Question - Refresh the index, or we might get wrong results.
Closed this issue · 3 comments
Hi, Thanks for creating this script. It looks really useful.
I am considering using it for my own project folder before I update my operating system. A kind of indication of any repos that are in an untidy state.
However I notice the line:
# Refresh the index, or we might get wrong results.
git --work-tree "$(dirname "$GIT_DIR")" --git-dir "$GIT_DIR" update-index -q --refresh >/dev/null 2>&1
I am not sure how this changes the state of the repository. Does it add unadded files?
I am not sure if/how it could change the state of a working copy of a repo and whether it is desirable to have such changes happen on a repo.
I am thinking sometimes, a .gitignore file may not have been set correctly and it might add items which were left 'not added'.
I might be wrong, so just want to hear your thoughts on this.
Hi Forikal-uk!
I am not sure how this changes the state of the repository. Does it add unadded files?
No, it doesn't really change anything. The git index keeps track of the status of files on disk. It's normally automatically refreshed whenever you do a "git status" command. However, multi-git-status never actually runs "git status", so there are situations in which the index does not reflect what is actually on disk, and multi-git-status returns incorrect results. So it updates the index manually through "git update-index --refresh".
I am not sure if/how it could change the state of a working copy of a repo and whether it is desirable to have such changes happen on a repo.
Unless you provide the "-f
" option to mgitstatus, all operations mgitstatus does on your repos are side-effect free. That is, absolutely nothing (other than updating the index) changes in your repo. The "-f
" (fetch) option obviously does change things, as performs a "git fetch".
If you ever notice that mgitstatus does have unintended side-effects, please let me know, as I would consider it a grave bug. mgitstatus should always follow the Law Of Least Astonishment.
If you have any further questions, please don't hesitate to ask!
Thanks for clearing it up. I'm glad you are aiming for avoiding unintended-side-effects operation.
I shall give it a go. Once again, thanks for building this tool and offering it to the world.
You're welcome, and I hope you find it useful!