# git-push and $GIT_DIR/branches

3 messages from 2008-11-07 to 2008-11-07. Participants: Martin Koegler, Junio C Hamano.
Thread: https://gitlist.dev/t/16206

## Martin Koegler, 2008-11-07 08:26

Subject: git-push and $GIT_DIR/branches
Message-ID: <20081107082629.GA27158@auto.tuwien.ac.at>
URL: https://gitlist.dev/e/20081107082629.GA27158%40auto.tuwien.ac.at

```
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, 2008-11-07 20:44

Subject: Re: git-push and $GIT_DIR/branches
Message-ID: <20081107204451.GA10394@auto.tuwien.ac.at>
URL: https://gitlist.dev/e/20081107204451.GA10394%40auto.tuwien.ac.at
In-Reply-To: <7vljvvh61y.fsf@gitster.siamese.dyndns.org>

```
On Fri, Nov 07, 2008 at 08:08:57AM -0800, Junio C Hamano wrote:
> 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, 2008-11-07 22:27

Subject: Re: git-push and $GIT_DIR/branches
Message-ID: <7vfxm3f9z8.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vfxm3f9z8.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <20081107204451.GA10394@auto.tuwien.ac.at>

```
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.

```
