Re: [PATCH] Make git-clone --use-separate-remote the default
- From
Salikh Zakirov <salikh@gmail.com>
- Date
- Nov 24, 2006, 23:28 UTC
- Message-ID
- <ek7v61$k89$1@sea.gmane.org>
- In-Reply-To
- <7vslg9axzv.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
Show 12 quoted lines
> The way this command: > > git push $remote $src:$dst > > is handled is: > > (0) send-pack gets ls-remote equivalent from the remote. This > tells us the set of refs the remote has and the value of > each of them. > > (1) $src can be a ref that is resolved locally the usual way. > You could have any valid SHA-1 expression (e.g. HEAD~6).
> (2) $dst is compared with the list of refs that the remote > has, and unique match is found.
I think that remote matching semantics is confusing, and the following change would make understanding easier.
I was understanding the manual incorrectly for a long time until you've explained its true meaning today (thanks!).
As a side effect, making 'git push repo master' unambiguously expanded to 'git push repo refs/heads/master:refs/heads/master' will make the syntax 'git push repo tag v1' unneeded at all, because it would be exactly the same as 'git push repo v1' (expanded to 'git push repo refs/tags/v1:refs/tags/v1').
--- connect.c +++ connect.c
@@ -277,6 +277,16 @@ static int match_explicit_refs(struct re rs[i].src); break; } + if (!strcmp(rs[i].src,rs[i].dst)) { + /* src refspec is the same as dst, + * take the remote refpath exactly the same + * as existing local reference + */ + int len = strlen(matched_src->name) + 1; + matched_dst = xcalloc(1, sizeof(*dst) + len); + memcpy(matched_dst->name, matched_src->name, len); + link_dst_tail(matched_dst, dst_tail); + } else switch (count_refspec_match(rs[i].dst, dst, &matched_dst)) { case 1: break;