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

Re: How can git pull be up-to-date and git push fail?

From
Jeff King <peff@peff.net>
Date
Apr 6, 2007, 02:52 UTC
Message-ID
<20070406025255.GA31909@coredump.intra.peff.net>
In-Reply-To
<7vodm2o6yl.fsf@assigned-by-dhcp.cox.net>
On Thu, Apr 05, 2007 at 02:18:58PM -0700, Junio C Hamano wrote:
> IIRC "git push" without explicit refspecs push the matching
> refs, but I am a bit under the weather and feverish, so don't
> take my word literally but look at git-push manual page please.

Ah, yes you're right. It really doesn't make sense to push refs/remotes/* in most cases, since they're just tracking branches, and if the destination _does_ have them, then it is unlikely to be in sync with you (leading to Bill's problem). OTOH, you might want to be able to push them explicitly if you are doing a strict mirror of a repository.

The patch below turns off refs/remotes/ sending for "git-push" and "git-push --all", but still allows "git-push origin remotes/origin/master". I'm not sure about the semantics; maybe --all should imply even remotes?

It also only impacts send-pack; I suspect pushing over dumb transports now has different behavior, but I haven't looked. My testing was light, so I may have totally broken something else, too. Input from more clueful people would be helpful.

Does this seem like a sane direction to take? It just seems silly to be pushing refs/remotes, which 99% of the time should be a purely local thing.

-Peff
---
diff --git a/send-pack.c b/send-pack.c
index d5b5162..39829e3 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -131,6 +131,8 @@ static int one_local_ref(const char *refname, const unsigned char *sha1, int fla
 {
 	struct ref *ref;
 	int len = strlen(refname) + 1;
+	if (!prefixcmp(refname, "refs/remotes/"))
+		return 0;
 	ref = xcalloc(1, sizeof(*ref) + len);
 	hashcpy(ref->new_sha1, sha1);
 	memcpy(ref->name, refname, len);
Previous: Junio C HamanoNext: Junio C Hamano
Message 9 of 13 in “How can git pull be up-to-date and git push fail?”
  1. Bill LearApr 5, 2007
  2. Jeff KingApr 5, 2007
  3. Bill LearApr 5, 2007
  4. Bill LearApr 5, 2007
  5. Jeff KingApr 5, 2007
  6. Bill LearApr 5, 2007
  7. Jeff KingApr 7, 2007
  8. Junio C HamanoApr 5, 2007
  9. Jeff KingApr 6, 2007
  10. Junio C HamanoApr 6, 2007
  11. Jeff KingApr 7, 2007
  12. Junio C HamanoApr 7, 2007
  13. Jeff KingApr 7, 2007

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.