简体   繁体   中英

Where can I find the files list displaying all files that have been set `assume-unchanged`?

Git has a function to ignore a changed file when you pull from remote repository. That's git update-index --assume-unchanged yourFileName . I just want to know how can I know that whether a file has been set with this flag. However there is nothing I can find in google.

According to the documentation :

To see which files have the "assume unchanged" bit set, use git ls-files -v

Where in -v stands for:

Similar to -t , but use lowercase letters for files that are marked as assume unchanged.

Therefore the lowercase letter in front of the file name will indicate that this file is marked as "assume unchanged". git-ls-files also accepts file name as an argument, so you could use it as follows:

git ls-files -v <file-name>

These bits can only be seen, as far as I know, with the --debug and -v flags of git ls-files . The output for --debug is deliberately not very well documented, while the output for -v is linked with that for -t which is called "semi-deprecated".

I set the assume-unchanged flag on wt-status.c and the skip-worktree flags on wt-status.h in a Git repository for Git. Here's a bit of git ls-files output, with various flags; the assume-unchanged flag, set on wt-status.c , is 0x8000 :

$ git ls-files --debug
...
wt-status.c
  ctime: 1479501926:0
  mtime: 1479501926:0
  dev: 127  ino: 11320057
  uid: 1001 gid: 1001
  size: 63601   flags: 8000
wt-status.h
  ctime: 1479501926:0
  mtime: 1479501926:0
  dev: 127  ino: 11320058
  uid: 1001 gid: 1001
  size: 3534    flags: 40004000

As you can see here, wt-status.h (with skip-worktree set) has flags 0x40004000 , which are:

#define CE_EXTENDED  (0x4000)
#define CE_SKIP_WORKTREE     (1 << 30)

(I skipped inapplicable flags here: they run from 0x3000 , which are the stage number mask, through 1 << 31 . Some appear to be used in-core only and some are saved in the actual on-disk index.)

Attempting to set both assume-unchanged and --skip-worktree works, but must be done in two steps:

$ git update-index --assume-unchanged ws.c
$ git update-index --skip-worktree ws.c
$ git ls-files --debug -- ws.c
ws.c
  ctime: 1451486045:0
  mtime: 1451486045:0
  dev: 127  ino: 11319929
  uid: 1001 gid: 1001
  size: 9782    flags: 4000c000

(attempting to set both at once just set one of them). Here's how git ls-files -v shows them:

$ git ls-files -v -- ws.c wt-status.c wt-status.h xdiff-interface.h
s ws.c
h wt-status.c
S wt-status.h
H xdiff-interface.h

(I included an extra file, with no flags set, to show how that gets displayed here: the H indicates that it's in the cache. This is of course necessarily true for any file that has a bit set in the cache. That should include files marked for deletion [ CE_REMOVE_WT or 1 << 22 ] though git ls-files won't show them, even with --deleted , which seems like a bug.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM