Re: Unfortunate interaction between git diff-index and fakeroot
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 7, 2017, 15:31 UTC
- Message-ID
- <xmqqzi6ueern.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <0190ae30-b6c8-2a8b-b1fb-fd9d84e6dfdf@oracle.com>
Elazar Leibovich <elazar.leibovich@oracle.com> writes:
Show 5 quoted lines
> We noticed some unexpected behavior of git, when running git commands under > fakeroot, and then running another command without fakeroot. > > When running, e.g., git status, or git describe --dirty, git can > update the index file.
Correct. fakeroot would report that the files that are actually owned by the user who is running fakeroot are owned by root; the cached stat information in the index would be "corrected" to say that they are owned by root. So once the index is refreshed like so, things will become consistent.
> The unexpected result is: > > "fakeroot git status" updates the index, and the index now says all files > are owned by uid:0.
You should learn to expect it; that is how fakeroot works.
> "git diff-index --name-only HEAD" is used to test if the git tree is dirty > without fakeroot, concluding all files have changed, since their owner UID > is changed.
The lower-level plumbing diff-* commands are meant to be used by scripts that refresh the index once upfront.
If you are using "diff-index" for the "is the tree dirty?" check without running "update-index --refresh", then you are not using the command correctly.