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

Git dirtiness check not working correctly #224

Closed
dmhacker opened this issue Sep 20, 2018 · 2 comments
Closed

Git dirtiness check not working correctly #224

dmhacker opened this issue Sep 20, 2018 · 2 comments

Comments

@dmhacker
Copy link

Hello! I thought I might bring this to your attention, since it seems that the dirtiness check for git repositories is not working correctly. It's pretty simple to reproduce:

mkdir test && cd test
git init
mkdir dir1
mkdir dir2
touch dir1/placeholder
cd dir2

At the end of running these commands, you'll notice that the git repository is being marked as clean inside dir2 when it should be marked as dirty. However, when you cd .. outside of dir2, the repository is then correctly marked as being dirty.

The problem seems to be arising from a bug in prompt_geometry_git_status(). You are running the commands git status --porcelain --ignore-submodules HEAD and git ls-files --others --modified --exclude-standard to perform the dirtiness check; however, the ls-files command implicity runs from the current directory. What you really want is git ls-files --others --modified --exclude-standard $(git rev-parse --show-toplevel) which then runs the command from the top level git directory.

My solution is to is to run a patched version of the function that just uses git status --porcelain --ignore-submodules and removes the ls-files command. I added a flag PROMPT_GEOMETRY_GIT_UNTRACKED_DIRTY that can disable checks for untracked files for large repositories (by simply running a git diff). It's the approach that the pure prompt takes. I'll be submitting a pull request shortly that you guys can review.

Love the prompt otherwise though. Keep up the good work!

@jedahan
Copy link
Member

jedahan commented Jan 2, 2019

Hey, I think I used the first fix you described in my branch https://github.com/jedahan/geometry (which also simplifies a lot how to use geometry). Thanks for the report and PR!

@jedahan
Copy link
Member

jedahan commented Aug 21, 2019

fixed in the latest

@jedahan jedahan closed this as completed Aug 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants