Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes in git not detected if root contains file named HEAD #517

Closed
dpinol opened this issue Apr 27, 2017 · 4 comments
Closed

changes in git not detected if root contains file named HEAD #517

dpinol opened this issue Apr 27, 2017 · 4 comments
Labels
bug git Related to Git VCS data
Milestone

Comments

@dpinol
Copy link

dpinol commented Apr 27, 2017

Shell: bash
Operating system: OSX 10.12.4
Liquid Prompt version (tag, commit): 1.11

when there are git changes on a git checkout whose root contains a file named HEAD, the prompt does not display them (remains in green).

Problem is with line 929
shortstat="$(LC_ALL=C \git diff --shortstat HEAD 2>/dev/null)"
This is because git does not know if we refer to the HEAD file or the HEAD revision

master* ± git diff --shortstat HEAD
fatal: ambiguous argument 'HEAD': both revision and filename
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]

I suggest this patch
shortstat="$(LC_ALL=C \git diff --shortstat HEAD -- 2>/dev/null)"

dpinol pushed a commit to dpinol/liquidprompt that referenced this issue Apr 27, 2017
@Rycieos
Copy link
Collaborator

Rycieos commented Apr 27, 2017

liquidprompt 1.11 is 25 commits behind master. You should update and try to reproduce.

I have the same version of git, and cannot reproduce this problem.

Note that the original line is a diff between the working directory and the HEAD commit. Your amended line is a diff between the working directory and the staging area. There should be no change in behavior between different git versions.

@dpinol dpinol changed the title changes in git not detected with new version changes in git not detected if root contains file named HEAD Apr 27, 2017
@dpinol
Copy link
Author

dpinol commented Apr 27, 2017

@Rycieos thank you your you prompt :-) answer. You're completely right, I rewrote the issue. The problem is that I had a file named HEAD.

@Rycieos
Copy link
Collaborator

Rycieos commented Apr 27, 2017

An interesting issue. Not strictly relevant, but why do you have a file named "HEAD"?

There very well might be many more locations where this could be a problem. Anywhere that a HEAD, master, or origin is referenced might break in a similar way. Maybe it's worth it to evaluate other such possible problem locations?

@dolmen dolmen added bug git Related to Git VCS data labels Aug 28, 2018
@Rycieos Rycieos added this to the v1.12 milestone Jun 30, 2020
@Rycieos
Copy link
Collaborator

Rycieos commented Jun 30, 2020

I just pushed a commit to the master branch fixing this. Sorry for the delay!

I tested all our other git evocations, but it turns out you caught the only place where this seems to be a problem. Thanks for helping us track this down, and providing great reproduction steps.

pkkolos pushed a commit to pkkolos/liquidprompt that referenced this issue May 9, 2021
"git diff" can take both refs and filenames, so if there a file named
HEAD, it would error not knowing which you wanted. Add the notation to
tell git we want the ref.

I checked and tested all the other git calls we are using, and this was
the only one that could take both filenames and refs, so therefore the
only one that needed changes.

Fixes liquidprompt#517
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug git Related to Git VCS data
Projects
None yet
Development

No branches or pull requests

3 participants