Skip to content

Commit d1ea896

Browse files
pcloudsgitster
authored andcommitted
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>
1 parent ff38d1a commit d1ea896

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

builtin/apply.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3607,11 +3607,11 @@ static int option_parse_directory(const struct option *opt,
36073607
return 0;
36083608
}
36093609

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_)
36113611
{
36123612
int i;
36133613
int errs = 0;
3614-
int is_not_gitdir;
3614+
int is_not_gitdir = !startup_info->have_repository;
36153615
int binary;
36163616
int force_apply = 0;
36173617

@@ -3684,7 +3684,7 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
36843684
OPT_END()
36853685
};
36863686

3687-
prefix = setup_git_directory_gently(&is_not_gitdir);
3687+
prefix = prefix_;
36883688
prefix_length = prefix ? strlen(prefix) : 0;
36893689
git_config(git_apply_config, NULL);
36903690
if (apply_default_whitespace)

git.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ static void handle_internal_command(int argc, const char **argv)
301301
{ "add", cmd_add, RUN_SETUP | NEED_WORK_TREE },
302302
{ "stage", cmd_add, RUN_SETUP | NEED_WORK_TREE },
303303
{ "annotate", cmd_annotate, RUN_SETUP },
304-
{ "apply", cmd_apply },
304+
{ "apply", cmd_apply, RUN_SETUP_GENTLY },
305305
{ "archive", cmd_archive },
306306
{ "bisect--helper", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },
307307
{ "blame", cmd_blame, RUN_SETUP },

t/t7006-pager.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,4 +391,7 @@ test_no_local_config_subdir expect_success 'git shortlog'
391391
test_default_pager expect_success 'git -p shortlog'
392392
test_core_pager_subdir expect_success 'git -p shortlog'
393393

394+
test_core_pager_subdir expect_success test_must_fail \
395+
'git -p apply </dev/null'
396+
394397
test_done

0 commit comments

Comments
 (0)