]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'en/keep-cwd'
authorJunio C Hamano <gitster@pobox.com>
Wed, 5 Jan 2022 22:01:28 +0000 (14:01 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 5 Jan 2022 22:01:28 +0000 (14:01 -0800)
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

1  2 
builtin/stash.c
cache.h
common-main.c
dir.c
sequencer.c
unpack-trees.c

diff --cc builtin/stash.c
Simple merge
diff --cc cache.h
Simple merge
diff --cc common-main.c
index eafc70718a545abc8abc1cf9cce46f175881bbd4,aa8d5aba5bbfdd941e62020e41e83c781058c6cf..29fb7452f8a0b78cf7784ee4a1af7b26ebb53379
@@@ -49,12 -50,12 +50,15 @@@ 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);
  
 -      trace2_cmd_exit(result);
 -
 -      return result;
 +      /*
 +       * We define exit() to call trace2_cmd_exit_fl() in
 +       * git-compat-util.h. Whether we reach this or exit()
 +       * elsewhere we'll always run our trace2 exit handler.
 +       */
 +      exit(result);
  }
diff --cc dir.c
Simple merge
diff --cc sequencer.c
Simple merge
diff --cc unpack-trees.c
Simple merge