summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Brown <jed@jedbrown.org>2018-08-21 13:05:16 -0600
committerGitHub <noreply@github.com>2018-08-21 13:05:16 -0600
commite1733b1c7c4169d0a1d31cb76f168fb0880176c0 (patch)
tree8230cf85d4af34c5b5376302d7883850293b330f
parent75fb63d034878cc5be2d4339e52bb6b6983d0626 (diff)
parent2fad58fd0631ed8dcb77358bb9b80e4cd091d3fe (diff)
downloadgit-fat-master.tar.gz
Merge pull request #83 from thcipriani/git-fat-upstreamHEADmaster
Invalidate git index cache before smudging
-rwxr-xr-xgit-fat17
1 files changed, 12 insertions, 5 deletions
diff --git a/git-fat b/git-fat
index 99facf6..135f4e2 100755
--- a/git-fat
+++ b/git-fat
@@ -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):