Skip to content

Commit 92ec546

Browse files
feat(record): add untracked file detection
This updates `git record` and `git amend` to automaticaly detect (and optionally add) new, untracked files. There are 4 modes of operation, configurable via command line option and config setting: - `disable` (default): do nothing; don't look for untracked files on disk/in db - `skip`: new files are not added, will remain skipped in subsequent invocaions - `add`: new files are added to the commit - `prompt`: user will be prompted for what to do with each new file Notes: - As noted above, this behavior it totally disabled by default. It must be enabled either via CLI option, or via the config setting. - Untracked files are considered "new" if they are detected on disk, but aren't in the cached list from last run (ie in the db). - Every invocation of record/amend updates a cache of "known" untracked files, stored in our internal sqlite db. - Because the cache is updated on every invocation, a previously skipped file may be treated as a new file if was deleted and later recreated. - Config setting `branchless.record.untrackedFiles` is provided to change the default runtime behavior, ie when `--untracked` is not used - If there are staged changes, then no untracked files are added/prompted. - A list of "known" (previously skipped) files is printed at runtime. Admittedly, this can be sort of annoying, but it is intended to help maintain "situational awareness" and reduce confusion about why the feature is behaving in a particular way. This may need to be reconsidered based on user feedback. - When new files are skipped, a hint is shown to remind the user that - they will remain skipped forever - if they need to be added, they need to do so manually, via `git add`
1 parent 2ac991e commit 92ec546

File tree

13 files changed

+967
-15
lines changed

13 files changed

+967
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- (#1461): added `!` revset postfix operator as shortcut for "only child"
1515
- (#1464): created `git split` command to extract changes from a commit
1616
- (#1603): added `git move --dry-run` to test in-memory rebases
17+
- (#1604): `git record` and `git amend` can now automatically detect and begin tracking new files (optional, disabled by default)
1718
- (#1632): added `git record --fixup` option, to create a fixup commit (similar to `reword --fixup`)
1819

1920
### Changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

git-branchless-lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ async-trait = { workspace = true }
4848
bstr = { workspace = true }
4949
chashmap = { workspace = true }
5050
chrono = { workspace = true }
51+
clap = { workspace = true }
5152
color-eyre = { workspace = true }
5253
concolor = { workspace = true }
5354
console = { workspace = true }

git-branchless-lib/src/core/config.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ pub const RESTACK_WARN_ABANDONED_CONFIG_KEY: &str = "branchless.restack.warnAban
250250
/// Possible hint types.
251251
#[derive(Clone, Debug)]
252252
pub enum Hint {
253+
/// Suggest running `git add` on skipped, untracked files, which are never
254+
/// automatically reconsidered for tracking.
255+
AddSkippedFiles,
256+
253257
/// Suggest running `git test clean` in order to clean cached test results.
254258
CleanCachedTestResults,
255259

@@ -269,6 +273,7 @@ pub enum Hint {
269273
impl Hint {
270274
fn get_config_key(&self) -> &'static str {
271275
match self {
276+
Hint::AddSkippedFiles => "branchless.hint.addSkippedFiles",
272277
Hint::CleanCachedTestResults => "branchless.hint.cleanCachedTestResults",
273278
Hint::MoveImplicitHeadArgument => "branchless.hint.moveImplicitHeadArgument",
274279
Hint::RestackWarnAbandoned => "branchless.hint.restackWarnAbandoned",

git-branchless-lib/src/core/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ pub mod node_descriptors;
1111
pub mod repo_ext;
1212
pub mod rewrite;
1313
pub mod task;
14+
pub mod untracked_file_cache;

0 commit comments

Comments
 (0)