Skip to content

git log or git show does not work when setting pager.<cmd> in version 2.11.0(2) or later #1077

Closed

Description

@hattya
  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options
git version 2.11.0.windows.1
sizeof-long: 4
machine: x86_64
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.14393]

Details

$ git config --global pager.diff 'diff-highlight | less'
$ git config --global pager.log 'diff-highlight | less'
$ git config --global pager.show 'diff-highlight | less'
$ git diff
$ git log
diff-highlight | less: No such file or directory
$ git show
diff-highlight | less: No such file or directory

The issue is introduced in commit 382b41b, and it seems that it is appeared by commit a9b8a09.

Following patch fixes the issue:

--- a/git.c
+++ b/git.c
@@ -633,10 +633,10 @@ static int run_argv(int *argcp, const char ***argv)
                                argv_array_push(&args, (*argv)[i]);

                        if (get_super_prefix())
-                               die("%s doesn't support --super-prefix", args.argv[0]);
+                               die("%s doesn't support --super-prefix", args.argv[1]);

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

                        trace_argv_printf(args.argv, "trace: exec:");

Activity

  1. dscho commented on Mar 2, 2017

    @dscho
    Member

    Following patch fixes the issue:

    Does it really? Have you verified that args.argv[1] is the command (not the first parameter)?

    diff-highlight | less: No such file or directory

    This indicates to me that the pager.<cmd> value is interpreted as path, not as command-line. From the documentation, it is not clear that it was ever meant to refer to a command-line instead of a path...

    However, from the source code it appears as if the value is actually passed to the shell, so it is a bit puzzling that it is not interpreted correctly.

  2. self-assigned this
    on Mar 2, 2017
  3. dscho commented on Mar 2, 2017

    @dscho
    Member

    it is a bit puzzling that it is not interpreted correctly.

    The reason is that a special "we have arguments" handling kicks in because in the Windows case apparently not only argv[0] is set to the pager value, but also argv[1]. This is a bug. I am continuing to investigate.

  4. dscho commented on Mar 2, 2017

    @dscho
    Member

    Hah. The problem is that isatty(1) returns non-zero even after the pager was started and stdout redirected.

  5. added this to the v2.12.1 milestone on Mar 2, 2017
  6. hattya commented on Mar 3, 2017

    @hattya
    Author

    Thank you for the fix!

    I think this patch should also be applied, it is a fix for commit 382b41b.

    It seems that commit 382b41b is copied from execv_dashed_external() without updating the index. In this scope, args.argv[0] is git and args.argv[1] (equals argv[0]) is a builtin command. Because get_builtin() returns non-NULL.

  7. dscho commented on Mar 3, 2017

    @dscho
    Member

    @hattya Uh oh. I must have been real tired when I looked at your patch. You are absolutely correct! Thanks!

  8. dscho commented on Mar 3, 2017

    @dscho
    Member

    BTW the code in question should only kick in after an alias was expanded. So I think you would need something like

    git -c pager.log 'diff-highlight | less' -c  alias.lg=log lg -1 -p

    to trigger that bug.

  9. dscho commented on Mar 3, 2017

    @dscho
    Member

    I chose to apply a slightly different patch, which also made the calls conciser and reordered to allow an early die() without having to initialize the args first.

  10. hattya commented on Mar 5, 2017

    @hattya
    Author

    Sorry, I thought I tested with git log and git show, but their aliases...

  11. added a commit that references this issue on Mar 6, 2017
  12. 226 remaining items

  13. added a commit that references this issue on Sep 11, 2018
  14. added a commit that references this issue on Oct 30, 2018
  15. added a commit that references this issue on Oct 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions