{"thread":{"id":"1450","subject":"[PATCH] Teach git push .git/branches shorthand","startedAt":"2005-08-08T06:12:26Z","lastAt":"2005-08-11T16:29:37Z","messageCount":11,"participants":["Junio C Hamano","Johannes Schindelin","Josef Weidendorfer","Darrin Thompson","Matthias Urlichs"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"6924","messageId":"7viryhgdo5.fsf@assigned-by-dhcp.cox.net","threadId":"1450","inReplyTo":null,"subject":"[PATCH] Teach git push .git/branches shorthand","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-08-08T06:12:26Z","receivedAt":"2005-08-08T06:12:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Although it is uncertain if we would keep .git/branches for\nlong, the shorthand stored there can be used for pushing if it\nis host:path/to/git format, so let's make use of it.  This does\nnot use git-parse-remote because that script will be rewritten\nquite a bit for updated pulling.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\nI hear a lot of people mention $GIT_DIR/branches/ is confusing.\nMaybe we should rename it to $GIT_DIR/remote/ directory?\n\n git-push-script |   63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 files changed, 62 insertions(+), 1 deletions(-)\n\nc781a84b5204fb294c9ccc79f8b3baceeb32c061\ndiff --git a/git-push-script b/git-push-script\n--- a/git-push-script\n+++ b/git-push-script\n@@ -1,3 +1,64 @@\n #!/bin/sh\n . git-sh-setup-script || die \"Not a git archive\"\n-git-send-pack \"$@\"\n+\n+# Parse out parameters and then stop at remote, so that we can\n+# translate it using .git/branches information\n+has_all=\n+has_force=\n+has_exec=\n+remote=\n+\n+while case \"$#\" in 0) break ;; esac\n+do\n+\tcase \"$1\" in\n+\t--all)\n+\t\thas_all=--all ;;\n+\t--force)\n+\t\thas_force=--force ;;\n+\t--exec=*)\n+\t\thas_exec=\"$1\" ;;\n+\t-*)\n+\t\tdie \"Unknown parameter $1\" ;;\n+        *)\n+\t\tremote=\"$1\"\n+\t\tshift\n+\t\tset x \"$@\"\n+\t\tshift\n+\t\tbreak ;;\n+\tesac\n+\tshift\n+done\n+\n+case \"$remote\" in\n+*:* | /* | ../* | ./* )\n+\t# An URL, host:/path/to/git, absolute and relative paths.\n+\t;;\n+* )\n+\t# Shorthand\n+\tif expr \"$remote\" : '..*/..*' >/dev/null\n+\tthen\n+\t\t# a short-hand followed by a trailing path\n+\t\tshorthand=$(expr \"$remote\" : '\\([^/]*\\)')\n+\t\tremainder=$(expr \"$remote\" : '[^/]*\\(/.*\\)$')\n+\telse\n+\t\tshorthand=\"$remote\"\n+\t\tremainder=\n+\tfi\n+\tremote=$(sed -e 's/#.*//' \"$GIT_DIR/branches/$remote\") &&\n+\texpr \"$remote\" : '..*:' >/dev/null &&\n+\tremote=\"$remote$remainder\" ||\n+\tdie \"Cannot parse remote $remote\"\n+\t;;\n+esac\n+\n+case \"$remote\" in\n+http://* | https://* | git://* | rsync://* )\n+\tdie \"Cannot push to $remote\" ;;\n+esac\n+\n+set x \"$remote\" \"$@\"; shift\n+test \"$has_all\" && set x \"$has_all\" \"$@\" && shift\n+test \"$has_force\" && set x \"$has_force\" \"$@\" && shift\n+test \"$has_exec\" && set x \"$has_exec\" \"$@\" && shift\n+\n+exec git-send-pack \"$@\"\n"},{"id":"6928","messageId":"Pine.LNX.4.63.0508081106580.26210@wgmdd8.biozentrum.uni-wuerzburg.de","threadId":"1450","inReplyTo":"7viryhgdo5.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Teach git push .git/branches shorthand","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-08-08T09:10:38Z","receivedAt":"2005-08-08T09:10:38Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 7 Aug 2005, Junio C Hamano wrote:\n\n> I hear a lot of people mention $GIT_DIR/branches/ is confusing.\n> Maybe we should rename it to $GIT_DIR/remote/ directory?\n\nI'd prefer $GIT_DIR/remotes/. And I propose another extension: Since the \nfiles stored therein right now contain only one <remote> string, it should \nbe possible to add the default head(s) to the file.\n\nCiao,\nDscho\n"},{"id":"6932","messageId":"200508081141.23242.Josef.Weidendorfer@gmx.de","threadId":"1450","inReplyTo":"Pine.LNX.4.63.0508081106580.26210@wgmdd8.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Teach git push .git/branches shorthand","fromName":"Josef Weidendorfer","fromEmail":"josef.weidendorfer@gmx.de","sentAt":"2005-08-08T09:41:22Z","receivedAt":"2005-08-08T09:41:22Z","isPatch":true,"sender":{"key":"josef.weidendorfer@gmx.de","avatar":null},"body":"On Monday 08 August 2005 11:10, Johannes Schindelin wrote:\n> Hi,\n>\n> On Sun, 7 Aug 2005, Junio C Hamano wrote:\n> > I hear a lot of people mention $GIT_DIR/branches/ is confusing.\n> > Maybe we should rename it to $GIT_DIR/remote/ directory?\n>\n> I'd prefer $GIT_DIR/remotes/.\n\nIMHO, $GIT_DIR/branches/ is really confusing.\nHmmm... in $GIT_DIR/branches/ there are named references to remote (named) \nreferences.\nPerhaps we should call it \"remoterefs/\" instead?\n\nJosef\n"},{"id":"6933","messageId":"Pine.LNX.4.63.0508081154190.32406@wgmdd8.biozentrum.uni-wuerzburg.de","threadId":"1450","inReplyTo":"200508081141.23242.Josef.Weidendorfer@gmx.de","subject":"Re: [PATCH] Teach git push .git/branches shorthand","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-08-08T09:55:46Z","receivedAt":"2005-08-08T09:55:46Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 8 Aug 2005, Josef Weidendorfer wrote:\n\n> IMHO, $GIT_DIR/branches/ is really confusing.\n> Hmmm... in $GIT_DIR/branches/ there are named references to remote (named) \n> references.\n\nNot necessarily. The following is perfectly valid:\n\necho \"rsync://rsync.kernel.org/pub/scm/git/git.git > .git/branches/x\n\nIt does not contain a named reference, just a host.\n\nCiao,\nDscho\n"},{"id":"6935","messageId":"200508081225.59949.Josef.Weidendorfer@gmx.de","threadId":"1450","inReplyTo":"Pine.LNX.4.63.0508081154190.32406@wgmdd8.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Teach git push .git/branches shorthand","fromName":"Josef Weidendorfer","fromEmail":"josef.weidendorfer@gmx.de","sentAt":"2005-08-08T10:25:59Z","receivedAt":"2005-08-08T10:25:59Z","isPatch":true,"sender":{"key":"josef.weidendorfer@gmx.de","avatar":null},"body":"On Monday 08 August 2005 11:55, Johannes Schindelin wrote:\n> Hi,\n>\n> On Mon, 8 Aug 2005, Josef Weidendorfer wrote:\n> > IMHO, $GIT_DIR/branches/ is really confusing.\n> > Hmmm... in $GIT_DIR/branches/ there are named references to remote\n> > (named) references.\n>\n> Not necessarily. The following is perfectly valid:\n>\n> echo \"rsync://rsync.kernel.org/pub/scm/git/git.git > .git/branches/x\n>\n> It does not contain a named reference, just a host.\n\nNot really.\nYour example defaults to the master head. It is perfectly valid (at least \ncogito usage), to have the reference appended as an anchor:\n\necho \"rsync://rsync.kernel.org/pub/scm/git/git.git#pu\" > .git/branches/pu\n\nFor lightweight remote tag, even a SHA1 as anchor should be possible.\n\nJosef\n\n> Ciao,\n> Dscho\n>\n> -\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"6937","messageId":"Pine.LNX.4.63.0508081234300.32668@wgmdd8.biozentrum.uni-wuerzburg.de","threadId":"1450","inReplyTo":"200508081225.59949.Josef.Weidendorfer@gmx.de","subject":"Re: [PATCH] Teach git push .git/branches shorthand","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-08-08T10:36:22Z","receivedAt":"2005-08-08T10:36:22Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 8 Aug 2005, Josef Weidendorfer wrote:\n\n> Your example defaults to the master head.\n\nMy point being that I still can say\n\n\tgit pull x some_non_default_head\n\nwith a file \"x\" in .git/branches. Anyway, I don't care much either way, if \nit be \"remotes/\" or \"remoterefs/\" or \n\"magic_mapping_for_remote_repositories/\" or even \"repositories/\".\n\nCiao,\nDscho\n"},{"id":"6938","messageId":"200508081822.24582.Josef.Weidendorfer@gmx.de","threadId":"1450","inReplyTo":"Pine.LNX.4.63.0508081234300.32668@wgmdd8.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Teach git push .git/branches shorthand","fromName":"Josef Weidendorfer","fromEmail":"josef.weidendorfer@gmx.de","sentAt":"2005-08-08T16:22:24Z","receivedAt":"2005-08-08T16:22:24Z","isPatch":true,"sender":{"key":"josef.weidendorfer@gmx.de","avatar":null},"body":"On Monday 08 August 2005 12:36, Johannes Schindelin wrote:\n> Hi,\n>\n> On Mon, 8 Aug 2005, Josef Weidendorfer wrote:\n> > Your example defaults to the master head.\n>\n> My point being that I still can say\n>\n> \tgit pull x some_non_default_head\n>\n> with a file \"x\" in .git/branches.\n\nIs this currently possible?\n\nMy understanding of .git/branches was that Cogito uses this as mapping of \nremote branches/heads to local branches/refs, and not to store shortcuts for \nremote git repositories.\nIMHO, the above usage is a kind of \"type mismatch\", as the \"x\" already \ncontains the branch.\n\nBut perhaps for git it is enough to only have a directory of shortcuts for \nremote repositories, to be found in .git/remotes?\n\nAnd cogito can use its own subdirectory for remote/local head mappings. This \nmapping even could use the shortcuts from .git/remotes.\n\n> Anyway, I don't care much either way, if \n> it be \"remotes/\" or \"remoterefs/\" or\n> \"magic_mapping_for_remote_repositories/\" or even \"repositories/\".\n\nMe either.\n\nJosef\n\n>\n> Ciao,\n> Dscho\n> -\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"6972","messageId":"7vd5onzuza.fsf@assigned-by-dhcp.cox.net","threadId":"1450","inReplyTo":"Pine.LNX.4.63.0508081106580.26210@wgmdd8.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Teach git push .git/branches shorthand","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-08-09T02:48:09Z","receivedAt":"2005-08-09T02:48:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> I'd prefer $GIT_DIR/remotes/. And I propose another extension: Since the \n> files stored therein right now contain only one <remote> string, it should \n> be possible to add the default head(s) to the file.\n\nThat makes sense.  Currently my arrangement is:\n\n    $ cd .git/branches && grep . public-*\n    public-master:http://www.kernel.org/pub/scm/git/git.git/\n    public-pu:http://www.kernel.org/pub/scm/git/git.git/#pu\n    public-rc:http://www.kernel.org/pub/scm/git/git.git/#rc\n\nand in order to get the references on the public server to make\nsure people are seeing what I want them to see, I say:\n\n    $ for h in master pu rc\n      do\n        echo $h\n        git fetch public-$h\n        git-rev-parse $h public-$h\n      done\n\nInstead, I should be able to say:\n\n    $ cat .git/remotes/public\n    http://www.kernel.org/pub/scm/git/git.git/#pu:public-pu,rc:public-rc\n\nto mean that the following two are equivalent:\n\n$ git fetch public\n$ git fetch public pu:public-pu rc:public-rc\n\nthat is, fetch pu there and store it in refs/heads/public-pu\n(same for rc).  When I want to fetch only pu from there:\n\n    $ git fetch public pu:public-pu\n\nor even\n\n    $ git fetch public pu\n\nshould work.  If I happen to want to fetch pu one-shot but not\nwant to update my local refs/heads/public-pu, then I should be\nable to say\n\n    $ git fetch public pu:\n\nAnother thing I need to worry about is that I would want to use\nthis remotes information for pushing as well, but probably the\nreference mappings are different when fetching and pushing.\n\nWith something like this:\n\n    $ cat .git/remotes/ko\n    kernel.org:/pub/scm/git/git.git/#master:ko-master,pu:ko-pu,rc:ko-rc\n    $ git fetch ko rc\n\nI would fetch the remote ref \"rc\" and store it in\nrefs/heads/ko-rc, which is fine, but after that I would do my\nwork in the local repository, merge things up and update my\nlocal \"rc\" (not ko-rc, which to me is a \"reference only\"\nbranch), and eventually when pushing I would want to store my\n\"rc\" (again not ko-rc) in \"rc\" over there.\n\nThis means the reference mapping in these two shorthand\nnotations should be flexible enough to allow me to do:\n\n    $ git fetch ko rc ;# get rc from there store it under ko-rc here\n\nwhich is equivalent to \n\n    $ git fetch ko rc:ko-rc\n\nand\n\n    $ git push ko rc  ;# push rc here to rc there\n\nwhich is equivalent to \n\n$ git push ko rc:rc\n\nMaybe its time to do a file format that is a bit more flexible.\nFor example:\n\n    $ cat .git/remotes/ko\n    URL: kernel.org:/pub/scm/git/git.git/\n    Fetch-Reference: master:ko-master pu:ko-pu rc:ko-rc\n    Push-Reference: master pu rc\n\nNote that I do not mean \"Push-Reference\" can not do the rename.\nI could have written \"master:master\" but I did not because I do\n_not_ want renaming push in this example.\n\nPeople who do not need different mappings for fetch/push should\nbe able to say:\n\n    $ cat .git/remotes/public\n    URL: http://www.kernel.org/pub/scm/git/git.git/\n    Reference: pu:public-pu rc:public-rc\n\nAnother thing I should mention is that Fetch-Reference mapping\nis <remote>:<local>, while Push-Reference is <local>:<remote>.\nThis is only because I feel always using <src>:<dst> is easy to\nremember, is the way it works for the command line refs for git\npush already, and is the way I plan to enhance fetch to grok.\n\nMy current thinking is Reference should take <remote>:<local>\nbecause fetching/pulling is probably more common than pushing,\nbut I need to think a bit more about it.\n\nJohannes, sorry for doing my design work in an e-mail buffer\nto you ;-).\n"},{"id":"6976","messageId":"7vvf2fyge4.fsf@assigned-by-dhcp.cox.net","threadId":"1450","inReplyTo":"200508081822.24582.Josef.Weidendorfer@gmx.de","subject":"Re: [PATCH] Teach git push .git/branches shorthand","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-08-09T02:48:35Z","receivedAt":"2005-08-09T02:48:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Josef Weidendorfer <Josef.Weidendorfer@gmx.de> writes:\n\n>> My point being that I still can say\n>>\n>> \tgit pull x some_non_default_head\n>>\n>> with a file \"x\" in .git/branches.\n>\n> Is this currently possible?\n\nNot right now, but that is the plan.\n\n> My understanding of .git/branches was that Cogito uses this as mapping of \n> remote branches/heads to local branches/refs, and not to store shortcuts for \n> remote git repositories.\n> IMHO, the above usage is a kind of \"type mismatch\", as the \"x\" already \n> contains the branch.\n\nYou can look at it this way: \"x which already contains the\nbranch\" can specify the default branch if command line did not\nsay anything, but the command line can override it.\n"},{"id":"7031","messageId":"1123630001.3609.24.camel@localhost.localdomain","threadId":"1450","inReplyTo":"200508081141.23242.Josef.Weidendorfer@gmx.de","subject":"Re: [PATCH] Teach git push .git/branches shorthand","fromName":"Darrin Thompson","fromEmail":"darrint@progeny.com","sentAt":"2005-08-09T23:26:41Z","receivedAt":"2005-08-09T23:26:41Z","isPatch":true,"sender":{"key":"darrint@progeny.com","avatar":null},"body":"On Mon, 2005-08-08 at 11:41 +0200, Josef Weidendorfer wrote:\n> Perhaps we should call it \"remoterefs/\" instead?\n> \n\nHow about .git/peers/ ?\n\n--\nDarrin\n"},{"id":"7066","messageId":"pan.2005.08.11.16.29.34.384813@smurf.noris.de","threadId":"1450","inReplyTo":"200508081822.24582.Josef.Weidendorfer@gmx.de","subject":"Re: [PATCH] Teach git push .git/branches shorthand","fromName":"Matthias Urlichs","fromEmail":"smurf@smurf.noris.de","sentAt":"2005-08-11T16:29:37Z","receivedAt":"2005-08-11T16:29:37Z","isPatch":true,"sender":{"key":"matthias@urlichs.de","avatar":"https://gravatar.com/avatar/2708905af227313eba6f2b2ae0f7d0259b5ac5d71baef58fe5a13c699ce0bbf0?d=mp&s=160"},"body":"Hi, Josef Weidendorfer wrote:\n\n> My understanding of .git/branches was that Cogito uses this as mapping of \n> remote branches/heads to local branches/refs, and not to store shortcuts for \n> remote git repositories.\n\nThat seems to be the case, yes.\n\nI'd argue that the shortcut idea is inherently more flexible, as it can\nemulate mappings, but not vice versa -- for instance, if my local branch\nfoo corresponds to more than one remote branch, .git/branches/* cannot\ncomprehend that idea.\n\nThat being said, I do like Junio's\n>>    $ cat .git/remotes/ko\n>>    URL: kernel.org:/pub/scm/git/git.git/\n>>    Fetch-Reference: master:ko-master pu:ko-pu rc:ko-rc\n>>    Push-Reference: master pu rc\nidea. A lot.\n\n-- \nMatthias Urlichs   |   {M:U} IT Design @ m-u-it.de   |  smurf@smurf.noris.de\nDisclaimer: The quote was selected randomly. Really. | http://smurf.noris.de\n - -\nSometimes I think my head is like a gas tank -- you have to be really\ncareful what you put into it 'cos it might affect the whole system.\n-- I'VE HEARD THE MERMAIDS SINGING\n"}]}