Skip to content

git show not working with files beginning with periods #685

Closed

Description

@rcdailey
  • 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? 32-bit or 64-bit? Include the
    output of git version as well.

Windows 8 x64, running 64-bit git

$ git --version
git version 2.7.2.windows.1
  • What options did you set as part of the installation? Or did you choose the
    defaults?

File caching set to enabled

  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

Happens on Windows only, works fine on Ubuntu 15

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Default bash shell

$ git show origin/develop:.gitmodules
  • What did you expect to occur after running these commands?

I expect the contents of the .gitmodules file on ref origin/develop to be printed.

  • What actually happened instead?

No output

Note on Ubuntu 15 I get this output:

$ GIT_TRACE=1 git show origin/develop:.gitmodules
10:49:09.589883 git.c:348               trace: built-in: git 'show' 'origin/develop:.gitmodules'
10:49:09.590826 run-command.c:338       trace: run_command: 'less'

I obtained this output by running ssh user@ubuntumachine FROM an actual Git Terminal on my Windows machine. So this should rule out any issue with the terminal itself, right?

The corresponding command run in a repository ON my windows machine using the git terminal:

$ GIT_TRACE=1 git show origin/develop:.gitmodules
10:48:00.961265 git.c:348               trace: built-in: git 'show' 'origin\develop;.gitmodules'
10:48:00.968267 run-command.c:343       trace: run_command: 'less'

The only observable difference I see is that on Windows a ; (semicolon) is used in the trace output, but a : (colon) used on Ubuntu. Note that show works fine as long as the file doesn't begin with a period. For example, both platforms output fine if I do git show origin/develop:CMakeLists.txt.

Activity

  1. whoisj commented on Mar 18, 2016

    @whoisj

    Confirmed.

    Works as expected from PowerShell, but with Git Bash there is no output.

  2. dscho commented on Apr 2, 2016

    @dscho
    Member

    The culprit is the POSIX <-> Windows path conversion, mentioned in our release notes:

    • If you specify command-line options starting with a slash, POSIX-to-Windows path conversion will kick in converting e.g. "/usr/bin/bash.exe" to "C:\Program Files\Git\usr\bin\bash.exe". When that is not desired -- e.g. "--upload-pack=/opt/git/bin/git-upload-pack" or "-L/regex/" -- you need to set the environment variable MSYS_NO_PATHCONV temporarily, like so:

      MSYS_NO_PATHCONV=1 git blame -L/pathconv/ msys2_path_conv.cc

      Alternatively, you can double the first slash to avoid POSIX-to-Windows path conversion.

    Granted, it does not talk about colons followed by a dot per se, but it is essentially the same problem. To the Bash, you see, it looks as if you are passing a path list of the form <path1>:<path2>:<path3>, using the standard POSIX path separator :, and it sees that you want to pass this path list to the non-POSIX program git.exe, so it assumes that git.exe wants this path list to have the standard Windows path separator ;. The MSYS_NO_PATHCONV=1 trick helps in this case. Not using the Bash would also help in this case, of course.

  3. dscho commented on Apr 2, 2016

    @dscho
    Member

    As changing the POSIX <-> Windows path conversion according to this ticket's wishes would break more things than it would fix, I am closing this as "wontfix".

  4. rcdailey commented on Apr 2, 2016

    @rcdailey
    Author
  5. rcdailey commented on Apr 3, 2016

    @rcdailey
    Author
  6. drizzd commented on Feb 20, 2017

    @drizzd

    Note that MSYS_NO_PATHCONV=1 works only with git-for-windows patches to the msys2-runtime. Users of the upstream msys2-runtime can use MSYS2_ARG_CONV_EXCL='*' instead, documented at https://github.com/msys2/msys2/wiki/Porting#filesystem-namespaces.

    $ git rev-parse --sq-quote origin/develop:.gitmodules
    'origin\develop;.gitmodules'
    $ MSYS2_ARG_CONV_EXCL='*' git rev-parse --sq-quote origin/develop:.gitmodules
    'origin/develop:.gitmodules'
    

    @dscho I agree that changing the path conversion would only cause issues elsewhere. Just for the record, here is an example that would break:

    $ MSYS2_ARG_CONV_EXCL='*' git ls-files /home/drizzd/git/README.md
    fatal: Not a git repository (or any of the parent directories): .git
    

    But if origin\develop;.gitmodules does not match a file literally, we could interpret it as <rev>;<path>, same as we interpret origin/develop:.gitmodules as <rev>:<path> if it does not match a file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions