Re: Git issue
- From
Philip Oakley <philipoakley@iee.org>
- Date
- Nov 1, 2016, 20:50 UTC
- Message-ID
- <7CE3166CFD244DAABF554451E8B0800F@PhilipOakley>
- In-Reply-To
- <20161101174526.e2tilsriz2fqaru3@sigill.intra.peff.net>
From: "Jeff King" <peff@peff.net>
Show 16 quoted lines
> On Tue, Nov 01, 2016 at 10:28:57AM +0000, Halde, Faiz wrote: > >> I frequently use the following command to ignore changes done in a file >> >> git update-index --assume-unchanged somefile >> >> Now when I do a pull from my remote branch and say the file 'somefile' >> was changed locally and in remote, git will abort the merge saying I >> need to commit my changes of 'somefile'. >> >> But isn't the whole point of the above command to ignore the changes >> within the file? > > No. The purpose of --assume-unchanged is to promise git that you will > not change the file, so that it may skip checking the file contents in > some cases as an optimization.
True. However...
Show 20 quoted lines
> > From "git help update-index": > > --[no-]assume-unchanged > When this flag is specified, the object names recorded for > the paths are not updated. Instead, this option sets/unsets > the "assume unchanged" bit for the paths. When the "assume > unchanged" bit is on, the user promises not to change the > file and allows Git to assume that the working tree file > matches what is recorded in the index. If you want to change > the working tree file, you need to unset the bit to tell Git. > This is sometimes helpful when working with a big project on > a filesystem that has very slow lstat(2) system call (e.g. > cifs). > > Git will fail (gracefully) in case it needs to modify this > file in the index e.g. when merging in a commit; thus, in > case the assumed-untracked file is changed upstream, you will > need to handle the situation manually. >
The whole section (including the ones above this quote) are often confused between the promises of the user, and the alleged promises of Git. Even in the quote above the "Instead" probably shouldn't be there.
Given the number of misrepresentations (on the web) of what the bit does, and the ongoing misunderstandings of users it does feel like the man page article could be refreshed to be more assertive about the users promise, and Git's cautions.
My quick rough working on a more assertive update.. -- >8 -- ---------------------- Documentation/git-update-index.txt ---------------------- index 7386c93..4ec1711 100644
@@ -84,12 +84,12 @@ OPTIONS Set the execute permissions on the updated files. --[no-]assume-unchanged:: When this flag is specified, the object names recorded - for the paths are not updated. Instead, this option + for the paths are not updated. This option sets/unsets the "assume unchanged" bit for the paths. When the "assume unchanged" bit is on, the user - promises not to change the file and allows Git to assume + *promises* not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git. This is sometimes helpful when working with a big project on a @@ -300,19 +300,25 @@ $ git ls-files -s Using ``assume unchanged'' bit ------------------------------ -Many operations in Git depend on your filesystem to have an +Many operations in Git depend on your filesystem having a fast and efficient `lstat(2)` implementation, so that `st_mtime` information for working tree files can be cheaply checked to see if the file contents have changed from the version recorded in the index file. Unfortunately, some filesystems have inefficient `lstat(2)`. If your filesystem is one of them, you -can set "assume unchanged" bit to paths you have not changed to -cause Git not to do this check. Note that setting this bit on a -path does not mean Git will check the contents of the file to -see if it has changed -- it makes Git to omit any checking and -assume it has *not* changed. When you make changes to working +can set "assume unchanged" bit to *paths you have not changed* to +cause Git not to do this check. + +Note that setting this bit on a +path does not mean Git will never check the contents of the file to +see if it has changed. Though normally it makes Git to omit any checking to +assume it has not changed. +Commands which may overwrite local changes (pull/merge etc) are +likely to check if the contents have changed + +If you make desired changes to working tree files, you have to explicitly tell Git about it by dropping "assume unchanged" bit, either before or after you modify them. In order to set "assume unchanged" bit, use `--assume-unchanged` --- Philip