summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-06-05 06:11:38 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-05 21:18:00 (GMT)
commita48e1d67e167507091f25dc00e2bd6c280fa538e (patch)
treefe68efbb7cf2f5c5c2d4ba448db7f50274fa3d43 /t
parentf78c79c5d4486f47dcd69ea7fef93e84051d4496 (diff)
downloadgit-a48e1d67e167507091f25dc00e2bd6c280fa538e.zip
git-a48e1d67e167507091f25dc00e2bd6c280fa538e.tar.gz
git-a48e1d67e167507091f25dc00e2bd6c280fa538e.tar.bz2
[PATCH] pull: gracefully recover from delta retrieval failure.
This addresses a concern raised by Jason McMullan in the mailing list discussion. After retrieving and storing a potentially deltified object, pull logic tries to check and fulfil its delta dependency. When the pull procedure is killed at this point, however, there was no easy way to recover by re-running pull, since next run would have found that we already have that deltified object and happily reported success, without really checking its delta dependency is satisfied. This patch introduces --recover option to git-*-pull family which causes them to re-validate dependency of deltified objects we are fetching. A new test t5100-delta-pull.sh covers such a failure mode. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 't')
-rw-r--r--t/t5100-delta-pull.sh79
1 files changed, 79 insertions, 0 deletions
diff --git a/t/t5100-delta-pull.sh b/t/t5100-delta-pull.sh
new file mode 100644
index 0000000..8693c5c
--- /dev/null
+++ b/t/t5100-delta-pull.sh
@@ -0,0 +1,79 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+test_description='Test pulling deltified objects
+
+'
+. ./test-lib.sh
+
+locate_obj='s|\(..\)|.git/objects/\1/|'
+
+test_expect_success \
+ setup \
+ 'cat ../README >a &&
+ git-update-cache --add a &&
+ a0=`git-ls-files --stage |
+ sed -e '\''s/^[0-7]* \([0-9a-f]*\) .*/\1/'\''` &&
+
+ sed -e 's/test/TEST/g' ../README >a &&
+ git-update-cache a &&
+ a1=`git-ls-files --stage |
+ sed -e '\''s/^[0-7]* \([0-9a-f]*\) .*/\1/'\''` &&
+ tree=`git-write-tree` &&
+ commit=`git-commit-tree $tree </dev/null` &&
+ a0f=`echo "$a0" | sed -e "$locate_obj"` &&
+ a1f=`echo "$a1" | sed -e "$locate_obj"` &&
+ echo commit $commit &&
+ echo a0 $a0 &&
+ echo a1 $a1 &&
+ ls -l $a0f $a1f &&
+ echo $commit >.git/HEAD &&
+ git-mkdelta -v $a0 $a1 &&
+ ls -l $a0f $a1f'
+
+# Now commit has a tree that records delitified "a" whose SHA1 is a1.
+# Create a new repo and pull this commit into it.
+
+test_expect_success \
+ 'setup and cd into new repo' \
+ 'mkdir dest && cd dest && rm -fr .git && git-init-db'
+
+test_expect_success \
+ 'pull from deltified repo into a new repo without -d' \
+ 'rm -fr .git a && git-init-db &&
+ git-local-pull -v -a $commit ../.git/ &&
+ git-cat-file blob $a1 >a &&
+ diff -u a ../a'
+
+test_expect_failure \
+ 'pull from deltified repo into a new repo with -d' \
+ 'rm -fr .git a && git-init-db &&
+ git-local-pull -v -a -d $commit ../.git/ &&
+ git-cat-file blob $a1 >a &&
+ diff -u a ../a'
+
+test_expect_failure \
+ 'pull from deltified repo after delta failure without --recover' \
+ 'rm -f a &&
+ git-local-pull -v -a $commit ../.git/ &&
+ git-cat-file blob $a1 >a &&
+ diff -u a ../a'
+
+test_expect_success \
+ 'pull from deltified repo after delta failure with --recover' \
+ 'rm -f a &&
+ git-local-pull -v -a --recover $commit ../.git/ &&
+ git-cat-file blob $a1 >a &&
+ diff -u a ../a'
+
+test_expect_success \
+ 'missing-tree or missing-blob should be re-fetched without --recover' \
+ 'rm -f a $a0f $a1f &&
+ git-local-pull -v -a $commit ../.git/ &&
+ git-cat-file blob $a1 >a &&
+ diff -u a ../a'
+
+test_done
+