@matheusbsbs / matheus-bagliano / commits / e0fce074fc
Fork 0

index-pack: run setup_git_directory_gently() sooner

index-pack already runs a repository search unconditionally; running such a search earlier is not risky and ensures GIT_DIR will be set correctly if the configuration needs to be accessed from run_builtin(). Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Aug 5, 2010 at 22:18 UTC e0fce074fc4fdf2d2175ff97f1cc3db918ea87e9
2 files changed +1 -3
builtin/index-pack.c
-2
@@ -880,12 +880,10 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
880 char *index_name_buf = NULL, *keep_name_buf = NULL;
881 struct pack_idx_entry **idx_objects;
882 unsigned char pack_sha1[20];
883 - int nongit;
883
884 if (argc == 2 && !strcmp(argv[1], "-h"))
885 usage(index_pack_usage);
886
888 - prefix = setup_git_directory_gently(&nongit);
887 git_config(git_index_pack_config, NULL);
888 if (prefix && chdir(prefix))
889 die("Cannot come back to cwd");
git.c
+1 -1
@@ -339,7 +339,7 @@ static void handle_internal_command(int argc, const char **argv)
339 { "grep", cmd_grep, RUN_SETUP_GENTLY },
340 { "hash-object", cmd_hash_object },
341 { "help", cmd_help },
342 - { "index-pack", cmd_index_pack },
342 + { "index-pack", cmd_index_pack, RUN_SETUP_GENTLY },
343 { "init", cmd_init_db },
344 { "init-db", cmd_init_db },
345 { "log", cmd_log, RUN_SETUP | USE_PAGER },