apply: run setup_git_directory_gently() sooner
As v1.7.2~16^2 (2010-07-14) explains, without this change, “git --paginate apply” can ignore the repository-local “[core] pager” configuration. 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 16, 2010 at 10:36 UTC
d1ea896290629185dc0bf4efa3469b410bd41313
3 files changed
+7
-4
builtin/apply.c
+3
-3
@@ -3607,11 +3607,11 @@ static int option_parse_directory(const struct option *opt,
3607
return 0;
3608
}
3609
3610
-int cmd_apply(int argc, const char **argv, const char *unused_prefix)
3610
+int cmd_apply(int argc, const char **argv, const char *prefix_)
3611
{
3612
int i;
3613
int errs = 0;
3614
- int is_not_gitdir;
3614
+ int is_not_gitdir = !startup_info->have_repository;
3615
int binary;
3616
int force_apply = 0;
3617
@@ -3684,7 +3684,7 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
3684
OPT_END()
3685
};
3686
3687
- prefix = setup_git_directory_gently(&is_not_gitdir);
3687
+ prefix = prefix_;
3688
prefix_length = prefix ? strlen(prefix) : 0;
3689
git_config(git_apply_config, NULL);
3690
if (apply_default_whitespace)
git.c
+1
-1
@@ -301,7 +301,7 @@ static void handle_internal_command(int argc, const char **argv)
301
{ "add", cmd_add, RUN_SETUP | NEED_WORK_TREE },
302
{ "stage", cmd_add, RUN_SETUP | NEED_WORK_TREE },
303
{ "annotate", cmd_annotate, RUN_SETUP },
304
- { "apply", cmd_apply },
304
+ { "apply", cmd_apply, RUN_SETUP_GENTLY },
305
{ "archive", cmd_archive },
306
{ "bisect--helper", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },
307
{ "blame", cmd_blame, RUN_SETUP },
t/t7006-pager.sh
+3
@@ -391,4 +391,7 @@ test_no_local_config_subdir expect_success 'git shortlog'
391
test_default_pager expect_success 'git -p shortlog'
392
test_core_pager_subdir expect_success 'git -p shortlog'
393
394
+test_core_pager_subdir expect_success test_must_fail \
395
+ 'git -p apply </dev/null'
396
+
397
test_done