git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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;
Previous: Salikh ZakirovNext: Junio C Hamano
Message 12 of 17 in “Make git-clone --use-separate-remote the default”
  1. Make git-clone --use-separate-remote the defaultPetr Baudis, Nov 23, 2006
  2. Junio C HamanoNov 23, 2006
  3. Andy WhitcroftNov 23, 2006
  4. Petr BaudisNov 23, 2006
  5. J. Bruce FieldsNov 23, 2006
  6. Junio C HamanoNov 24, 2006
  7. Junio C HamanoNov 24, 2006
  8. Junio C HamanoNov 24, 2006
  9. Salikh ZakirovNov 24, 2006
  10. Junio C HamanoNov 24, 2006
  11. Salikh ZakirovNov 24, 2006
  12. Salikh ZakirovNov 24, 2006
  13. Junio C HamanoNov 25, 2006
  14. Sergey VlasovNov 24, 2006
  15. Junio C HamanoNov 24, 2006
  16. Jakub NarebskiNov 24, 2006
  17. Salikh ZakirovNov 24, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.