threads / discuss / 16206

git-push and $GIT_DIR/branches

Subject: git-push and $GIT_DIR/branches

## tl;dr

3 messages between Nov 7, 2008 and Nov 7, 2008.

replies: 2people: 2as markdown or json

Martin Koegler· Nov 7, 2008, 08:26 UTC · lore

I think, that the git-push behaviour is a bit unlogical in conjunction with $GIT_DIR/branches.

If $GIT_DIR/branches/name1 contains "<repository>#name2":
- git-fetch name1
  will fetch refs/heads/name2 from <repository> and store it in refs/heads/name1
- git-push name1
  will push refs/heads/master to refs/heads/master in <repository>

I would expect, that git-push would somehow honour #name2. As far as I remember, cg-push name1 would have pushed HEAD to refs/heads/name2 in <repository>.

In remote.c, function read_branches_file the following code
would implement a similar behaviour:
        strbuf_init(&push, 0);
        strbuf_addstr(&push, "HEAD");
        if (frag) {
                strbuf_addf(&push, ":refs/heads/%s", frag);
        } else
                strbuf_addstr(&push, ":refs/heads/master");
        add_push_refspec(remote, strbuf_detach(&push, 0));
Options about this?
mfg Martin Kögler
Martin Koegler· Nov 7, 2008, 20:44 UTC · lore

Re: git-push and $GIT_DIR/branches

On Fri, Nov 07, 2008 at 08:08:57AM -0800, Junio C Hamano wrote:
Show 8 quoted lines
> mkoegler@auto.tuwien.ac.at (Martin Koegler) writes:
> 
> > I think, that the git-push behaviour is a bit unlogical in conjunction
> > with $GIT_DIR/branches.
> 
> That is because it is illogical to use $GIT_DIR/branches in conjunction
> with git; the former is a backward compatibility wart with Cogito which is
> now dead.

I'm aware, that $GIT_DIR/branches origins from Cogito and are not recommended. But eg. Documentation/urls-remotes.txt does not reflect this.

I asume, that you [and probably many other] are not very interrested in this feature. But would you accept a patch changing the push refspec to HEAD:refs/heads/<head>?

mfg Martin Kögler
Junio C Hamano· Nov 7, 2008, 22:27 UTC · re: Martin Koegler · lore

Re: git-push and $GIT_DIR/branches

mkoegler@auto.tuwien.ac.at (Martin Koegler) writes:
> I asume, that you [and probably many other] are not very interrested
> in this feature. But would you accept a patch changing the push
> refspec to HEAD:refs/heads/<head>?

I believe "git-push foo" with .git/branches/foo has worked the way it does now from day one, so the above change you suggest breaks peoples' expectations and documented behaviour, _if_ people are using "branches" with git-push. It definitely is a no-go to just change the behaviour without warning and deprecation period, but with a careful transition plan, I personally do not think there is a fundamental reason not to improve it (others may disagree).

I do not know what Cogito did when you told it to push with such a configuration, though. Its "branches" had quite different semantics from the concept of "remote" in git.

← back to recent threads