Re: [PATCH] cg-fetch will now retrieve commits related to tags if missing.

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] cg-fetch will now retrieve commits related to tags if missing.

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:09

Martin Langhoff [off-list ref] writes:
quoted
        GIT_DIR=../.. git-rev-parse --verify "$tagid^0" >/dev/null 2>&1 && continue
Note however that git-rev-parse is lazy and won't check that the
commit is there. I have to call git-cat-file and check whether it
succeeds to know if we have the object.
Are you sure?

What "rev^0" does is:

    1. parse "rev"; make sure it can deref to commit and read
       it (otherwise give up and say the whole thing is not an
       SHA1 expression);

    2. grab the nth parent SHA1.  If N>0, it is lazy and does
       not check if the parent object exists, but still 0th
       parent is the commit object itself and if we came this
       far you know that commit is available already.

Together with --verify, it barfs if the above does not say "rev^0"
is a valid SHA1 expression.  So this should work without
cat-file.  No?

BTW, I just got a SEGV while pulling Cogito repository over
git-fetch-pack after interrupting rsync transfer (I wanted to
switch to git transfer).  I am running with Johaness patch from
today so the cause may be different from yours, but now I have
something to look at, which is better than before.

Fetching with rsync (and interrupting in the middle) is a good
way to simulate a broken repository ;-).

Re: [PATCH] cg-fetch will now retrieve commits related to tags if missing.

From: Martin Langhoff <hidden>
Date: 2016-06-15 22:42:09

On 10/20/05, Junio C Hamano [off-list ref] wrote:
Martin Langhoff [off-list ref] writes:
quoted
quoted
        GIT_DIR=../.. git-rev-parse --verify "$tagid^0" >/dev/null 2>&1 && continue
Note however that git-rev-parse is lazy and won't check that the
commit is there. I have to call git-cat-file and check whether it
succeeds to know if we have the object.
Are you sure?

What "rev^0" does is:
Ok -- I was using ^{commit} which _is_ lazy, but you are right, ^0 isn't lazy.
BTW, I just got a SEGV while pulling Cogito repository over
git-fetch-pack after interrupting rsync transfer (I wanted to
switch to git transfer).  I am running with Johaness patch from
today so the cause may be different from yours, but now I have
something to look at, which is better than before.

Fetching with rsync (and interrupting in the middle) is a good
way to simulate a broken repository ;-).
Cool. That's something for you to play with I guess, to tell you the
truth, I'm not useful with gdb ;)

martin

Re: [PATCH] cg-fetch will now retrieve commits related to tags if missing.

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:09

Martin Langhoff [off-list ref] writes:
Ok -- I was using ^{commit} which _is_ lazy, but you are
right, ^0 isn't lazy.
Ah, my mistake.  We would need something like this.

---
diff --git a/sha1_name.c b/sha1_name.c
index 75c688e..cc320d3 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -323,6 +323,8 @@ static int peel_onion(const char *name, 
 		return -1;
 	if (!type_string) {
 		o = deref_tag(o);
+		if (!o || (!o->parsed && !parse_object(o->sha1)))
+			return -1;
 		memcpy(sha1, o->sha1, 20);
 	}
 	else {
@@ -332,7 +334,7 @@ static int peel_onion(const char *name, 
 		 */
 
 		while (1) {
-			if (!o)
+			if (!o || (!o->parsed && !parse_object(o->sha1)))
 				return -1;
 			if (o->type == type_string) {
 				memcpy(sha1, o->sha1, 20);
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help