{"thread":{"id":"2157","subject":"[PATCH] cg-fetch will now retrieve commits related to tags if missing.","startedAt":"2005-10-20T00:55:45Z","lastAt":"2005-10-20T05:23:30Z","messageCount":7,"participants":["Martin Langhoff","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"10323","messageId":"1129769745158-git-send-email-martin@catalyst.net.nz","threadId":"2157","inReplyTo":null,"subject":"[PATCH] cg-fetch will now retrieve commits related to tags if missing.","fromName":"Martin Langhoff","fromEmail":"martin@catalyst.net.nz","sentAt":"2005-10-20T00:55:45Z","receivedAt":"2005-10-20T00:55:45Z","isPatch":true,"sender":{"key":"martin@laptop.org","avatar":null},"body":"Signed-off-by: Martin Langhoff <martin@catalyst.net.nz>\n\n\n---\n\n cg-fetch |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\napplies-to: 38ed7981343a8e2bb734d64e019186a8a482dbef\n48cb643964910a058881307513cb63aeee28a1de\ndiff --git a/cg-fetch b/cg-fetch\nindex 7694584..d4650e5 100755\n--- a/cg-fetch\n+++ b/cg-fetch\n@@ -417,7 +417,8 @@ $get -i -s -u -d \"$uri/refs/tags\" \"$_git\n \tfor tag in *; do\n \t\t[ \"$tag\" = \"*\" ] && break\n \t\ttagid=$(cat $tag)\n-\t\tGIT_DIR=../.. git-cat-file -t \"$tagid\" >/dev/null 2>&1 && continue\n+\t\tGIT_DIR=../.. [ \"`git-cat-file -t $tagid 2>/dev/null`\" = \"commit\" ] && continue\n+\t\tGIT_DIR=../.. git-cat-file commit `git-rev-parse $tag^{commit}  2>/dev/null` 2>&1 >> /dev/null && continue\n \t\techo -n \"Missing object of tag $tag... \"\n \t\tif [ \"$fetch\" != \"fetch_rsync\" ] && GIT_DIR=../.. $fetch \"$tagid\" \"$uri\" 2>/dev/null >&2; then\n \t\t\techo \"retrieved\"\n---\n0.99.8.GIT\n"},{"id":"10327","messageId":"7voe5lvv1q.fsf@assigned-by-dhcp.cox.net","threadId":"2157","inReplyTo":"1129769745158-git-send-email-martin@catalyst.net.nz","subject":"Re: [PATCH] cg-fetch will now retrieve commits related to tags if missing.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-10-20T01:25:37Z","receivedAt":"2005-10-20T01:25:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Langhoff <martin@catalyst.net.nz> writes:\n\n> diff --git a/cg-fetch b/cg-fetch\n> index 7694584..d4650e5 100755\n> --- a/cg-fetch\n> +++ b/cg-fetch\n> @@ -417,7 +417,8 @@ $get -i -s -u -d \"$uri/refs/tags\" \"$_git\n>  \tfor tag in *; do\n>  \t\t[ \"$tag\" = \"*\" ] && break\n>  \t\ttagid=$(cat $tag)\n\nYou just reported this $tag needs quoting ;-).\n\n> +\t\tGIT_DIR=../.. [ \"`git-cat-file -t $tagid 2>/dev/null`\" = \"commit\" ] && continue\n> +\t\tGIT_DIR=../.. git-cat-file commit `git-rev-parse $tag^{commit}  2>/dev/null` 2>&1 >> /dev/null && continue\n\nYou are saying:\n\tif \"$tagid\" is already commit then continue;\n        if \"$tagid\" dereferences to a commit and if you have it\n\tthen continue\n\nIf that is the case, then this might be more efficient.\n\n\tGIT_DIR=../.. git-rev-parse --verify \"$tagid^0\" >/dev/null 2>&1 && continue\n\nYou can say ^{commit} instead of ^0 if you like that newer\nstyle, of course.\n"},{"id":"10334","messageId":"46a038f90510192115x21ed7e96l6d85ce233e66a5f2@mail.gmail.com","threadId":"2157","inReplyTo":"7voe5lvv1q.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] cg-fetch will now retrieve commits related to tags if missing.","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2005-10-20T04:15:26Z","receivedAt":"2005-10-20T04:15:26Z","isPatch":true,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On 10/20/05, Junio C Hamano <junkio@cox.net> wrote:\n> You just reported this $tag needs quoting ;-).\n\nI thought I had seen a post from you to Petr, mentioning that he had\njust fixed it. I didn't see any fix when I updated, but I thought it\nmay have been due to mirroring issues. In any case, it obviously needs\nquoting.\n\n> > +             GIT_DIR=../.. [ \"`git-cat-file -t $tagid 2>/dev/null`\" = \"commit\" ] && continue\n> > +             GIT_DIR=../.. git-cat-file commit `git-rev-parse $tag^{commit}  2>/dev/null` 2>&1 >> /dev/null && continue\n>\n> You are saying:\n>         if \"$tagid\" is already commit then continue;\n>         if \"$tagid\" dereferences to a commit and if you have it\n>         then continue\n>\n> If that is the case, then this might be more efficient.\n>\n>         GIT_DIR=../.. git-rev-parse --verify \"$tagid^0\" >/dev/null 2>&1 && continue\n>\n> You can say ^{commit} instead of ^0 if you like that newer\n> style, of course.\n\nI tried, and failed to get it to work 100% so I reverted to the double\ncheck you've seen. Must have been PEBKAC for now it works correctly --\npossibly related to the unquoted tagnames.\n\nOk -- too many problems with that patch. Let's try it again...\n\n\nmartin\n"},{"id":"10335","messageId":"46a038f90510192118s31c52fe7m73d88a9779653f4c@mail.gmail.com","threadId":"2157","inReplyTo":"7voe5lvv1q.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] cg-fetch will now retrieve commits related to tags if missing.","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2005-10-20T04:18:51Z","receivedAt":"2005-10-20T04:18:51Z","isPatch":true,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On 10/20/05, Junio C Hamano <junkio@cox.net> wrote:\n\n> You are saying:\n>         if \"$tagid\" is already commit then continue;\n>         if \"$tagid\" dereferences to a commit and if you have it\n>         then continue\n>\n> If that is the case, then this might be more efficient.\n>\n>         GIT_DIR=../.. git-rev-parse --verify \"$tagid^0\" >/dev/null 2>&1 && continue\n\nNote however that git-rev-parse is lazy and won't check that the\ncommit is there. I have to call git-cat-file and check whether it\nsucceeds to know if we have the object.\n\ncheers,\n\n\nmartin\n"},{"id":"10338","messageId":"7virvsu79c.fsf@assigned-by-dhcp.cox.net","threadId":"2157","inReplyTo":"46a038f90510192118s31c52fe7m73d88a9779653f4c@mail.gmail.com","subject":"Re: [PATCH] cg-fetch will now retrieve commits related to tags if missing.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-10-20T04:44:47Z","receivedAt":"2005-10-20T04:44:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Langhoff <martin.langhoff@gmail.com> writes:\n\n>>         GIT_DIR=../.. git-rev-parse --verify \"$tagid^0\" >/dev/null 2>&1 && continue\n>\n> Note however that git-rev-parse is lazy and won't check that the\n> commit is there. I have to call git-cat-file and check whether it\n> succeeds to know if we have the object.\n\nAre you sure?\n\nWhat \"rev^0\" does is:\n\n    1. parse \"rev\"; make sure it can deref to commit and read\n       it (otherwise give up and say the whole thing is not an\n       SHA1 expression);\n\n    2. grab the nth parent SHA1.  If N>0, it is lazy and does\n       not check if the parent object exists, but still 0th\n       parent is the commit object itself and if we came this\n       far you know that commit is available already.\n\nTogether with --verify, it barfs if the above does not say \"rev^0\"\nis a valid SHA1 expression.  So this should work without\ncat-file.  No?\n\nBTW, I just got a SEGV while pulling Cogito repository over\ngit-fetch-pack after interrupting rsync transfer (I wanted to\nswitch to git transfer).  I am running with Johaness patch from\ntoday so the cause may be different from yours, but now I have\nsomething to look at, which is better than before.\n\nFetching with rsync (and interrupting in the middle) is a good\nway to simulate a broken repository ;-).\n"},{"id":"10339","messageId":"46a038f90510192159h25aad025kf377e3e33b5d30d@mail.gmail.com","threadId":"2157","inReplyTo":"7virvsu79c.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] cg-fetch will now retrieve commits related to tags if missing.","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2005-10-20T04:59:50Z","receivedAt":"2005-10-20T04:59:50Z","isPatch":true,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On 10/20/05, Junio C Hamano <junkio@cox.net> wrote:\n> Martin Langhoff <martin.langhoff@gmail.com> writes:\n>\n> >>         GIT_DIR=../.. git-rev-parse --verify \"$tagid^0\" >/dev/null 2>&1 && continue\n> >\n> > Note however that git-rev-parse is lazy and won't check that the\n> > commit is there. I have to call git-cat-file and check whether it\n> > succeeds to know if we have the object.\n>\n> Are you sure?\n>\n> What \"rev^0\" does is:\n\nOk -- I was using ^{commit} which _is_ lazy, but you are right, ^0 isn't lazy.\n\n> BTW, I just got a SEGV while pulling Cogito repository over\n> git-fetch-pack after interrupting rsync transfer (I wanted to\n> switch to git transfer).  I am running with Johaness patch from\n> today so the cause may be different from yours, but now I have\n> something to look at, which is better than before.\n>\n> Fetching with rsync (and interrupting in the middle) is a good\n> way to simulate a broken repository ;-).\n\nCool. That's something for you to play with I guess, to tell you the\ntruth, I'm not useful with gdb ;)\n\nmartin\n"},{"id":"10342","messageId":"7v3bmwu5gt.fsf@assigned-by-dhcp.cox.net","threadId":"2157","inReplyTo":"46a038f90510192159h25aad025kf377e3e33b5d30d@mail.gmail.com","subject":"Re: [PATCH] cg-fetch will now retrieve commits related to tags if missing.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-10-20T05:23:30Z","receivedAt":"2005-10-20T05:23:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Langhoff <martin.langhoff@gmail.com> writes:\n\n> Ok -- I was using ^{commit} which _is_ lazy, but you are\n> right, ^0 isn't lazy.\n\nAh, my mistake.  We would need something like this.\n\n---\n\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 75c688e..cc320d3 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -323,6 +323,8 @@ static int peel_onion(const char *name, \n \t\treturn -1;\n \tif (!type_string) {\n \t\to = deref_tag(o);\n+\t\tif (!o || (!o->parsed && !parse_object(o->sha1)))\n+\t\t\treturn -1;\n \t\tmemcpy(sha1, o->sha1, 20);\n \t}\n \telse {\n@@ -332,7 +334,7 @@ static int peel_onion(const char *name, \n \t\t */\n \n \t\twhile (1) {\n-\t\t\tif (!o)\n+\t\t\tif (!o || (!o->parsed && !parse_object(o->sha1)))\n \t\t\t\treturn -1;\n \t\t\tif (o->type == type_string) {\n \t\t\t\tmemcpy(sha1, o->sha1, 20);\n"}]}