summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Murty <james@murty.co>2014-05-23 16:20:30 +0100
committerJames Murty <james@murty.co>2014-05-23 16:20:30 +0100
commit9f52324add1a4ededc8f47d11e90216f40cab497 (patch)
tree6732d80979632f40ba3f50a99134095736f6e701
parent456d22cb3c7ba60e15d5d0f7de771c2acf573481 (diff)
downloadgit-fat-9f52324add1a4ededc8f47d11e90216f40cab497.tar.gz
Fail with a clear error if 'git fat pull' is run on uninitialised repo.
This fixes issue #25 in the original project.
-rwxr-xr-xgit-fat9
-rwxr-xr-xtest.sh10
2 files changed, 18 insertions, 1 deletions
diff --git a/git-fat b/git-fat
index 97315ea..7a9c00d 100755
--- a/git-fat
+++ b/git-fat
@@ -370,6 +370,7 @@ class GitFat(object):
def cmd_pull(self, args):
'Pull anything that I have referenced, but not stored'
self.setup()
+ self.assert_init_done()
refargs = dict()
if '--all' in args:
refargs['all'] = True
@@ -414,9 +415,15 @@ class GitFat(object):
fname = os.path.join(self.objdir, obj)
print('%10d %s' % (os.stat(fname).st_size, obj))
os.remove(fname)
+ def is_init_done(self):
+ return gitconfig_get('filter.fat.clean') or gitconfig_get('filter.fat.smudge')
+ def assert_init_done(self):
+ if not self.is_init_done():
+ print('Git fat is not yet configured in this repository, run "git fat init"')
+ sys.exit(1)
def cmd_init(self):
self.setup()
- if gitconfig_get('filter.fat.clean') or gitconfig_get('filter.fat.smudge'):
+ if self.is_init_done():
print('Git fat already configured, check configuration in .git/config')
else:
gitconfig_set('filter.fat.clean', 'git-fat filter-clean')
diff --git a/test.sh b/test.sh
index e9c9163..a5ff2f6 100755
--- a/test.sh
+++ b/test.sh
@@ -2,6 +2,9 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
+# Clear out repos and fat store from prior test runs
+rm -fR fat-test fat-test2 /tmp/fat-store
+
git init fat-test
cd fat-test
git fat init
@@ -29,6 +32,13 @@ git fat push
cd ..
git clone fat-test fat-test2
cd fat-test2
+# Pull should fail in repo not yet init'ed for git-fat
+git fat pull -- 'a.fa*' && true
+if [ $? -eq 0 ]
+then
+ echo 'ERROR: "git fat pull" in uninitialised repo should fail'
+ exit 1
+fi
git fat init
git fat pull -- 'a.fa*'
cat a.fat