summaryrefslogtreecommitdiff
path: root/common-main.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-01-05 22:01:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-01-05 22:01:28 (GMT)
commitda81d473fcfa67dfbcf0504d2b5225885e51e532 (patch)
tree69f054e9d22dac00cf4b68705f3ab28dbb51a0b2 /common-main.c
parentd0c99fcc618fc71cff261246b9d5605cbd225329 (diff)
parent324b170b88475811cb0506a30b4710ffc89ae936 (diff)
downloadgit-da81d473fcfa67dfbcf0504d2b5225885e51e532.zip
git-da81d473fcfa67dfbcf0504d2b5225885e51e532.tar.gz
git-da81d473fcfa67dfbcf0504d2b5225885e51e532.tar.bz2
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 'common-main.c')
-rw-r--r--common-main.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/common-main.c b/common-main.c
index eafc707..29fb745 100644
--- a/common-main.c
+++ b/common-main.c
@@ -26,6 +26,7 @@ static void restore_sigpipe_to_default(void)
int main(int argc, const char **argv)
{
int result;
+ struct strbuf tmp = STRBUF_INIT;
trace2_initialize_clock();
@@ -49,6 +50,9 @@ int main(int argc, const char **argv)
trace2_cmd_start(argv);
trace2_collect_process_info(TRACE2_PROCESS_INFO_STARTUP);
+ if (!strbuf_getcwd(&tmp))
+ tmp_original_cwd = strbuf_detach(&tmp, NULL);
+
result = cmd_main(argc, argv);
/*