diff options
| author | Junio C Hamano <gitster@pobox.com> | 2022-01-05 14:01:28 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2022-01-05 14:01:28 -0800 |
| commit | da81d473fcfa67dfbcf0504d2b5225885e51e532 (patch) | |
| tree | 69f054e9d22dac00cf4b68705f3ab28dbb51a0b2 /dir.h | |
| parent | d0c99fcc618fc71cff261246b9d5605cbd225329 (diff) | |
| parent | 324b170b88475811cb0506a30b4710ffc89ae936 (diff) | |
| download | git-da81d473fcfa67dfbcf0504d2b5225885e51e532.tar.xz | |
Merge branch 'en/keep-cwd'
Many git commands that deal with working tree files try to remove a
directory that becomes empty (i.e. "git switch" from a branch that
has the directory to another branch that does not would attempt
remove all files in the directory and the directory itself). This
drops users into an unfamiliar situation if the command was run in
a subdirectory that becomes subject to removal due to the command.
The commands have been taught to keep an empty directory if it is
the directory they were started in to avoid surprising users.
* en/keep-cwd:
t2501: simplify the tests since we can now assume desired behavior
dir: new flag to remove_dir_recurse() to spare the original_cwd
dir: avoid incidentally removing the original_cwd in remove_path()
stash: do not attempt to remove startup_info->original_cwd
rebase: do not attempt to remove startup_info->original_cwd
clean: do not attempt to remove startup_info->original_cwd
symlinks: do not include startup_info->original_cwd in dir removal
unpack-trees: add special cwd handling
unpack-trees: refuse to remove startup_info->original_cwd
setup: introduce startup_info->original_cwd
t2501: add various tests for removing the current working directory
Diffstat (limited to 'dir.h')
| -rw-r--r-- | dir.h | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -495,6 +495,9 @@ int get_sparse_checkout_patterns(struct pattern_list *pl); /* Remove the contents of path, but leave path itself. */ #define REMOVE_DIR_KEEP_TOPLEVEL 04 +/* Remove the_original_cwd too */ +#define REMOVE_DIR_PURGE_ORIGINAL_CWD 0x08 + /* * Remove path and its contents, recursively. flags is a combination * of the above REMOVE_DIR_* constants. Return 0 on success. @@ -504,7 +507,11 @@ int get_sparse_checkout_patterns(struct pattern_list *pl); */ int remove_dir_recursively(struct strbuf *path, int flag); -/* tries to remove the path with empty directories along it, ignores ENOENT */ +/* + * Tries to remove the path, along with leading empty directories so long as + * those empty directories are not startup_info->original_cwd. Ignores + * ENOENT. + */ int remove_path(const char *path); int fspathcmp(const char *a, const char *b); |
