Skip to content
New issue

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

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

Already on GitHub? # to your account

.git is being touched continuously #97

Closed
tbg opened this issue Nov 8, 2014 · 9 comments · Fixed by #99
Closed

.git is being touched continuously #97

tbg opened this issue Nov 8, 2014 · 9 comments · Fixed by #99

Comments

@tbg
Copy link
Contributor

tbg commented Nov 8, 2014

While normally not being an issue, in the case of working on Docker builds etc it will mean that the cache is invalidated all the time.
I haven't had the time to look into why that happens, but the .git directory is definitely touched every time the prompt displays. I've looked at the code that updates the HEAD ref, but that's not it (that will run every 5mins by default).
I'll look into this more when I get the chance but maybe it's obvious why this happens to anyone here?

@magicmonty
Copy link
Owner

It seems that the git status command touches the .git directory. I currently have no idea how to circumvent this, as I need the output for displaying the prompt information.

@magicmonty
Copy link
Owner

Git writes and deletes an index.lock file into the .git directory. With the help of some nice people at StackOverflow I found out, that the index file could be set manually before issuing the status command. This will be done from now on, so there should be no more touching of the .git directory.

@moraxy
Copy link

moraxy commented Nov 14, 2014

The added GIT_INDEX_FILE=/tmp/bash_git_prompt_index results in faulty untracked numbers for me

moraxy@local:~/skript [master|✚ 4… 1644] $ GIT_INDEX_FILE=/tmp/bash_git_prompt_index git status -s -uall | grep -c "^??"
1644
moraxy@local:~/skript [master|✚ 4… 1644] $ git status -s -uall | grep -c "^??"
227

gitstatus.py also still gets it right

moraxy@local:~/skript [master|✚ 4… 1644] $ ~/.bash-git-prompt/gitstatus.py
master
.
0
0
4
227
0
0

@Gniourf
Copy link

Gniourf commented Nov 14, 2014

@moraxy You should copy the file .git/index to /tmp/bash_git_prompt_index, since all the files in staged area are stored in this file... with an empty index file, there are no files commited for git, that's why you get 1664 files. Good luck.

Edit: actually, a hard-link seems to work (and doesn't update .git's timestamp)… but be careful with these…

@moraxy
Copy link

moraxy commented Nov 14, 2014

That did it. But that means I would need to maintain a unique index copy for every repo plus some sort of update everytime something about the actual index changes, or not?

@magicmonty
Copy link
Owner

I have reverted this for now, as I have to implement this differently as it seems.
Copying the index file every time the status is updated could mean a huge bottlenech, so this needs to be configurable.

@magicmonty
Copy link
Owner

Please try it again. The git status command was used to get the count of the untracked files. Thanks to @tschottdorf this was replaced by a call to git ls-files, which should not touch the .git directory.

@moraxy
Copy link

moraxy commented Nov 15, 2014

Works fine, thank you and @tschottdorf for the quick response :)

@tbg
Copy link
Contributor Author

tbg commented Nov 15, 2014

My pleasure!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants