[posh-git] Fix for the "phantom modified files" issue.

335 views
Skip to first unread message

Mark Embling

unread,
Apr 23, 2010, 6:07:58 AM4/23/10
to posh...@googlegroups.com
Hi,

For some time, we have suffered from an issue where the prompt would report that one (or more) files had been modified when in reality they had not changed. In particular, ReSharper files (MyProject.csproj.ReSharper for example) would exhibit this behaviour. After some investigation, I tracked this down to be caused by ReSharper re-saving the file (thereby changing its last-modified date) without actually changing the file contents. The prompt would display one modified file because the output of `git diff-files -M --name-status` would report the file changed. Running a `git status` would update it and the phantom "modification" would disappear.

Jeremy came across this (http://permalink.gmane.org/gmane.comp.version-control.git/144178) which details the very same problem and provides an explanation of this behaviour. In order to prevent this happening as the article says, we need to trigger an update of the informaton like so:

git update-index --refresh -q

I have added a call to this into the Get-GitStatus function in order to make sure git diff-files always reports the correct number of changed files. From my understanding, this should not make *too* much difference to the speed of posh-git, but will ensure we always get the correct information back each time the prompt is re-shown.

I've pushed up this change to my fork of posh-git at http://github.com/markembling/posh-git

Mark

Keith Dahlby

unread,
Apr 23, 2010, 6:54:33 AM4/23/10
to posh...@googlegroups.com
I had noticed that as well, thanks for the fix. That link mentions git diff has a setting to turn off refreshing the index - maybe we could provide the same?

Mark Embling

unread,
Apr 23, 2010, 7:00:35 AM4/23/10
to posh...@googlegroups.com
Yes, I suppose that is probably worthwhile. It's not something I'd ever set, but I can see that it'd make it consistent with git diff.

My first instinct is to add it to the GitPromptSettings, but I wonder whether it is sensible to define it there and effectively just be passing it down to the Get-GitStatus method? Perhaps there should be some other separate settings defined for this? I was wondering what you thought the best approach would be, or whether you think its fine to add to GitPromptSettings.

Keith Dahlby

unread,
Apr 23, 2010, 7:46:10 AM4/23/10
to posh...@googlegroups.com
I think GitPromptSettings is fine for now; can always move it later.

Mark Embling

unread,
Apr 23, 2010, 8:08:10 AM4/23/10
to posh...@googlegroups.com
I have pushed up with this new setting added (GitPromptSettings.AutoRefreshIndex), defaulting to $true.

I have also swapped the arguments to git update-index around to have -q first as it seems that it does matter (certainly in the particular version of git I'm using at least).

Mark
Reply all
Reply to author
Forward
0 new messages