summaryrefslogtreecommitdiff
path: root/git-fat
diff options
context:
space:
mode:
authorJed Brown <jed@59A2.org>2012-11-26 07:30:20 +0100
committerJed Brown <jed@59A2.org>2012-11-26 07:30:20 +0100
commita155e456f4dcbd3a919d6fecb7c078b6a1a28756 (patch)
tree2ca3dfe4aeb0bdbc10bf6d5c7d349d11ede4ef1d /git-fat
parenta6c335a64420e65296af579f4103980c6be09a00 (diff)
downloadgit-fat-a155e456f4dcbd3a919d6fecb7c078b6a1a28756.tar.gz
Cleaner way to checkout files after pull
Diffstat (limited to 'git-fat')
-rwxr-xr-xgit-fat16
1 files changed, 11 insertions, 5 deletions
diff --git a/git-fat b/git-fat
index 84be082..bd6ed9c 100755
--- a/git-fat
+++ b/git-fat
@@ -98,7 +98,7 @@ class GitFat(object):
fd, tmpname = tempfile.mkstemp(dir=self.objdir)
try:
ishanging = False
- cached = False # changes to True when file is cached, means we
+ cached = False # changes to True when file is cached
with os.fdopen(fd, 'w') as cache:
outstream = cache
blockiter = readblocks(sys.stdin)
@@ -116,9 +116,13 @@ class GitFat(object):
digest = h.hexdigest()
objfile = os.path.join(self.objdir, digest)
if not ishanging:
- os.rename(tmpname, objfile)
+ if os.path.exists(objfile):
+ self.verbose('git-fat filter-clean: cache already exists %s' % objfile)
+ os.remove(tmpname)
+ else:
+ os.rename(tmpname, objfile)
+ self.verbose('git-fat filter-clean: caching to %s' % objfile)
cached = True
- self.verbose('git-fat filter-clean: caching to %s' % objfile)
sys.stdout.write(self.encode(digest))
finally:
if not cached:
@@ -181,6 +185,8 @@ class GitFat(object):
print('Garbage objects:')
for g in garbage:
print(' ' + g)
+ def is_dirty(self):
+ return subprocess.call(['git', 'diff-index', '--quiet', 'HEAD']) == 0
def cmd_push(self):
'Push anything that I have stored and referenced'
self.setup()
@@ -198,10 +204,10 @@ class GitFat(object):
objpath = os.path.join(self.objdir, digest)
if os.access(objpath, os.R_OK):
print('Restoring %s -> %s' % (digest, fname))
- shutil.copy(objpath, fname)
+ os.utime(fname, None)
+ subprocess.check_call(['git', 'checkout-index', '--index', '--force', fname])
elif show_orphans:
print('Data unavailable: %s %s' % (digest,fname))
- subprocess.call(['git', 'checkout', '.'])
def cmd_pull(self, args):
'Pull anything that I have referenced, but not stored'
self.setup()