summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Brown <jed@59A2.org>2014-05-25 21:05:29 -0600
committerJed Brown <jed@59A2.org>2014-05-25 21:05:29 -0600
commit6b01b1a7080e3aad3b6c19e3938d83a3168cfd4e (patch)
treeab3d8ce95199e02d9816c1bfcb4e85dcf81bcce8
parent456d22cb3c7ba60e15d5d0f7de771c2acf573481 (diff)
parentb1af5996fd2b1fc5eb21bab2d2477095f72ffa27 (diff)
downloadgit-fat-6b01b1a7080e3aad3b6c19e3938d83a3168cfd4e.tar.gz
Merge branch 'jmurty/ensure-init-before-pull' (PR #33)
* jmurty/ensure-init-before-pull: Print fatal error message to stderr Moved requirement for init to `checkout` operation. Fail with a clear error if 'git fat pull' is run on uninitialised repo.
-rwxr-xr-xgit-fat10
-rwxr-xr-xtest.sh16
2 files changed, 25 insertions, 1 deletions
diff --git a/git-fat b/git-fat
index 97315ea..049844f 100755
--- a/git-fat
+++ b/git-fat
@@ -352,6 +352,7 @@ class GitFat(object):
sys.exit(p.returncode)
def checkout(self, show_orphans=False):
'Update any stale files in the present working tree'
+ self.assert_init_done()
for digest, fname in self.orphan_files():
objpath = os.path.join(self.objdir, digest)
if os.access(objpath, os.R_OK):
@@ -414,9 +415,16 @@ 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():
+ sys.stderr.write('fatal: git-fat is not yet configured in this repository.\n')
+ sys.stderr.write('Run "git fat init" to configure.\n')
+ 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..33c6d66 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,19 @@ git fat push
cd ..
git clone fat-test fat-test2
cd fat-test2
+# checkout and pull should fail in repo not yet init'ed for git-fat
+git fat checkout && true
+if [ $? -eq 0 ]
+then
+ echo 'ERROR: "git fat checkout" in uninitialised repo should fail'
+ exit 1
+fi
+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