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

Re: [PATCH] Teach git push .git/branches shorthand

From
Junio C Hamano <junkio@cox.net>
Date
Aug 9, 2005, 02:48 UTC
Message-ID
<7vd5onzuza.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.63.0508081106580.26210@wgmdd8.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> I'd prefer $GIT_DIR/remotes/. And I propose another extension: Since the 
> files stored therein right now contain only one <remote> string, it should 
> be possible to add the default head(s) to the file.
That makes sense.  Currently my arrangement is:
    $ cd .git/branches && grep . public-*
    public-master:http://www.kernel.org/pub/scm/git/git.git/
    public-pu:http://www.kernel.org/pub/scm/git/git.git/#pu
    public-rc:http://www.kernel.org/pub/scm/git/git.git/#rc

and in order to get the references on the public server to make sure people are seeing what I want them to see, I say:

    $ for h in master pu rc
      do
        echo $h
        git fetch public-$h
        git-rev-parse $h public-$h
      done
Instead, I should be able to say:
    $ cat .git/remotes/public
    http://www.kernel.org/pub/scm/git/git.git/#pu:public-pu,rc:public-rc
to mean that the following two are equivalent:

$ git fetch public $ git fetch public pu:public-pu rc:public-rc

that is, fetch pu there and store it in refs/heads/public-pu (same for rc). When I want to fetch only pu from there:

    $ git fetch public pu:public-pu
or even
    $ git fetch public pu

should work. If I happen to want to fetch pu one-shot but not want to update my local refs/heads/public-pu, then I should be able to say

    $ git fetch public pu:

Another thing I need to worry about is that I would want to use this remotes information for pushing as well, but probably the reference mappings are different when fetching and pushing.

With something like this:
    $ cat .git/remotes/ko
    kernel.org:/pub/scm/git/git.git/#master:ko-master,pu:ko-pu,rc:ko-rc
    $ git fetch ko rc

I would fetch the remote ref "rc" and store it in refs/heads/ko-rc, which is fine, but after that I would do my work in the local repository, merge things up and update my local "rc" (not ko-rc, which to me is a "reference only" branch), and eventually when pushing I would want to store my "rc" (again not ko-rc) in "rc" over there.

This means the reference mapping in these two shorthand notations should be flexible enough to allow me to do:

    $ git fetch ko rc ;# get rc from there store it under ko-rc here
which is equivalent to 
    $ git fetch ko rc:ko-rc
and
    $ git push ko rc  ;# push rc here to rc there
which is equivalent to 
$ git push ko rc:rc

Maybe its time to do a file format that is a bit more flexible. For example:

    $ cat .git/remotes/ko
    URL: kernel.org:/pub/scm/git/git.git/
    Fetch-Reference: master:ko-master pu:ko-pu rc:ko-rc
    Push-Reference: master pu rc

Note that I do not mean "Push-Reference" can not do the rename. I could have written "master:master" but I did not because I do _not_ want renaming push in this example.

People who do not need different mappings for fetch/push should be able to say:

    $ cat .git/remotes/public
    URL: http://www.kernel.org/pub/scm/git/git.git/
    Reference: pu:public-pu rc:public-rc

Another thing I should mention is that Fetch-Reference mapping is <remote>:<local>, while Push-Reference is <local>:<remote>. This is only because I feel always using <src>:<dst> is easy to remember, is the way it works for the command line refs for git push already, and is the way I plan to enhance fetch to grok.

My current thinking is Reference should take <remote>:<local> because fetching/pulling is probably more common than pushing, but I need to think a bit more about it.

Johannes, sorry for doing my design work in an e-mail buffer to you ;-).

Previous: Darrin Thompson
Message 11 of 11 in “Teach git push .git/branches shorthand”
  1. Teach git push .git/branches shorthandJunio C Hamano, Aug 8, 2005
  2. Johannes SchindelinAug 8, 2005
  3. Josef WeidendorferAug 8, 2005
  4. Johannes SchindelinAug 8, 2005
  5. Josef WeidendorferAug 8, 2005
  6. Johannes SchindelinAug 8, 2005
  7. Josef WeidendorferAug 8, 2005
  8. Junio C HamanoAug 9, 2005
  9. Matthias UrlichsAug 11, 2005
  10. Darrin ThompsonAug 9, 2005
  11. Junio C HamanoAug 9, 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.