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

[PATCH] send-pack: allow generic sha1 expression on the source side.

From
Junio C Hamano <junkio@cox.net>
Date
Aug 6, 2005, 17:24 UTC
Message-ID
<7vek979dws.fsf@assigned-by-dhcp.cox.net>

As promised earlier. I will shortly push this out with another send-pack fix, initially in the proposed updates branch.

------------ This extends the source side semantics to match what Linus suggested.

An example:
    $ git-send-pack kernel.org:/pub/scm/git/git.git pu^^:master pu
    would allow me to push the current pu into pu, and the
    commit two commits before it into master, on my public
    repository.
The revised rule for updating remote heads is as follows.
 $ git-send-pack [--all] <remote> [<ref>...]
 - When no <ref> is specified:
   - with '--all', it is the same as specifying the full refs/*
     path for all local refs;
   - without '--all', it is the same as specifying the full
     refs/* path for refs that exist on both ends;
 - When one or more <ref>s are specified:
   - a single token <ref> (i.e. no colon) must be a pattern that
     tail-matches refs/* path for an existing local ref.  It is
     an error for the pattern to match no local ref, or more
     than one local refs.  The matching ref is pushed to the
     remote end under the same name.
   - <src>:<dst> can have different cases.  <src> is first tried
     as the tail-matching pattern for refs/* path.
     - If more than one matches are found, it is an error.
     - If one match is found, <dst> must either match no remote
       ref and start with "refs/", or match exactly one remote
       ref.  That remote ref is updated with the sha1 value
       obtained from the <src> sha1.
     - If no match is found, it is given to get_extended_sha1();
       it is an error if get_extended_sha1() does not find an
       object name.  If it succeeds, <dst> must either match
       no remote ref and start with "refs/" or match exactly
       one remote ref.  That remote ref is updated with the sha1
       value.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 connect.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
15e02b372ddebd2aac829707786462798f91d509
diff --git a/connect.c b/connect.c
--- a/connect.c
+++ b/connect.c
@@ -133,6 +133,20 @@ static void link_dst_tail(struct ref *re
 	**tail = NULL;
 }
 
+static struct ref *try_explicit_object_name(const char *name)
+{
+	unsigned char sha1[20];
+	struct ref *ref;
+	int len;
+	if (get_sha1(name, sha1))
+		return NULL;
+	len = strlen(name) + 1;
+	ref = xcalloc(1, sizeof(*ref) + len);
+	memcpy(ref->name, name, len);
+	memcpy(ref->new_sha1, sha1, 20);
+	return ref;
+}
+
 static int match_explicit_refs(struct ref *src, struct ref *dst,
 			       struct ref ***dst_tail, struct refspec *rs)
 {
@@ -145,6 +159,12 @@ static int match_explicit_refs(struct re
 		case 1:
 			break;
 		case 0:
+			/* The source could be in the get_sha1() format
+			 * not a reference name.
+			 */
+			matched_src = try_explicit_object_name(rs[i].src);
+			if (matched_src)
+				break;
 			errs = 1;
 			error("src refspec %s does not match any.");
 			break;
Message 1 of 1 in “send-pack: allow generic sha1 expression on the source side.”
  1. send-pack: allow generic sha1 expression on the source side.Junio C Hamano, Aug 6, 2005

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.