diff options
author | Jed Brown <jed@jedbrown.org> | 2018-08-21 13:05:16 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-21 13:05:16 -0600 |
commit | e1733b1c7c4169d0a1d31cb76f168fb0880176c0 (patch) | |
tree | 8230cf85d4af34c5b5376302d7883850293b330f /git-fat | |
parent | 75fb63d034878cc5be2d4339e52bb6b6983d0626 (diff) | |
parent | 2fad58fd0631ed8dcb77358bb9b80e4cd091d3fe (diff) | |
download | git-fat-master.tar.gz |
Invalidate git index cache before smudging
Diffstat (limited to 'git-fat')
-rwxr-xr-x | git-fat | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -412,11 +412,18 @@ class GitFat(object): # the file in .git/fat/objects, but git caches the file stat # from the previous time the file was smudged, therefore it # won't try to re-smudge. I don't know a git command that - # specifically invalidates that cache, but touching the file - # also does the trick. - os.utime(fname, None) - # This re-smudge is essentially a copy that restores permissions. - subprocess.check_call(['git', 'checkout-index', '--index', '--force', fname]) + # specifically invalidates that cache, but changing the mtime + # on the file will invalidate the cache. + # Here we set the mtime to mtime + 1. This is an improvement + # over touching the file as it catches the edgecase where a + # git-checkout happens within the same second as a git fat + # checkout. + stat = os.lstat(fname) + os.utime(fname, (stat.st_atime, stat.st_mtime + 1)) + # This re-smudge is essentially a copy that restores + # permissions. + subprocess.check_call( + ['git', 'checkout-index', '--index', '--force', fname]) elif show_orphans: print('Data unavailable: %s %s' % (digest,fname)) def cmd_pull(self, args): |