Skip to content

Commit

Permalink
Merge branch 'jk/pager-with-external-command'
Browse files Browse the repository at this point in the history
* jk/pager-with-external-command:
  support pager.* for external commands
  • Loading branch information
Junio C Hamano committed Aug 29, 2011
2 parents 2478bd8 + 92058e4 commit 67c116b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions git.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ static void execv_dashed_external(const char **argv)
const char *tmp;
int status;

if (use_pager == -1)
use_pager = check_pager_config(argv[0]);
commit_pager_choice();

strbuf_addf(&cmd, "git-%s", argv[0]);
Expand Down
36 changes: 36 additions & 0 deletions t/t7006-pager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -450,4 +450,40 @@ test_expect_success TTY 'command-specific pager overridden by environment' '
test_cmp expect actual
'

test_expect_success 'setup external command' '
cat >git-external <<-\EOF &&
#!/bin/sh
git "$@"
EOF
chmod +x git-external
'

test_expect_success TTY 'command-specific pager works for external commands' '
sane_unset PAGER GIT_PAGER &&
echo "foo:initial" >expect &&
>actual &&
test_config pager.external "sed s/^/foo:/ >actual" &&
test_terminal git --exec-path="`pwd`" external log --format=%s -1 &&
test_cmp expect actual
'

test_expect_success TTY 'sub-commands of externals use their own pager' '
sane_unset PAGER GIT_PAGER &&
echo "foo:initial" >expect &&
>actual &&
test_config pager.log "sed s/^/foo:/ >actual" &&
test_terminal git --exec-path=. external log --format=%s -1 &&
test_cmp expect actual
'

test_expect_success TTY 'external command pagers override sub-commands' '
sane_unset PAGER GIT_PAGER &&
>expect &&
>actual &&
test_config pager.external false &&
test_config pager.log "sed s/^/log:/ >actual" &&
test_terminal git --exec-path=. external log --format=%s -1 &&
test_cmp expect actual
'

test_done

0 comments on commit 67c116b

Please sign in to comment.