SYNOPSIS
--------
-'git-http-pull' [-c] [-t] [-a] [-v] [-d] commit-id url
+'git-http-pull' [-c] [-t] [-a] [-v] [-d] [--recover] commit-id url
DESCRIPTION
-----------
Do not check for delta base objects (use this option
only when you know the remote repository is not
deltified).
+--recover::
+ Check dependency of deltified object more carefully than
+ usual, to recover after earlier pull that was interrupted.
-v::
Report what is downloaded.
SYNOPSIS
--------
-'git-local-pull' [-c] [-t] [-a] [-l] [-s] [-n] [-v] [-d] commit-id path
+'git-local-pull' [-c] [-t] [-a] [-l] [-s] [-n] [-v] [-d] [--recover] commit-id path
DESCRIPTION
-----------
Do not check for delta base objects (use this option
only when you know the remote repository is not
deltified).
+--recover::
+ Check dependency of deltified object more carefully than
+ usual, to recover after earlier pull that was interrupted.
-v::
Report what is downloaded.
SYNOPSIS
--------
-'git-rpull' [-c] [-t] [-a] [-d] [-v] commit-id url
+'git-rpull' [-c] [-t] [-a] [-d] [-v] [--recover] commit-id url
DESCRIPTION
-----------
Do not check for delta base objects (use this option
only when you know the remote repository is not
deltified).
+--recover::
+ Check dependency of deltified object more carefully than
+ usual, to recover after earlier pull that was interrupted.
-v::
Report what is downloaded.
get_history = 1;
} else if (argv[arg][1] == 'd') {
get_delta = 0;
+ } else if (!strcmp(argv[arg], "--recover")) {
+ get_delta = 2;
} else if (argv[arg][1] == 'a') {
get_all = 1;
get_tree = 1;
arg++;
}
if (argc < arg + 2) {
- usage("git-http-pull [-c] [-t] [-a] [-d] [-v] commit-id url");
+ usage("git-http-pull [-c] [-t] [-a] [-d] [-v] [--recover] commit-id url");
return 1;
}
commit_id = argv[arg];
}
static const char *local_pull_usage =
-"git-local-pull [-c] [-t] [-a] [-l] [-s] [-n] [-v] [-d] commit-id path";
+"git-local-pull [-c] [-t] [-a] [-l] [-s] [-n] [-v] [-d] [--recover] commit-id path";
/*
* By default we only use file copy.
get_history = 1;
else if (argv[arg][1] == 'd')
get_delta = 0;
+ else if (!strcmp(argv[arg], "--recover"))
+ get_delta = 2;
else if (argv[arg][1] == 'a') {
get_all = 1;
get_tree = 1;
int get_tree = 0;
int get_history = 0;
+/* 1 means "get delta", 2 means "really check delta harder */
int get_delta = 1;
int get_all = 0;
int get_verbosely = 0;
static int make_sure_we_have_it(const char *what, unsigned char *sha1)
{
- int status;
- if (has_sha1_file(sha1))
+ int status = 0;
+
+ if (!has_sha1_file(sha1)) {
+ status = fetch(sha1);
+ if (status && what)
+ report_missing(what, sha1);
+ }
+ else if (get_delta < 2)
return 0;
- status = fetch(sha1);
- if (status && what)
- report_missing(what, sha1);
+
if (get_delta) {
char delta_sha1[20];
status = sha1_delta_base(sha1, delta_sha1);
/** Set to fetch the trees in the commit history. **/
extern int get_all;
-/* Set to zero to skip the check for delta object base. */
+/* Set to zero to skip the check for delta object base;
+ * set to two to check delta dependency even for objects we already have.
+ */
extern int get_delta;
/* Set to be verbose */
get_history = 1;
} else if (argv[arg][1] == 'd') {
get_delta = 0;
+ } else if (!strcmp(argv[arg], "--recover")) {
+ get_delta = 2;
} else if (argv[arg][1] == 'a') {
get_all = 1;
get_tree = 1;
arg++;
}
if (argc < arg + 2) {
- usage("git-rpull [-c] [-t] [-a] [-v] [-d] commit-id url");
+ usage("git-rpull [-c] [-t] [-a] [-v] [-d] [--recover] commit-id url");
return 1;
}
commit_id = argv[arg];
--- /dev/null
+#!/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
+