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

Re: error pushing stash ?

From
Jeff King <peff@peff.net>
Date
Oct 28, 2008, 21:17 UTC
Message-ID
<20081028211755.GA8074@sigill.intra.peff.net>
In-Reply-To
<20081007004051.GA18889@spearce.org>
On Mon, Oct 06, 2008 at 05:40:51PM -0700, Shawn O. Pearce wrote:
Show 6 quoted lines
> >  ! [remote rejected] refs/stash -> refs/stash (funny refname)
> > error: failed to push some refs to '/users/dbryson/backup/janus.git/'
> 
> refs/stash is a funny refname because it contains only 1 '/'.
> Normally a valid ref has at least 2 '/', e.g. refs/heads/8654 or
> refs/tags/v1.0.

Since no version of receive-pack accepts these "funny refs", perhaps we should mirror the check when considering the list of refs to send. IOW, don't even make them eligible for matching or mirroring. Patch is below.

Show 5 quoted lines
> Naming the stash refs/stash was perhaps funny in the first place
> since it cannot be moved about on the transport protocol, but then
> again the bulk of the stash data is actually in the reflog for the
> stash (and not the stash ref itself) so there is basically no point
> in pushing or fetching a stash directly.

I agree there is not much point in pushing it, since the useful bit is in the reflog. So perhaps a "funny" refname is a good place to put it, since it easily tells us that it is not a useful thing to push.

---
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index bbf6e0a..298bd71 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -140,7 +140,13 @@ static struct ref *remote_refs, **remote_tail;
 static int one_local_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
 {
 	struct ref *ref;
-	int len = strlen(refname) + 1;
+	int len;
+
+	/* we already know it starts with refs/ to get here */
+	if (check_ref_format(refname + 5))
+		return 0;
+
+	len = strlen(refname) + 1;
 	ref = xcalloc(1, sizeof(*ref) + len);
 	hashcpy(ref->new_sha1, sha1);
 	memcpy(ref->name, refname, len);
Previous: Shawn O. PearceNext: Jeff King
Message 3 of 8 in “error pushing stash ?”
  1. David BrysonOct 7, 2008
  2. Shawn O. PearceOct 7, 2008
  3. Jeff KingOct 28, 2008
  4. Jeff KingOct 28, 2008
  5. Added test case for mirror to not push stash refsdavid@statichacks.org, Nov 6, 2008
  6. Sverre RabbelierNov 6, 2008
  7. Junio C HamanoNov 6, 2008
  8. Added test case for mirror to not push stash refsdavid@statichacks.org, Nov 6, 2008

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.