{"thread":{"id":"18378","subject":"Re: Git {log,diff} against tracked branch?","startedAt":"2009-03-18T18:26:03Z","lastAt":"2009-03-22T17:40:16Z","messageCount":61,"participants":["Petr Baudis","Johannes Schindelin","Andreas Gruenbacher","Junio C Hamano","Michael J Gruber","Shawn O. Pearce","Sverre Rabbelier","Jeff King","Wincent Colaiuta","Santi Béjar","Mikael Magnusson","Matthieu Moy","Björn Steinbrink","Daniel Barkalow","Julian Phillips","Miles Bader"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"108403","messageId":"20090318182603.GM8940@machine.or.cz","threadId":"18378","inReplyTo":"200903181448.50706.agruen@suse.de","subject":"Re: Git {log,diff} against tracked branch?","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2009-03-18T18:26:03Z","receivedAt":"2009-03-18T18:26:03Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"  Hi,\n\nOn Wed, Mar 18, 2009 at 02:48:50PM +0100, Andreas Gruenbacher wrote:\n> I often want to see what the differences are between a local branch and the \n> branch it tracks (if it tracks a branch). I currently do something like \"git \n> log master..origin/master\". This is a lot of unnecessary typing though \n> compared to something like \"git log -t master\", or even \"git log -t\" when on \n> the master branch.\n\n  sorry, I think Git can't do anything like this either. :-(\n\n  However, I think something like this would be useful and probably easy\nto do? Maybe someone on the list will get inspired to implement\na special refspec character to represent the \"tracked branch\"\nrelationship, so e.g. %master would expand to %origin/master. Then you\nshould be able to do something like:\n\n\tgit log %..\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nThe average, healthy, well-adjusted adult gets up at seven-thirty\nin the morning feeling just terrible. -- Jean Kerr\n"},{"id":"108422","messageId":"alpine.DEB.1.00.0903182210310.10279@pacific.mpi-cbg.de","threadId":"18378","inReplyTo":"20090318182603.GM8940@machine.or.cz","subject":"[PATCH] Introduce %<branch> as shortcut to the tracked branch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-18T21:12:19Z","receivedAt":"2009-03-18T21:12:19Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nSuggested by Pasky.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tOn Wed, 18 Mar 2009, Petr Baudis wrote:\n\n\t> On Wed, Mar 18, 2009 at 02:48:50PM +0100, Andreas Gruenbacher wrote:\n\t> > I often want to see what the differences are between a local \n\t> > branch and the branch it tracks (if it tracks a branch). I\n\t> > currently do something like \"git log master..origin/master\". \n\t> > This is a lot of unnecessary typing though compared to something\n\t> > like \"git log -t master\", or even \"git log -t\" when on the \n\t> > master branch.\n\t> \n\t> sorry, I think Git can't do anything like this either. :-(\n\t> \n\t> However, I think something like this would be useful and \n\t> probably easy to do? Maybe someone on the list will get inspired to \n\t> implement a special refspec character to represent the \"tracked\n\t> branch\" relationship, so e.g. %master would expand to \n\t> %origin/master. Then you should be able to do something like:\n\t> \n\t> \tgit log %..\n\n\tGreat idea!\n\n sha1_name.c |   22 ++++++++++++++++++----\n 1 files changed, 18 insertions(+), 4 deletions(-)\n\ndiff --git a/sha1_name.c b/sha1_name.c\nindex a96ca8b..1a77b20 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -6,6 +6,7 @@\n #include \"tree-walk.h\"\n #include \"refs.h\"\n #include \"cache-tree.h\"\n+#include \"remote.h\"\n \n static int find_short_object_filename(int len, const char *name, unsigned char *sha1)\n {\n@@ -241,9 +242,10 @@ static int ambiguous_path(const char *path, int len)\n \n /*\n  * *string and *len will only be substituted, and *string returned (for\n- * later free()ing) if the string passed in is of the form @{-<n>}.\n+ * later free()ing) if the string passed in is of the form @{-<n>} or\n+ * of the form %<branch>.\n  */\n-static char *substitute_nth_last_branch(const char **string, int *len)\n+static char *substitute_branch(const char **string, int *len)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \tint ret = interpret_nth_last_branch(*string, &buf);\n@@ -255,12 +257,24 @@ static char *substitute_nth_last_branch(const char **string, int *len)\n \t\treturn (char *)*string;\n \t}\n \n+\tif (**string == '%') {\n+\t\tint ours, theirs;\n+\t\tstruct branch *tracking = branch_get((*string)[1] ?\n+\t\t\t(*string) + 1 : NULL);\n+\n+\t\tif (tracking->merge && tracking->merge[0]->dst) {\n+\t\t\t*string = xstrdup(tracking->merge[0]->dst);\n+\t\t\t*len = strlen(*string);\n+\t\t\treturn (char *)*string;\n+\t\t}\n+\t}\n+\n \treturn NULL;\n }\n \n int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)\n {\n-\tchar *last_branch = substitute_nth_last_branch(&str, &len);\n+\tchar *last_branch = substitute_branch(&str, &len);\n \tconst char **p, *r;\n \tint refs_found = 0;\n \n@@ -289,7 +303,7 @@ int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)\n \n int dwim_log(const char *str, int len, unsigned char *sha1, char **log)\n {\n-\tchar *last_branch = substitute_nth_last_branch(&str, &len);\n+\tchar *last_branch = substitute_branch(&str, &len);\n \tconst char **p;\n \tint logs_found = 0;\n \n-- \n1.6.2.1.422.g885ce.dirty\n"},{"id":"108440","messageId":"200903182241.44388.agruen@suse.de","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903182210310.10279@pacific.mpi-cbg.de","subject":"Re: [PATCH] Introduce %<branch> as shortcut to the tracked branch","fromName":"Andreas Gruenbacher","fromEmail":"agruen@suse.de","sentAt":"2009-03-18T21:41:44Z","receivedAt":"2009-03-18T21:41:44Z","isPatch":true,"sender":{"key":"agruen@suse.de","avatar":null},"body":"On Wednesday, 18 March 2009 22:12:19 Johannes Schindelin wrote:\n> Suggested by Pasky.\n\nDoesn't work here with git e986ceb, unfortunately. On branch master which is \ntracking origin/master, I get this:\n\n\t$ git log %..\n\tfatal: ambiguous argument '%..': unknown revision or path not in the\n\t\tworking tree.\n\n(There also is a trivial reject in hunk one as well.)\n\nThanks,\nAndreas\n"},{"id":"108441","messageId":"alpine.DEB.1.00.0903182245280.10279@pacific.mpi-cbg.de","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903182210310.10279@pacific.mpi-cbg.de","subject":"[PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-18T21:46:22Z","receivedAt":"2009-03-18T21:46:22Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nSuggested by Pasky.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tArjen reminded me on IRC that I worked off of dscho/master instead \n\tof junio/next...  D'oh.\n\n sha1_name.c |   21 +++++++++++++++++----\n 1 files changed, 17 insertions(+), 4 deletions(-)\n\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 2f75179..cb4168d 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -5,6 +5,7 @@\n #include \"blob.h\"\n #include \"tree-walk.h\"\n #include \"refs.h\"\n+#include \"remote.h\"\n \n static int find_short_object_filename(int len, const char *name, unsigned char *sha1)\n {\n@@ -240,9 +241,10 @@ static int ambiguous_path(const char *path, int len)\n \n /*\n  * *string and *len will only be substituted, and *string returned (for\n- * later free()ing) if the string passed in is of the form @{-<n>}.\n+ * later free()ing) if the string passed in is of the form @{-<n>} or\n+ * of the form %<branch>.\n  */\n-static char *substitute_nth_last_branch(const char **string, int *len)\n+static char *substitute_branch(const char **string, int *len)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \tint ret = interpret_nth_last_branch(*string, &buf);\n@@ -254,12 +256,23 @@ static char *substitute_nth_last_branch(const char **string, int *len)\n \t\treturn (char *)*string;\n \t}\n \n+\tif (**string == '%') {\n+\t\tstruct branch *tracking = branch_get((*string)[1] ?\n+\t\t\t(*string) + 1 : NULL);\n+\n+\t\tif (tracking->merge && tracking->merge[0]->dst) {\n+\t\t\t*string = xstrdup(tracking->merge[0]->dst);\n+\t\t\t*len = strlen(*string);\n+\t\t\treturn (char *)*string;\n+\t\t}\n+\t}\n+\n \treturn NULL;\n }\n \n int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)\n {\n-\tchar *last_branch = substitute_nth_last_branch(&str, &len);\n+\tchar *last_branch = substitute_branch(&str, &len);\n \tconst char **p, *r;\n \tint refs_found = 0;\n \n@@ -288,7 +301,7 @@ int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)\n \n int dwim_log(const char *str, int len, unsigned char *sha1, char **log)\n {\n-\tchar *last_branch = substitute_nth_last_branch(&str, &len);\n+\tchar *last_branch = substitute_branch(&str, &len);\n \tconst char **p;\n \tint logs_found = 0;\n \n-- \n1.6.2.1.422.g885ce.dirty\n"},{"id":"108443","messageId":"200903182258.31113.agruen@suse.de","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903182245280.10279@pacific.mpi-cbg.de","subject":"Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Andreas Gruenbacher","fromEmail":"agruen@suse.de","sentAt":"2009-03-18T21:58:30Z","receivedAt":"2009-03-18T21:58:30Z","isPatch":true,"sender":{"key":"agruen@suse.de","avatar":null},"body":"On Wednesday, 18 March 2009 22:46:22 Johannes Schindelin wrote:\n> Suggested by Pasky.\n\nWorks here now. Thanks a lot!\n\nAndreas\n"},{"id":"108450","messageId":"7vr60ubgul.fsf@gitster.siamese.dyndns.org","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903182245280.10279@pacific.mpi-cbg.de","subject":"Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-18T22:34:26Z","receivedAt":"2009-03-18T22:34:26Z","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> Suggested by Pasky.\n>\n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nIn the longer term who suggested matters much less than why such a feature\nis desirable, how it is used, and without it what is impossible and/or\ncumbersome.  What's the motivation behind this?\n\nYou do not have to explain it to me, but you should explain it to the\nhistory that records this commit, and to the users who read doccos.\n"},{"id":"108451","messageId":"alpine.DEB.1.00.0903182343200.10279@pacific.mpi-cbg.de","threadId":"18378","inReplyTo":"200903182258.31113.agruen@suse.de","subject":"Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-18T22:43:40Z","receivedAt":"2009-03-18T22:43:40Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi\n\nOn Wed, 18 Mar 2009, Andreas Gruenbacher wrote:\n\n> On Wednesday, 18 March 2009 22:46:22 Johannes Schindelin wrote:\n> > Suggested by Pasky.\n> \n> Works here now. Thanks a lot!\n\nYou're welcome!  Was fun, too...\n\nCiao,\nDscho\n"},{"id":"108453","messageId":"alpine.DEB.1.00.0903182343580.10279@pacific.mpi-cbg.de","threadId":"18378","inReplyTo":"7vr60ubgul.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-18T22:46:33Z","receivedAt":"2009-03-18T22:46:33Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 18 Mar 2009, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > Suggested by Pasky.\n> >\n> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> \n> In the longer term who suggested matters much less than why such a \n> feature is desirable, how it is used, and without it what is impossible \n> and/or cumbersome.  What's the motivation behind this?\n> \n> You do not have to explain it to me, but you should explain it to the \n> history that records this commit, and to the users who read doccos.\n\nAnd that's not all... Documentation updates and tests for % and %<branch> \nare missing, too.\n\nMy main motivation to make this patch was to see how fast I could come up \nwith something working that does not hurt my eyes.\n\nBut I do not have time to do more today: My main project as well as Git \ngot accepted into the Google Summer of Code program, so I am even more \nswamped than usually.\n\nSo... if anybody feels like it, I would be very thankful for a proper \ncommit message, documentation and tests...\n\nCiao,\nDscho\n"},{"id":"108529","messageId":"49C25C4A.2010202@drmicha.warpmail.net","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903182343580.10279@pacific.mpi-cbg.de","subject":"Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-03-19T14:52:58Z","receivedAt":"2009-03-19T14:52:58Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Johannes Schindelin venit, vidit, dixit 18.03.2009 23:46:\n> Hi,\n> \n> On Wed, 18 Mar 2009, Junio C Hamano wrote:\n> \n>> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n>>\n>>> Suggested by Pasky.\n>>>\n>>> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n>>\n>> In the longer term who suggested matters much less than why such a \n>> feature is desirable, how it is used, and without it what is impossible \n>> and/or cumbersome.  What's the motivation behind this?\n>>\n>> You do not have to explain it to me, but you should explain it to the \n>> history that records this commit, and to the users who read doccos.\n> \n> And that's not all... Documentation updates and tests for % and %<branch> \n> are missing, too.\n> \n> My main motivation to make this patch was to see how fast I could come up \n> with something working that does not hurt my eyes.\n> \n> But I do not have time to do more today: My main project as well as Git \n> got accepted into the Google Summer of Code program, so I am even more \n> swamped than usually.\n> \n> So... if anybody feels like it, I would be very thankful for a proper \n> commit message, documentation and tests...\n\nJust a quick note that I'm feeling like it... Though it seems this does\nnot quite work with local branches, i.e. a branch created with\n\ngit checkout --track -b tracking tracked\n\nwith \"tracked\" being a local branch. I don't see why on first inspection\nof the code (branch.tracking.merge = refs/heads/tracked, so what), but\nmaybe you will...\n\nMichael\n"},{"id":"108536","messageId":"49C26220.8050603@drmicha.warpmail.net","threadId":"18378","inReplyTo":"49C25C4A.2010202@drmicha.warpmail.net","subject":"Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-03-19T15:17:52Z","receivedAt":"2009-03-19T15:17:52Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Michael J Gruber venit, vidit, dixit 19.03.2009 15:52:\n> Johannes Schindelin venit, vidit, dixit 18.03.2009 23:46:\n>> Hi,\n>>\n>> On Wed, 18 Mar 2009, Junio C Hamano wrote:\n>>\n>>> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n>>>\n>>>> Suggested by Pasky.\n>>>>\n>>>> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n>>>\n>>> In the longer term who suggested matters much less than why such a \n>>> feature is desirable, how it is used, and without it what is impossible \n>>> and/or cumbersome.  What's the motivation behind this?\n>>>\n>>> You do not have to explain it to me, but you should explain it to the \n>>> history that records this commit, and to the users who read doccos.\n>>\n>> And that's not all... Documentation updates and tests for % and %<branch> \n>> are missing, too.\n>>\n>> My main motivation to make this patch was to see how fast I could come up \n>> with something working that does not hurt my eyes.\n>>\n>> But I do not have time to do more today: My main project as well as Git \n>> got accepted into the Google Summer of Code program, so I am even more \n>> swamped than usually.\n>>\n>> So... if anybody feels like it, I would be very thankful for a proper \n>> commit message, documentation and tests...\n> \n> Just a quick note that I'm feeling like it... Though it seems this does\n> not quite work with local branches, i.e. a branch created with\n> \n> git checkout --track -b tracking tracked\n> \n> with \"tracked\" being a local branch. I don't see why on first inspection\n> of the code (branch.tracking.merge = refs/heads/tracked, so what), but\n> maybe you will...\n\nSo, for a local branch, branch_get() returns a branch without merge info\neven though it's in the config (the remote is \".\" here). \"git branch\n--track\" is specifically meant for (branching off a ) local branch,\nbecause it's the default for remote branches anyway. Right? Does not\nlook right.\n\nMichael\n"},{"id":"108628","messageId":"alpine.DEB.1.00.0903200121330.10279@pacific.mpi-cbg.de","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903182343580.10279@pacific.mpi-cbg.de","subject":"Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-20T00:23:58Z","receivedAt":"2009-03-20T00:23:58Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 18 Mar 2009, Johannes Schindelin wrote:\n\n> On Wed, 18 Mar 2009, Junio C Hamano wrote:\n> \n> > Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> > \n> > > Suggested by Pasky.\n> > >\n> > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> > \n> > In the longer term who suggested matters much less than why such a \n> > feature is desirable, how it is used, and without it what is impossible \n> > and/or cumbersome.  What's the motivation behind this?\n> > \n> > You do not have to explain it to me, but you should explain it to the \n> > history that records this commit, and to the users who read doccos.\n> \n> And that's not all... Documentation updates and tests for % and %<branch> \n> are missing, too.\n\nDarn, darn, DARN!\n\nJust when I squeezed that half an hour from the time I have to sleep, to \nprovide documentation and tests, _just_ after I finished that, I got the \nidea that '%' might not be a 'bad ref char' after all.\n\nAnd of course I was correct.\n\nJust try this:\n\n\t$ git checkout -b %helloworld\n\nand weep... so, no v3 of that patch, even if I have it right here.\n\nCiao,\nDscho \"who goes to bed being frustrated\"\n"},{"id":"108631","messageId":"alpine.DEB.1.00.0903200137230.10279@pacific.mpi-cbg.de","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903200121330.10279@pacific.mpi-cbg.de","subject":"ref name troubles, was Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-20T00:38:37Z","receivedAt":"2009-03-20T00:38:37Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 20 Mar 2009, Johannes Schindelin wrote:\n\n> Just try this:\n> \n> \t$ git checkout -b %helloworld\n\nIt gets worse.  Much worse.\n\nTry this (triggered by a comment by Ilari on IRC):\n\n\t$ git checkout -b '@{1}'\n\nThat _works_! WTH?\n\nCiao,\nDscho\n"},{"id":"108632","messageId":"20090320004029.GX23521@spearce.org","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903200137230.10279@pacific.mpi-cbg.de","subject":"Re: ref name troubles, was Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-03-20T00:40:29Z","receivedAt":"2009-03-20T00:40:29Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> On Fri, 20 Mar 2009, Johannes Schindelin wrote:\n> \n> > Just try this:\n> > \n> > \t$ git checkout -b %helloworld\n> \n> It gets worse.  Much worse.\n> \n> Try this (triggered by a comment by Ilari on IRC):\n> \n> \t$ git checkout -b '@{1}'\n> \n> That _works_! WTH?\n\n'@' is not reserved.  Neither is '{' or '}'.  Neither is\nthe combination.\n\nWaaaaaay back when I added reflog query syntax I tried to use only\n'@', people with branch names like 'foo@bar' made a point that they\ndidn't want to reserve it.  We stuck the {} in as a \"highly unlikely\nto conflict with a branch name\" and others pointed out most shells\nwill do fun things with those, but we kept it to avoid ambiguous\nmeanings of \"foo@noon\" when foo@noon is already a branch.\n\nFast-forward more than 2 years, and the \"@{...}\" syntax is quite\nwidely used, perhaps more so than \"@\" in a branch name.  But its\nstill not reserved.\n\nSo yea, you can create a branch named \"foo@{1}\".\n\n$ git branch foo@{1}\n$ git branch\n  cache-walk\n  foo@{1}\n  master\n* mergebase-bug\n  mw/blame\n  rr/compareeditor\n  transport-mirror\n  worktree-api\n  worktree-edit\n\nYay.\n\n-- \nShawn.\n"},{"id":"108634","messageId":"20090320004450.GY23521@spearce.org","threadId":"18378","inReplyTo":"20090320004029.GX23521@spearce.org","subject":"Re: ref name troubles, was Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-03-20T00:44:50Z","receivedAt":"2009-03-20T00:44:50Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> wrote:\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > On Fri, 20 Mar 2009, Johannes Schindelin wrote:\n> > \n> > > Just try this:\n> > > \n> > > \t$ git checkout -b %helloworld\n> > \n> > It gets worse.  Much worse.\n> > \n> > Try this (triggered by a comment by Ilari on IRC):\n> > \n> > \t$ git checkout -b '@{1}'\n> > \n> > That _works_! WTH?\n> \n> '@' is not reserved.  Neither is '{' or '}'.  Neither is\n> the combination.\n\nIn hindsight, I wish we had reserved all of the \"fun\" characters\nlike !@#$%^&*():;~'\"\\ and prevented them from ever appearing in a\nref name.\n\nInstead only what check_ref_format() in refs.c ll.694 tells is\nis reserved:\n\n 671 /*\n 672  * Make sure \"ref\" is something reasonable to have under \".git/refs/\";\n 673  * We do not like it if:\n 674  *\n 675  * - any path component of it begins with \".\", or\n 676  * - it has double dots \"..\", or\n 677  * - it has ASCII control character, \"~\", \"^\", \":\" or SP, anywhere, or\n 678  * - it ends with a \"/\".\n 679  */\n\nHeh.  At least : and SP are reserved.\n\nUse BEL for your %helloworld hack.  It'll be fun to type.  :-)\n\n-- \nShawn.\n"},{"id":"108653","messageId":"fabb9a1e0903192259m3b1516a3h315baf84ce65aa35@mail.gmail.com","threadId":"18378","inReplyTo":"20090320004450.GY23521@spearce.org","subject":"Re: ref name troubles, was Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-03-20T05:59:00Z","receivedAt":"2009-03-20T05:59:00Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Fri, Mar 20, 2009 at 01:44, Shawn O. Pearce <spearce@spearce.org> wrote:\n> In hindsight, I wish we had reserved all of the \"fun\" characters\n> like !@#$%^&*():;~'\"\\ and prevented them from ever appearing in a\n> ref name.\n\nMaybe we should add a --pedantic which whines when you use any of\nthose in a branch name; oh wait, wrong project... :P.\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"108655","messageId":"20090320060545.GB27008@coredump.intra.peff.net","threadId":"18378","inReplyTo":"20090320004029.GX23521@spearce.org","subject":"Re: ref name troubles, was Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-03-20T06:05:45Z","receivedAt":"2009-03-20T06:05:45Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Mar 19, 2009 at 05:40:29PM -0700, Shawn O. Pearce wrote:\n\n> So yea, you can create a branch named \"foo@{1}\".\n\nBut you can't actually refer to it:\n\n  $ git branch foo@{1}\n  $ git show foo@{1} --\n  fatal: bad revision 'foo@{1}'\n\nwhich implies that nobody is actually using it for anything.\n\n-Peff\n"},{"id":"108659","messageId":"7vprgc4r6h.fsf@gitster.siamese.dyndns.org","threadId":"18378","inReplyTo":"20090320060545.GB27008@coredump.intra.peff.net","subject":"Re: ref name troubles, was Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-20T06:57:42Z","receivedAt":"2009-03-20T06:57:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Thu, Mar 19, 2009 at 05:40:29PM -0700, Shawn O. Pearce wrote:\n>\n>> So yea, you can create a branch named \"foo@{1}\".\n>\n> But you can't actually refer to it:\n>\n>   $ git branch foo@{1}\n>   $ git show foo@{1} --\n>   fatal: bad revision 'foo@{1}'\n>\n> which implies that nobody is actually using it for anything.\n\nI think you are right.  It is just \"git branch\" and perhaps \"git\nupdate-ref\" are too loose in enforcing what can be created.\n"},{"id":"108677","messageId":"alpine.DEB.1.00.0903201027450.10279@pacific.mpi-cbg.de","threadId":"18378","inReplyTo":"20090320004450.GY23521@spearce.org","subject":"[PATCH v3] Introduce BEL<branch> as shortcut to the tracked branch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-20T09:29:11Z","receivedAt":"2009-03-20T09:29:11Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nOften, it is quite interesting to inspect the branch tracked by a given\nbranch.  This patch introduces a nice notation to get at the tracked\nbranch: 'BEL<branch>' can be used to access that tracked branch.\n\nA special shortcut 'BEL' refers to the branch tracked by the current branch.\n\nSuggested by Pasky and Shawn.\n\nThis patch extends the function introduced to handle the nth-last branch\n(via the {-<n>} notation); therefore that function name was renamed to\nsomething more general.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tOn Thu, 19 Mar 2009, Shawn O. Pearce wrote:\n\n\t> Use BEL for your %helloworld hack.\n\n\tHere you are.\n\n Documentation/git-rev-parse.txt |    3 ++\n sha1_name.c                     |   21 ++++++++++++---\n t/t1506-rev-parse-tracked.sh    |   54 +++++++++++++++++++++++++++++++++++++++\n 3 files changed, 74 insertions(+), 4 deletions(-)\n create mode 100755 t/t1506-rev-parse-tracked.sh\n\ndiff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt\nindex 5ed2bc8..a4bcd5e 100644\n--- a/Documentation/git-rev-parse.txt\n+++ b/Documentation/git-rev-parse.txt\n@@ -215,6 +215,9 @@ when you run 'git-merge'.\n * The special construct '@\\{-<n>\\}' means the <n>th branch checked out\n   before the current one.\n \n+* The prefix 'BEL' to a ref means the branch tracked by that ref.  If no\n+  ref was specified, it means the branch tracked by the current branch.\n+\n * A suffix '{caret}' to a revision parameter means the first parent of\n   that commit object.  '{caret}<n>' means the <n>th parent (i.e.\n   'rev{caret}'\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 2f75179..cb4168d 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -5,6 +5,7 @@\n #include \"blob.h\"\n #include \"tree-walk.h\"\n #include \"refs.h\"\n+#include \"remote.h\"\n \n static int find_short_object_filename(int len, const char *name, unsigned char *sha1)\n {\n@@ -240,9 +241,10 @@ static int ambiguous_path(const char *path, int len)\n \n /*\n  * *string and *len will only be substituted, and *string returned (for\n- * later free()ing) if the string passed in is of the form @{-<n>}.\n+ * later free()ing) if the string passed in is of the form @{-<n>} or\n+ * of the form BEL<branch>.\n  */\n-static char *substitute_nth_last_branch(const char **string, int *len)\n+static char *substitute_branch(const char **string, int *len)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \tint ret = interpret_nth_last_branch(*string, &buf);\n@@ -254,12 +256,23 @@ static char *substitute_nth_last_branch(const char **string, int *len)\n \t\treturn (char *)*string;\n \t}\n \n+\tif (**string == '\\007') {\n+\t\tstruct branch *tracking = branch_get((*string)[1] ?\n+\t\t\t(*string) + 1 : NULL);\n+\n+\t\tif (tracking->merge && tracking->merge[0]->dst) {\n+\t\t\t*string = xstrdup(tracking->merge[0]->dst);\n+\t\t\t*len = strlen(*string);\n+\t\t\treturn (char *)*string;\n+\t\t}\n+\t}\n+\n \treturn NULL;\n }\n \n int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)\n {\n-\tchar *last_branch = substitute_nth_last_branch(&str, &len);\n+\tchar *last_branch = substitute_branch(&str, &len);\n \tconst char **p, *r;\n \tint refs_found = 0;\n \n@@ -288,7 +301,7 @@ int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)\n \n int dwim_log(const char *str, int len, unsigned char *sha1, char **log)\n {\n-\tchar *last_branch = substitute_nth_last_branch(&str, &len);\n+\tchar *last_branch = substitute_branch(&str, &len);\n \tconst char **p;\n \tint logs_found = 0;\n \ndiff --git a/t/t1506-rev-parse-tracked.sh b/t/t1506-rev-parse-tracked.sh\nnew file mode 100755\nindex 0000000..359f648\n--- /dev/null\n+++ b/t/t1506-rev-parse-tracked.sh\n@@ -0,0 +1,54 @@\n+#!/bin/sh\n+\n+test_description='test BEL<branch> syntax'\n+\n+. ./test-lib.sh\n+\n+\n+test_expect_success 'setup' '\n+\n+\ttest_commit 1 &&\n+\tgit checkout -b side &&\n+\ttest_commit 2 &&\n+\tgit checkout master &&\n+\tgit clone . clone &&\n+\ttest_commit 3 &&\n+\t(cd clone &&\n+\t test_commit 4 &&\n+\t git branch --track my-side origin/side)\n+\n+'\n+\n+full_name () {\n+\t(cd clone &&\n+\t git rev-parse --symbolic-full-name \"$@\")\n+}\n+\n+commit_subject () {\n+\t(cd clone &&\n+\t git show -s --pretty=format:%s \"$@\")\n+}\n+\n+test_expect_success 'BEL resolves to correct full name' '\n+\n+\ttest refs/remotes/origin/master = \"$(full_name \"$(echo -e '\\007')\")\"\n+\n+'\n+\n+test_expect_success 'BELmy-side resolves to correct full name' '\n+\n+\ttest refs/remotes/origin/side = \"$(full_name \"$(echo -e '\\007')\"my-side)\"\n+\n+'\n+\n+test_expect_success 'BELmy-side resolves to correct commit' '\n+\n+\tgit checkout side &&\n+\ttest_commit 5 &&\n+\t(cd clone && git fetch) &&\n+\ttest 2 = \"$(commit_subject my-side)\" &&\n+\ttest 5 = \"$(commit_subject \"$(echo -e '\\007')\"my-side)\"\n+\n+'\n+\n+test_done\n-- \n1.6.2.1.477.g74567\n"},{"id":"108678","messageId":"alpine.DEB.1.00.0903201029290.10279@pacific.mpi-cbg.de","threadId":"18378","inReplyTo":"7vprgc4r6h.fsf@gitster.siamese.dyndns.org","subject":"Re: ref name troubles, was Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-20T09:30:29Z","receivedAt":"2009-03-20T09:30:29Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 19 Mar 2009, Junio C Hamano wrote:\n\n> Jeff King <peff@peff.net> writes:\n> \n> > On Thu, Mar 19, 2009 at 05:40:29PM -0700, Shawn O. Pearce wrote:\n> >\n> >> So yea, you can create a branch named \"foo@{1}\".\n> >\n> > But you can't actually refer to it:\n> >\n> >   $ git branch foo@{1}\n> >   $ git show foo@{1} --\n> >   fatal: bad revision 'foo@{1}'\n> >\n> > which implies that nobody is actually using it for anything.\n> \n> I think you are right.  It is just \"git branch\" and perhaps \"git\n> update-ref\" are too loose in enforcing what can be created.\n\n\"git branch\" I agree with, but not \"git update-ref\".  As plumbing, the \nlatter should be much more allowing, feeding rope aplenty (but also \nallowing cool tricks we do not think about yet).\n\nCiao,\nDscho\n"},{"id":"108681","messageId":"3F6729A7-76FA-43F4-9538-D644B30576D7@wincent.com","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903201027450.10279@pacific.mpi-cbg.de","subject":"Re: [PATCH v3] Introduce BEL<branch> as shortcut to the tracked branch","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2009-03-20T09:42:18Z","receivedAt":"2009-03-20T09:42:18Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 20/3/2009, a las 10:29, Johannes Schindelin escribió:\n\n>\n> Often, it is quite interesting to inspect the branch tracked by a  \n> given\n> branch.  This patch introduces a nice notation to get at the tracked\n> branch: 'BEL<branch>' can be used to access that tracked branch.\n>\n> A special shortcut 'BEL' refers to the branch tracked by the current  \n> branch.\n>\n> Suggested by Pasky and Shawn.\n\nWhat does BEL actually stand for? I read Shawn's suggestion, but it's  \nnot immediately clear to me what \"BEL\" means.\n\nCheers,\nWincent\n"},{"id":"108683","messageId":"alpine.DEB.1.00.0903201053280.10279@pacific.mpi-cbg.de","threadId":"18378","inReplyTo":"3F6729A7-76FA-43F4-9538-D644B30576D7@wincent.com","subject":"Re: [PATCH v3] Introduce BEL<branch> as shortcut to the tracked branch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-20T09:54:51Z","receivedAt":"2009-03-20T09:54:51Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 20 Mar 2009, Wincent Colaiuta wrote:\n\n> El 20/3/2009, a las 10:29, Johannes Schindelin escribió:\n> \n> >\n> >Often, it is quite interesting to inspect the branch tracked by a given\n> >branch.  This patch introduces a nice notation to get at the tracked\n> >branch: 'BEL<branch>' can be used to access that tracked branch.\n> >\n> >A special shortcut 'BEL' refers to the branch tracked by the current branch.\n> >\n> >Suggested by Pasky and Shawn.\n> \n> What does BEL actually stand for? I read Shawn's suggestion, but it's not\n> immediately clear to me what \"BEL\" means.\n\nIt is the ASCII \"bell\" character, 007 (I always wanted to write that \nmagic identifier into a patch).\n\nFWIW you could type it in a regular ANSI terminal using Control-v \nControl-g.\n\nCiao,\nDscho\n"},{"id":"108687","messageId":"1237543471-27248-1-git-send-email-git@drmicha.warpmail.net","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903201027450.10279@pacific.mpi-cbg.de","subject":"[PATCH] Document and test the new % shotcut for the tracked branch","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-03-20T10:04:31Z","receivedAt":"2009-03-20T10:04:31Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\nJohannes Schindelin venit, vidit, dixit 20.03.2009 10:29:\n> \n> Often, it is quite interesting to inspect the branch tracked by a given\n> branch.  This patch introduces a nice notation to get at the tracked\n> branch: 'BEL<branch>' can be used to access that tracked branch.\n> \n> A special shortcut 'BEL' refers to the branch tracked by the current branch.\n> \n> Suggested by Pasky and Shawn.\n> \n> This patch extends the function introduced to handle the nth-last branch\n> (via the {-<n>} notation); therefore that function name was renamed to\n> something more general.\n> \n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nI guess you beat me to it then, which is fine.\n\nBut haven't you seen my note about the failing test either? The code below\ntests with branches which track local branches. merge and remote is set\nfor the branch in question (\"tracking\"), it's just that remote is \".\".\nIt seems that the remote.c code does not set up merge info for these\nbranches.\n\n<Goes to figure out how to enter BEL...>\n\n Documentation/git-rev-parse.txt |    3 ++\n t/t1506-rev-parse-track.sh      |   60 +++++++++++++++++++++++++++++++++++++++\n 2 files changed, 63 insertions(+), 0 deletions(-)\n create mode 100755 t/t1506-rev-parse-track.sh\n\ndiff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt\nindex 5ed2bc8..dafcfe8 100644\n--- a/Documentation/git-rev-parse.txt\n+++ b/Documentation/git-rev-parse.txt\n@@ -215,6 +215,9 @@ when you run 'git-merge'.\n * The special construct '@\\{-<n>\\}' means the <n>th branch checked out\n   before the current one.\n \n+* A prefix '%', optionally followed by a branchname '<branch>', means the\n+  branch tracked by '<branch>'. '<branch>' defaults to the current branch.\n+\n * A suffix '{caret}' to a revision parameter means the first parent of\n   that commit object.  '{caret}<n>' means the <n>th parent (i.e.\n   'rev{caret}'\ndiff --git a/t/t1506-rev-parse-track.sh b/t/t1506-rev-parse-track.sh\nnew file mode 100755\nindex 0000000..1ca1dd6\n--- /dev/null\n+++ b/t/t1506-rev-parse-track.sh\n@@ -0,0 +1,60 @@\n+#!/bin/sh\n+\n+test_description='test % syntax'\n+\n+. ./test-lib.sh\n+\n+\n+make_commit () {\n+\techo \"$1\" > \"$1\" &&\n+\tgit add \"$1\" &&\n+\tgit commit -m \"$1\"\n+}\n+\n+\n+test_expect_success 'setup' '\n+\n+\tmake_commit 1 &&\n+\tgit branch tracked &&\n+\tmake_commit 2 &&\n+\tgit checkout tracked &&\n+\tmake_commit 3 &&\n+\tgit checkout --track -b tracking tracked\n+\tmake_commit 4 &&\n+\tgit checkout master\n+\n+'\n+\n+# tracking tracks tracked\n+# master does not track anything\n+# all three point at different commits\n+\n+test_rev_equivalent () {\n+\n+\tgit rev-parse \"$1\" > expect &&\n+\tgit rev-parse \"$2\" > output &&\n+\ttest_cmp expect output\n+\n+}\n+\n+test_expect_success '%trackingbranch works' '\n+\ttest_rev_equivalent tracked %tracking\n+'\n+\n+test_expect_success '% works in tracking branch' '\n+\tgit checkout tracking &&\n+\ttest_rev_equivalent tracked %\n+'\n+\n+test_expect_success '%nontrackingbranch fails' '\n+\ttest_must_fail git rev-parse %tracked\n+'\n+\n+test_expect_success '% fails in non-tracking branch' '\n+\tgit checkout tracked &&\n+\ttest_must_fail git rev-parse %\n+'\n+\n+test_done\n+\n+\n-- \n1.6.2.149.g6462\n"},{"id":"108691","messageId":"alpine.DEB.1.00.0903201128380.10279@pacific.mpi-cbg.de","threadId":"18378","inReplyTo":"1237543471-27248-1-git-send-email-git@drmicha.warpmail.net","subject":"Re: [PATCH] Document and test the new % shotcut for the tracked branch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-20T10:31:31Z","receivedAt":"2009-03-20T10:31:31Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 20 Mar 2009, Michael J Gruber wrote:\n\n> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n> ---\n\nThat is brutal.  First shot, then cut.\n\n> Johannes Schindelin venit, vidit, dixit 20.03.2009 10:29:\n> > \n> > Often, it is quite interesting to inspect the branch tracked by a \n> > given branch.  This patch introduces a nice notation to get at the \n> > tracked branch: 'BEL<branch>' can be used to access that tracked \n> > branch.\n> > \n> > A special shortcut 'BEL' refers to the branch tracked by the current \n> > branch.\n> > \n> > Suggested by Pasky and Shawn.\n> > \n> > This patch extends the function introduced to handle the nth-last \n> > branch (via the {-<n>} notation); therefore that function name was \n> > renamed to something more general.\n> > \n> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> \n> I guess you beat me to it then, which is fine.\n\nI had it ready yesterday!  But the real problem is not addressed by your \npatch, either: '%<branch>' is a legal branch name.\n\nI briefly considered <branch>^{tracked}, but\n\n- the ^{} codepath does not try to substitute branch _names_, so we'd have \n  to duplicate that ^{} detection, and,\n\n- it is really cumbersome to write.\n\n> But haven't you seen my note about the failing test either? The code \n> below tests with branches which track local branches. merge and remote \n> is set for the branch in question (\"tracking\"), it's just that remote is \n> \".\". It seems that the remote.c code does not set up merge info for \n> these branches.\n\nI have seen it, it's just not my itch, and I am busy enough as it is.\n\n> <Goes to figure out how to enter BEL...>\n\nCtrl-v Ctrl-g\n\nCiao,\nDscho\n"},{"id":"108693","messageId":"49C37240.6070604@drmicha.warpmail.net","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903201128380.10279@pacific.mpi-cbg.de","subject":"Re: [PATCH] Document and test the new % shotcut for the tracked branch","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-03-20T10:38:56Z","receivedAt":"2009-03-20T10:38:56Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Johannes Schindelin venit, vidit, dixit 20.03.2009 11:31:\n> Hi,\n> \n> On Fri, 20 Mar 2009, Michael J Gruber wrote:\n> \n>> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n>> ---\n> \n> That is brutal.  First shot, then cut.\n\nI'm sorry! But you're a tough guy, you'll recover...\n\n> \n>> Johannes Schindelin venit, vidit, dixit 20.03.2009 10:29:\n>>>\n>>> Often, it is quite interesting to inspect the branch tracked by a \n>>> given branch.  This patch introduces a nice notation to get at the \n>>> tracked branch: 'BEL<branch>' can be used to access that tracked \n>>> branch.\n>>>\n>>> A special shortcut 'BEL' refers to the branch tracked by the current \n>>> branch.\n>>>\n>>> Suggested by Pasky and Shawn.\n>>>\n>>> This patch extends the function introduced to handle the nth-last \n>>> branch (via the {-<n>} notation); therefore that function name was \n>>> renamed to something more general.\n>>>\n>>> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n>>\n>> I guess you beat me to it then, which is fine.\n> \n> I had it ready yesterday!  But the real problem is not addressed by your \n> patch, either: '%<branch>' is a legal branch name.\n\nNo, of course, I just added doc+test to your patch v2, since you seemed\nto encourage people to do so.\n\nI would have sent it out yesterday if my tests hadn't shown a problem.\n(Or did you misunderstand my doc notation? <branch> = ${branch} =\n\"branch\" placeholder for a generic branch name)\n\n> I briefly considered <branch>^{tracked}, but\n> \n> - the ^{} codepath does not try to substitute branch _names_, so we'd have \n>   to duplicate that ^{} detection, and,\n> \n> - it is really cumbersome to write.\n> \n>> But haven't you seen my note about the failing test either? The code \n>> below tests with branches which track local branches. merge and remote \n>> is set for the branch in question (\"tracking\"), it's just that remote is \n>> \".\". It seems that the remote.c code does not set up merge info for \n>> these branches.\n> \n> I have seen it, it's just not my itch, and I am busy enough as it is.\n\nIf I'm not totally off-track (which I may well be) then that problem\nshould show up with other uses of the merge/track setting as well. I\nguess it's just that everyone tracks remote branches, not local ones.\n\nI'll see if I have time...\n\n>> <Goes to figure out how to enter BEL...>\n> \n> Ctrl-v Ctrl-g\n> \n> Ciao,\n> Dscho\n\nBing bing bing...\n\nMichael\n"},{"id":"108696","messageId":"20090320111238.GZ8940@machine.or.cz","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903201029290.10279@pacific.mpi-cbg.de","subject":"Re: ref name troubles, was Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2009-03-20T11:12:38Z","receivedAt":"2009-03-20T11:12:38Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Hi!\n\nOn Fri, Mar 20, 2009 at 10:30:29AM +0100, Johannes Schindelin wrote:\n> On Thu, 19 Mar 2009, Junio C Hamano wrote:\n> \n> > I think you are right.  It is just \"git branch\" and perhaps \"git\n> > update-ref\" are too loose in enforcing what can be created.\n> \n> \"git branch\" I agree with, but not \"git update-ref\".  As plumbing, the \n> latter should be much more allowing, feeding rope aplenty (but also \n> allowing cool tricks we do not think about yet).\n\nWe shouldn't allow creating insane ref names even with update-ref. That\nway porcelains cannot rely on update-ref to sanity check the user's\ncrap. At most, maybe you might want to bypass this check with some force\nswitch, though I really can't quite imagine why.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nThe average, healthy, well-adjusted adult gets up at seven-thirty\nin the morning feeling just terrible. -- Jean Kerr\n"},{"id":"108697","messageId":"20090320111656.GA8940@machine.or.cz","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903201128380.10279@pacific.mpi-cbg.de","subject":"Re: [PATCH] Document and test the new % shotcut for the tracked branch","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2009-03-20T11:16:56Z","receivedAt":"2009-03-20T11:16:56Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"  Hi!\n\nOn Fri, Mar 20, 2009 at 11:31:31AM +0100, Johannes Schindelin wrote:\n> I had it ready yesterday!  But the real problem is not addressed by your \n> patch, either: '%<branch>' is a legal branch name.\n> \n> I briefly considered <branch>^{tracked}, but\n> \n> - the ^{} codepath does not try to substitute branch _names_, so we'd have \n>   to duplicate that ^{} detection, and,\n> \n> - it is really cumbersome to write.\n\nWe already have @{N} to do one branch-based substitution, so what about\nfollowing this convention? Can't we have @{t}?\n\n\t\t\t\tPetr \"Pasky\" Baudis\n"},{"id":"108698","messageId":"alpine.DEB.1.00.0903201245140.6865@intel-tinevez-2-302","threadId":"18378","inReplyTo":"20090320111238.GZ8940@machine.or.cz","subject":"Re: ref name troubles, was Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-20T11:46:19Z","receivedAt":"2009-03-20T11:46:19Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 20 Mar 2009, Petr Baudis wrote:\n\n> On Fri, Mar 20, 2009 at 10:30:29AM +0100, Johannes Schindelin wrote:\n> > On Thu, 19 Mar 2009, Junio C Hamano wrote:\n> > \n> > > I think you are right.  It is just \"git branch\" and perhaps \"git\n> > > update-ref\" are too loose in enforcing what can be created.\n> > \n> > \"git branch\" I agree with, but not \"git update-ref\".  As plumbing, the \n> > latter should be much more allowing, feeding rope aplenty (but also \n> > allowing cool tricks we do not think about yet).\n> \n> We shouldn't allow creating insane ref names even with update-ref. That\n> way porcelains cannot rely on update-ref to sanity check the user's\n> crap. At most, maybe you might want to bypass this check with some force\n> switch, though I really can't quite imagine why.\n\nYou really cannot imagine?  You, the author of filter-branch?  People _do_ \nhave fscked-up repositories, but they get really angry when they cannot \nuse rebase or filter-branch on them.\n\nCiao,\nDscho\n"},{"id":"108699","messageId":"alpine.DEB.1.00.0903201247440.6865@intel-tinevez-2-302","threadId":"18378","inReplyTo":"20090320111656.GA8940@machine.or.cz","subject":"Re: [PATCH] Document and test the new % shotcut for the tracked branch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-20T11:48:50Z","receivedAt":"2009-03-20T11:48:50Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 20 Mar 2009, Petr Baudis wrote:\n\n> On Fri, Mar 20, 2009 at 11:31:31AM +0100, Johannes Schindelin wrote:\n> > I had it ready yesterday!  But the real problem is not addressed by \n> > your patch, either: '%<branch>' is a legal branch name.\n> > \n> > I briefly considered <branch>^{tracked}, but\n> > \n> > - the ^{} codepath does not try to substitute branch _names_, so we'd \n> >   have to duplicate that ^{} detection, and,\n> > \n> > - it is really cumbersome to write.\n> \n> We already have @{N} to do one branch-based substitution, so what about \n> following this convention? Can't we have @{t}?\n\nHave you ever tried a German keyboard layout?  You would not say that @{} \nis easy to write if you did.\n\nBesides, @{<string>} is already taken for the date-based reflog.\n\nCiao,\nDscho\n"},{"id":"108700","messageId":"20090320115043.GB8940@machine.or.cz","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903201245140.6865@intel-tinevez-2-302","subject":"Re: ref name troubles, was Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2009-03-20T11:50:43Z","receivedAt":"2009-03-20T11:50:43Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"On Fri, Mar 20, 2009 at 12:46:19PM +0100, Johannes Schindelin wrote:\n> Hi,\n> \n> On Fri, 20 Mar 2009, Petr Baudis wrote:\n> \n> > On Fri, Mar 20, 2009 at 10:30:29AM +0100, Johannes Schindelin wrote:\n> > > On Thu, 19 Mar 2009, Junio C Hamano wrote:\n> > > \n> > > > I think you are right.  It is just \"git branch\" and perhaps \"git\n> > > > update-ref\" are too loose in enforcing what can be created.\n> > > \n> > > \"git branch\" I agree with, but not \"git update-ref\".  As plumbing, the \n> > > latter should be much more allowing, feeding rope aplenty (but also \n> > > allowing cool tricks we do not think about yet).\n> > \n> > We shouldn't allow creating insane ref names even with update-ref. That\n> > way porcelains cannot rely on update-ref to sanity check the user's\n> > crap. At most, maybe you might want to bypass this check with some force\n> > switch, though I really can't quite imagine why.\n> \n> You really cannot imagine?  You, the author of filter-branch?  People _do_ \n> have fscked-up repositories, but they get really angry when they cannot \n> use rebase or filter-branch on them.\n\nThey can rename the ref as the first step of a cleanup, can't they?\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nThe average, healthy, well-adjusted adult gets up at seven-thirty\nin the morning feeling just terrible. -- Jean Kerr\n"},{"id":"108701","messageId":"alpine.DEB.1.00.0903201255230.6865@intel-tinevez-2-302","threadId":"18378","inReplyTo":"20090320115043.GB8940@machine.or.cz","subject":"Re: ref name troubles, was Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-20T11:57:13Z","receivedAt":"2009-03-20T11:57:13Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 20 Mar 2009, Petr Baudis wrote:\n\n> On Fri, Mar 20, 2009 at 12:46:19PM +0100, Johannes Schindelin wrote:\n> \n> > On Fri, 20 Mar 2009, Petr Baudis wrote:\n> > \n> > > On Fri, Mar 20, 2009 at 10:30:29AM +0100, Johannes Schindelin wrote:\n> > > > On Thu, 19 Mar 2009, Junio C Hamano wrote:\n> > > > \n> > > > > I think you are right.  It is just \"git branch\" and perhaps \"git\n> > > > > update-ref\" are too loose in enforcing what can be created.\n> > > > \n> > > > \"git branch\" I agree with, but not \"git update-ref\".  As plumbing, the \n> > > > latter should be much more allowing, feeding rope aplenty (but also \n> > > > allowing cool tricks we do not think about yet).\n> > > \n> > > We shouldn't allow creating insane ref names even with update-ref. That\n> > > way porcelains cannot rely on update-ref to sanity check the user's\n> > > crap. At most, maybe you might want to bypass this check with some force\n> > > switch, though I really can't quite imagine why.\n> > \n> > You really cannot imagine?  You, the author of filter-branch?  People _do_ \n> > have fscked-up repositories, but they get really angry when they cannot \n> > use rebase or filter-branch on them.\n> \n> They can rename the ref as the first step of a cleanup, can't they?\n\nWell, of course, we can make life hard on everybody.  That is quite \npossible.\n\nBut then, we can be nice, and at the same time fix the problem _properly_.\n\nIMHO a _warning_ should be the best thing.\n\nBut all this does not solve _my_ problem: I'd like something as easy to \nwrite as %next, but as unlikely to be used in existing refs as @{..}.\n\nCiao,\nDscho\n"},{"id":"108704","messageId":"adf1fd3d0903200533s2be08ee7t58a22180b1c886c0@mail.gmail.com","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903201053280.10279@pacific.mpi-cbg.de","subject":"Re: [PATCH v3] Introduce BEL<branch> as shortcut to the tracked branch","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-03-20T12:33:18Z","receivedAt":"2009-03-20T12:33:18Z","isPatch":true,"sender":{"key":"santi@agolina.net","avatar":null},"body":"2009/3/20 Johannes Schindelin <Johannes.Schindelin@gmx.de>:\n> Hi,\n>\n> On Fri, 20 Mar 2009, Wincent Colaiuta wrote:\n>\n>> El 20/3/2009, a las 10:29, Johannes Schindelin escribió:\n>>\n>> >\n>> >Often, it is quite interesting to inspect the branch tracked by a given\n>> >branch.  This patch introduces a nice notation to get at the tracked\n>> >branch: 'BEL<branch>' can be used to access that tracked branch.\n>> >\n>> >A special shortcut 'BEL' refers to the branch tracked by the current branch.\n>> >\n>> >Suggested by Pasky and Shawn.\n>>\n>> What does BEL actually stand for? I read Shawn's suggestion, but it's not\n>> immediately clear to me what \"BEL\" means.\n>\n> It is the ASCII \"bell\" character, 007 (I always wanted to write that\n> magic identifier into a patch).\n>\n> FWIW you could type it in a regular ANSI terminal using Control-v\n> Control-g.\n\nCan we use branch^{origin} instead? It is longer to type, but uses the\nsame syntax as the ^{tree}, ^{commit}, ^{tag} and you don't have to\nknow how to produce the bell character.\n\n2 cents,\nSanti\n"},{"id":"108708","messageId":"200903201345.23864.agruen@suse.de","threadId":"18378","inReplyTo":"adf1fd3d0903200533s2be08ee7t58a22180b1c886c0@mail.gmail.com","subject":"Re: [PATCH v3] Introduce BEL<branch> as shortcut to the tracked branch","fromName":"Andreas Gruenbacher","fromEmail":"agruen@suse.de","sentAt":"2009-03-20T12:45:23Z","receivedAt":"2009-03-20T12:45:23Z","isPatch":true,"sender":{"key":"agruen@suse.de","avatar":null},"body":"On Friday, 20 March 2009 13:33:18 Santi Béjar wrote:\n> Can we use branch^{origin} instead? It is longer to type, but uses the\n> same syntax as the ^{tree}, ^{commit}, ^{tag} and you don't have to\n> know how to produce the bell character.\n\nFor me this defeats the purpose; I can just as well type origin/branch (or \nwhatever it is) instead of branch^{origin}.  I'm really looking for something \nvery short like % or %branch.\n\nA notation for referring to the tracked branch in arbitrary contexts still \nsounds like a good idea, and for that purpose, your proposal sounds useful.\n\nThanks,\nAndreas\n"},{"id":"108707","messageId":"alpine.DEB.1.00.0903201345190.6865@intel-tinevez-2-302","threadId":"18378","inReplyTo":"adf1fd3d0903200533s2be08ee7t58a22180b1c886c0@mail.gmail.com","subject":"Re: [PATCH v3] Introduce BEL<branch> as shortcut to the tracked branch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-20T12:46:37Z","receivedAt":"2009-03-20T12:46:37Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 20 Mar 2009, Santi Béjar wrote:\n\n> 2009/3/20 Johannes Schindelin <Johannes.Schindelin@gmx.de>:\n>\n> > On Fri, 20 Mar 2009, Wincent Colaiuta wrote:\n> >\n> >> El 20/3/2009, a las 10:29, Johannes Schindelin escribió:\n> >>\n> >> >Often, it is quite interesting to inspect the branch tracked by a \n> >> >given branch.  This patch introduces a nice notation to get at the \n> >> >tracked branch: 'BEL<branch>' can be used to access that tracked \n> >> >branch.\n> >> >\n> >> >A special shortcut 'BEL' refers to the branch tracked by the current \n> >> >branch.\n> >> >\n> >> >Suggested by Pasky and Shawn.\n> >>\n> >> What does BEL actually stand for? I read Shawn's suggestion, but it's \n> >> not immediately clear to me what \"BEL\" means.\n> >\n> > It is the ASCII \"bell\" character, 007 (I always wanted to write that \n> > magic identifier into a patch).\n> >\n> > FWIW you could type it in a regular ANSI terminal using Control-v \n> > Control-g.\n> \n> Can we use branch^{origin} instead? It is longer to type, but uses the \n> same syntax as the ^{tree}, ^{commit}, ^{tag} and you don't have to know \n> how to produce the bell character.\n\nI think I addressed that issue already.  (Summary: I do not like it)\n\nLet me spell it out if it was not obvious yet: the BEL patch was meant as \na more or less funny reminder that the issue is not solved and that I need \nhelp.\n\nCiao,\nDscho\n"},{"id":"108709","messageId":"237967ef0903200553v58af40b5sfbfa0bbb1f9d96eb@mail.gmail.com","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903201345190.6865@intel-tinevez-2-302","subject":"Re: [PATCH v3] Introduce BEL<branch> as shortcut to the tracked branch","fromName":"Mikael Magnusson","fromEmail":"mikachu@gmail.com","sentAt":"2009-03-20T12:53:20Z","receivedAt":"2009-03-20T12:53:20Z","isPatch":true,"sender":{"key":"mikachu@gmail.com","avatar":null},"body":"2009/3/20 Johannes Schindelin <Johannes.Schindelin@gmx.de>:\n> Hi,\n>\n> On Fri, 20 Mar 2009, Santi Béjar wrote:\n>\n>> 2009/3/20 Johannes Schindelin <Johannes.Schindelin@gmx.de>:\n>>\n>> > On Fri, 20 Mar 2009, Wincent Colaiuta wrote:\n>> >\n>> >> El 20/3/2009, a las 10:29, Johannes Schindelin escribió:\n>> >>\n>> >> >Often, it is quite interesting to inspect the branch tracked by a\n>> >> >given branch.  This patch introduces a nice notation to get at the\n>> >> >tracked branch: 'BEL<branch>' can be used to access that tracked\n>> >> >branch.\n>> >> >\n>> >> >A special shortcut 'BEL' refers to the branch tracked by the current\n>> >> >branch.\n>> >> >\n>> >> >Suggested by Pasky and Shawn.\n>> >>\n>> >> What does BEL actually stand for? I read Shawn's suggestion, but it's\n>> >> not immediately clear to me what \"BEL\" means.\n>> >\n>> > It is the ASCII \"bell\" character, 007 (I always wanted to write that\n>> > magic identifier into a patch).\n>> >\n>> > FWIW you could type it in a regular ANSI terminal using Control-v\n>> > Control-g.\n>>\n>> Can we use branch^{origin} instead? It is longer to type, but uses the\n>> same syntax as the ^{tree}, ^{commit}, ^{tag} and you don't have to know\n>> how to produce the bell character.\n>\n> I think I addressed that issue already.  (Summary: I do not like it)\n>\n> Let me spell it out if it was not obvious yet: the BEL patch was meant as\n> a more or less funny reminder that the issue is not solved and that I need\n> help.\n\nWould :%:foo work? I thought about the reserved prefix :/! , but :/!!\nisn't reserved so I don't think that would work. And it's pretty\nannoying to type too.\n\n-- \nMikael Magnusson\n"},{"id":"108710","messageId":"vpqy6v0ny3i.fsf@bauges.imag.fr","threadId":"18378","inReplyTo":"200903201345.23864.agruen@suse.de","subject":"Re: [PATCH v3] Introduce BEL<branch> as shortcut to the tracked branch","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2009-03-20T13:05:37Z","receivedAt":"2009-03-20T13:05:37Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Andreas Gruenbacher <agruen@suse.de> writes:\n\n> For me this defeats the purpose; I can just as well type origin/branch (or \n> whatever it is) instead of branch^{origin}.  I'm really looking for something \n> very short like % or %branch.\n\nI was thinking of ../branch (so, replace % with ../ in your patch,\nroughly). The cool thing is that my fingers are used to ../ already.\nThe bad things are 1) not sure the \"analogy\" with .. in filesystem is\ngood, and 2) this interacts badly with ref..branch. ref..%branch was\ncool, ref..../branch is less cool.\n\nOr is //branch an idea?\n\nMy 2 cents,\n\n-- \nMatthieu\n"},{"id":"108715","messageId":"alpine.DEB.1.00.0903201455130.6865@intel-tinevez-2-302","threadId":"18378","inReplyTo":"237967ef0903200553v58af40b5sfbfa0bbb1f9d96eb@mail.gmail.com","subject":"Re: [PATCH v3] Introduce BEL<branch> as shortcut to the tracked branch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-20T14:00:24Z","receivedAt":"2009-03-20T14:00:24Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 20 Mar 2009, Mikael Magnusson wrote:\n\n> 2009/3/20 Johannes Schindelin <Johannes.Schindelin@gmx.de>:\n>\n> > On Fri, 20 Mar 2009, Santi Béjar wrote:\n> >\n> >> 2009/3/20 Johannes Schindelin <Johannes.Schindelin@gmx.de>:\n> >>\n> >> > On Fri, 20 Mar 2009, Wincent Colaiuta wrote:\n> >> >\n> >> >> El 20/3/2009, a las 10:29, Johannes Schindelin escribió:\n> >> >>\n> >> >> >Often, it is quite interesting to inspect the branch tracked by a\n> >> >> >given branch.  This patch introduces a nice notation to get at the\n> >> >> >tracked branch: 'BEL<branch>' can be used to access that tracked\n> >> >> >branch.\n> >> >> >\n> >> >> >A special shortcut 'BEL' refers to the branch tracked by the current\n> >> >> >branch.\n> >> >> >\n> >> >> >Suggested by Pasky and Shawn.\n> >> >>\n> >> >> What does BEL actually stand for? I read Shawn's suggestion, but it's\n> >> >> not immediately clear to me what \"BEL\" means.\n> >> >\n> >> > It is the ASCII \"bell\" character, 007 (I always wanted to write that\n> >> > magic identifier into a patch).\n> >> >\n> >> > FWIW you could type it in a regular ANSI terminal using Control-v\n> >> > Control-g.\n> >>\n> >> Can we use branch^{origin} instead? It is longer to type, but uses the\n> >> same syntax as the ^{tree}, ^{commit}, ^{tag} and you don't have to know\n> >> how to produce the bell character.\n> >\n> > I think I addressed that issue already.  (Summary: I do not like it)\n> >\n> > Let me spell it out if it was not obvious yet: the BEL patch was meant as\n> > a more or less funny reminder that the issue is not solved and that I need\n> > help.\n> \n> Would :%:foo work? I thought about the reserved prefix :/! , but :/!! \n> isn't reserved so I don't think that would work. And it's pretty \n> annoying to type too.\n\nOr maybe :%foo?\n\nThat would have a rather nasty interaction with code I have in my tree to \nrefer to the cache-trees via ':<path>', but I guess I can live with that.\n\nCiao,\nDscho\n"},{"id":"108716","messageId":"49C3A513.9010206@drmicha.warpmail.net","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903201128380.10279@pacific.mpi-cbg.de","subject":"Re: [PATCH] Document and test the new % shotcut for the tracked branch","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-03-20T14:15:47Z","receivedAt":"2009-03-20T14:15:47Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Johannes Schindelin venit, vidit, dixit 20.03.2009 11:31:\n> Hi,\n> \n> On Fri, 20 Mar 2009, Michael J Gruber wrote:\n> \n>> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n>> ---\n> \n> That is brutal.  First shot, then cut.\n\nOh my gosh, noooow I got it! Better late than never. You really have a\nthing with typos... Although not quoting the subject was not fair ;)\n\nCheers,\nMichael\n"},{"id":"108720","messageId":"49C3A8D7.1040509@drmicha.warpmail.net","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903201255230.6865@intel-tinevez-2-302","subject":"Re: ref name troubles, was Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-03-20T14:31:51Z","receivedAt":"2009-03-20T14:31:51Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Johannes Schindelin venit, vidit, dixit 20.03.2009 12:57:\n> Hi,\n> \n> On Fri, 20 Mar 2009, Petr Baudis wrote:\n> \n>> On Fri, Mar 20, 2009 at 12:46:19PM +0100, Johannes Schindelin wrote:\n>>\n>>> On Fri, 20 Mar 2009, Petr Baudis wrote:\n>>>\n>>>> On Fri, Mar 20, 2009 at 10:30:29AM +0100, Johannes Schindelin wrote:\n>>>>> On Thu, 19 Mar 2009, Junio C Hamano wrote:\n>>>>>\n>>>>>> I think you are right.  It is just \"git branch\" and perhaps \"git\n>>>>>> update-ref\" are too loose in enforcing what can be created.\n>>>>>\n>>>>> \"git branch\" I agree with, but not \"git update-ref\".  As plumbing, the \n>>>>> latter should be much more allowing, feeding rope aplenty (but also \n>>>>> allowing cool tricks we do not think about yet).\n>>>>\n>>>> We shouldn't allow creating insane ref names even with update-ref. That\n>>>> way porcelains cannot rely on update-ref to sanity check the user's\n>>>> crap. At most, maybe you might want to bypass this check with some force\n>>>> switch, though I really can't quite imagine why.\n>>>\n>>> You really cannot imagine?  You, the author of filter-branch?  People _do_ \n>>> have fscked-up repositories, but they get really angry when they cannot \n>>> use rebase or filter-branch on them.\n>>\n>> They can rename the ref as the first step of a cleanup, can't they?\n> \n> Well, of course, we can make life hard on everybody.  That is quite \n> possible.\n> \n> But then, we can be nice, and at the same time fix the problem _properly_.\n> \n> IMHO a _warning_ should be the best thing.\n> \n> But all this does not solve _my_ problem: I'd like something as easy to \n> write as %next, but as unlikely to be used in existing refs as @{..}.\n\nDo we have ^ as a prefix yet?\nNeither the suffix (commit^) nor the infix (commit^{type}) allow an\nempty commit (for HEAD) - which might be nice, though. So, ^ as a prefix\nis free, even without any specifier after.\n\nAlso, I don't think people would use @@ much in branch names.\n\nMichael\n"},{"id":"108723","messageId":"alpine.DEB.1.00.0903201600500.6865@intel-tinevez-2-302","threadId":"18378","inReplyTo":"49C3A8D7.1040509@drmicha.warpmail.net","subject":"Re: ref name troubles, was Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-20T15:01:44Z","receivedAt":"2009-03-20T15:01:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 20 Mar 2009, Michael J Gruber wrote:\n\n> Do we have ^ as a prefix yet?\n\nYes, it means \"not\".  IOW '^bla blub' is the same as 'bla..blub'.\n\n> Also, I don't think people would use @@ much in branch names.\n\nWhoa...\n\nCiao,\nDscho\n"},{"id":"108726","messageId":"49C3B273.4080402@drmicha.warpmail.net","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903201600500.6865@intel-tinevez-2-302","subject":"Re: ref name troubles, was Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-03-20T15:12:51Z","receivedAt":"2009-03-20T15:12:51Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Johannes Schindelin venit, vidit, dixit 20.03.2009 16:01:\n> Hi,\n> \n> On Fri, 20 Mar 2009, Michael J Gruber wrote:\n> \n>> Do we have ^ as a prefix yet?\n> \n> Yes, it means \"not\".  IOW '^bla blub' is the same as 'bla..blub'.\n\nOh yes, I forgot. commit specifiers and ranges are in different sections\nin git-rev-parse.1.\n\n>> Also, I don't think people would use @@ much in branch names.\n> \n> Whoa...\n\nWe already have ^! and ^@ (I didn't know).\n\nWhile someone may have a branch like \"@junio\" I think doubled special\ncharacters are uncommon. Except for that topic branch /&$%$%§$%&/) for a\nreally nasty bug.\n\nOf course, if @@ refers to a tracked branch which follows another\nbranch, then @@@@...\n\nMichael\n"},{"id":"108729","messageId":"alpine.DEB.1.00.0903201714020.10279@pacific.mpi-cbg.de","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903201027450.10279@pacific.mpi-cbg.de","subject":"[PATCH v4] Introduce %<branch> as shortcut to the tracked branch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-20T16:17:01Z","receivedAt":"2009-03-20T16:17:01Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nOften, it is quite interesting to inspect the branch tracked by a given\nbranch.  This patch introduces a nice notation to get at the tracked\nbranch: '%<branch>' can be used to access that tracked branch.\n\nA special shortcut '%' refers to the branch tracked by the current branch.\n\nSuggested by Pasky.\n\nEven if a branch name can legally start with a '%' sign, we can use the\nspecial character '%' here, as you can always specify the full ref:\nrefs/heads/%my-branch (pointed out by doener on IRC).\n\nThis patch extends the function introduced to handle the nth-last branch\n(via the {-<n>} notation); therefore that function name was renamed to\nsomething more general.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tSometimes IRC is awesome.  Knowing that you can always access an\n\totherwise-hidden branch using the full name, I am now fully\n\tcomfortable with '%[<branch>]'.\n\n Documentation/git-rev-parse.txt |    3 ++\n sha1_name.c                     |   21 ++++++++++++---\n t/t1506-rev-parse-tracked.sh    |   54 +++++++++++++++++++++++++++++++++++++++\n 3 files changed, 74 insertions(+), 4 deletions(-)\n create mode 100755 t/t1506-rev-parse-tracked.sh\n\ndiff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt\nindex 5ed2bc8..a4bcd5e 100644\n--- a/Documentation/git-rev-parse.txt\n+++ b/Documentation/git-rev-parse.txt\n@@ -215,6 +215,9 @@ when you run 'git-merge'.\n * The special construct '@\\{-<n>\\}' means the <n>th branch checked out\n   before the current one.\n \n+* The prefix '%' to a ref means the branch tracked by that ref.  If no\n+  ref was specified, it means the branch tracked by the current branch.\n+\n * A suffix '{caret}' to a revision parameter means the first parent of\n   that commit object.  '{caret}<n>' means the <n>th parent (i.e.\n   'rev{caret}'\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 2f75179..cb4168d 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -5,6 +5,7 @@\n #include \"blob.h\"\n #include \"tree-walk.h\"\n #include \"refs.h\"\n+#include \"remote.h\"\n \n static int find_short_object_filename(int len, const char *name, unsigned char *sha1)\n {\n@@ -240,9 +241,10 @@ static int ambiguous_path(const char *path, int len)\n \n /*\n  * *string and *len will only be substituted, and *string returned (for\n- * later free()ing) if the string passed in is of the form @{-<n>}.\n+ * later free()ing) if the string passed in is of the form @{-<n>} or\n+ * of the form %<branch>.\n  */\n-static char *substitute_nth_last_branch(const char **string, int *len)\n+static char *substitute_branch(const char **string, int *len)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \tint ret = interpret_nth_last_branch(*string, &buf);\n@@ -254,12 +256,23 @@ static char *substitute_nth_last_branch(const char **string, int *len)\n \t\treturn (char *)*string;\n \t}\n \n+\tif (**string == '%') {\n+\t\tstruct branch *tracking = branch_get((*string)[1] ?\n+\t\t\t(*string) + 1 : NULL);\n+\n+\t\tif (tracking->merge && tracking->merge[0]->dst) {\n+\t\t\t*string = xstrdup(tracking->merge[0]->dst);\n+\t\t\t*len = strlen(*string);\n+\t\t\treturn (char *)*string;\n+\t\t}\n+\t}\n+\n \treturn NULL;\n }\n \n int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)\n {\n-\tchar *last_branch = substitute_nth_last_branch(&str, &len);\n+\tchar *last_branch = substitute_branch(&str, &len);\n \tconst char **p, *r;\n \tint refs_found = 0;\n \n@@ -288,7 +301,7 @@ int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)\n \n int dwim_log(const char *str, int len, unsigned char *sha1, char **log)\n {\n-\tchar *last_branch = substitute_nth_last_branch(&str, &len);\n+\tchar *last_branch = substitute_branch(&str, &len);\n \tconst char **p;\n \tint logs_found = 0;\n \ndiff --git a/t/t1506-rev-parse-tracked.sh b/t/t1506-rev-parse-tracked.sh\nnew file mode 100755\nindex 0000000..359f648\n--- /dev/null\n+++ b/t/t1506-rev-parse-tracked.sh\n@@ -0,0 +1,54 @@\n+#!/bin/sh\n+\n+test_description='test %<branch> syntax'\n+\n+. ./test-lib.sh\n+\n+\n+test_expect_success 'setup' '\n+\n+\ttest_commit 1 &&\n+\tgit checkout -b side &&\n+\ttest_commit 2 &&\n+\tgit checkout master &&\n+\tgit clone . clone &&\n+\ttest_commit 3 &&\n+\t(cd clone &&\n+\t test_commit 4 &&\n+\t git branch --track my-side origin/side)\n+\n+'\n+\n+full_name () {\n+\t(cd clone &&\n+\t git rev-parse --symbolic-full-name \"$@\")\n+}\n+\n+commit_subject () {\n+\t(cd clone &&\n+\t git show -s --pretty=format:%s \"$@\")\n+}\n+\n+test_expect_success '% resolves to correct full name' '\n+\n+\ttest refs/remotes/origin/master = \"$(full_name %)\"\n+\n+'\n+\n+test_expect_success '%my-side resolves to correct full name' '\n+\n+\ttest refs/remotes/origin/side = \"$(full_name %my-side)\"\n+\n+'\n+\n+test_expect_success '%my-side resolves to correct commit' '\n+\n+\tgit checkout side &&\n+\ttest_commit 5 &&\n+\t(cd clone && git fetch) &&\n+\ttest 2 = \"$(commit_subject my-side)\" &&\n+\ttest 5 = \"$(commit_subject %my-side)\"\n+\n+'\n+\n+test_done\n-- \n1.6.2.1.477.g74567\n"},{"id":"108734","messageId":"7vbprwi1ju.fsf@gitster.siamese.dyndns.org","threadId":"18378","inReplyTo":"20090320111238.GZ8940@machine.or.cz","subject":"Re: ref name troubles, was Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-20T16:47:33Z","receivedAt":"2009-03-20T16:47:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Petr Baudis <pasky@suse.cz> writes:\n\n>> \"git branch\" I agree with, but not \"git update-ref\".  As plumbing, the \n>> latter should be much more allowing, feeding rope aplenty (but also \n>> allowing cool tricks we do not think about yet).\n>\n> We shouldn't allow creating insane ref names even with update-ref. That\n> way porcelains cannot rely on update-ref to sanity check the user's\n> crap. At most, maybe you might want to bypass this check with some force\n> switch, though I really can't quite imagine why.\n\nThat's all nice and clean in theory, but it was more or less the same\nreasoning as what was behind the tightening not to allow anything but\nrefs/heads pointed by HEAD, but you know what fell out of it.  \"Insane\"\nand \"crap\" are in the eye of the beholder.\n"},{"id":"108735","messageId":"7v7i2ki0sw.fsf@gitster.siamese.dyndns.org","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903201714020.10279@pacific.mpi-cbg.de","subject":"Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-20T17:03:43Z","receivedAt":"2009-03-20T17:03:43Z","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> Often, it is quite interesting to inspect the branch tracked by a given\n> branch.  This patch introduces a nice notation to get at the tracked\n> branch: '%<branch>' can be used to access that tracked branch.\n>\n> A special shortcut '%' refers to the branch tracked by the current branch.\n>\n> Suggested by Pasky.\n>\n> Even if a branch name can legally start with a '%' sign, we can use the\n> special character '%' here, as you can always specify the full ref:\n> refs/heads/%my-branch (pointed out by doener on IRC).\n\nThat is not a good argument, as %<name> is (just like name@{-n} is) a\nsubstitute way to spell the \"name\" of a branch, not just a random SHA-1,\nand to some commands it makes a difference between <branchname> and\nrefs/heads/<branchname>.  The latter is not giving the name of the branch,\nbut merely a commit object name.\n\nAn most obvious one is that \"git checkout branchname\" and \"git checkout\nrefs/heads/branchname\" behave differently.  You cannot checkout a branch\ncalled %master after this patch goes in.\n\nJust be honest and say \"You may have a branch whose name begins with a '%'\nand you cannot refer to it anymore in certain contexts.  Too bad.  Don't\ndo it next time you create a new branch\".  I _can_ buy that argument.\n\nIt however asks for a sane escape hatch.  You cannot \"fix\" such branch\nnames in most obvious ways (if you could, that would be a bug in this %\nfeature).\n\n (1) git branch -m %master percent-master\n\n     We would end up renaming what master tracks to new name.\n\n (2) git branch percent-master refs/heads/%master; git branch -d %master\n\n     The first part is a good try, but the latter deletes what master\n     tracks.\n\n\"git update-ref -d refs/heads/%master\" needs to replace the second step of\nthe latter.\n"},{"id":"108736","messageId":"20090320170814.GB24968@atjola.homenet","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903201714020.10279@pacific.mpi-cbg.de","subject":"Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-03-20T17:08:14Z","receivedAt":"2009-03-20T17:08:14Z","isPatch":true,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2009.03.20 17:17:01 +0100, Johannes Schindelin wrote:\n> Even if a branch name can legally start with a '%' sign, we can use the\n> special character '%' here, as you can always specify the full ref:\n> refs/heads/%my-branch (pointed out by doener on IRC).\n\nHm, I just recalled that \"git checkout\" doesn't \"like\" anything but the\nshortname for a branch, with refs/heads/master or heads/master, you get\na detached HEAD. Though at least when reading the doc, that seems like a\nbug to me. The man page says:\n\n    When this parameter names a non-branch (but still a valid commit\n    object), your HEAD becomes detached.\n\nAnd of course refs/heads/master names a branch. Is it\nexpected/intended that checkout detaches HEAD anyway when given a full\nref name?\n\nBjörn\n"},{"id":"108740","messageId":"alpine.DEB.1.00.0903201831420.6865@intel-tinevez-2-302","threadId":"18378","inReplyTo":"7v7i2ki0sw.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-20T17:32:25Z","receivedAt":"2009-03-20T17:32:25Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 20 Mar 2009, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > Often, it is quite interesting to inspect the branch tracked by a given\n> > branch.  This patch introduces a nice notation to get at the tracked\n> > branch: '%<branch>' can be used to access that tracked branch.\n> >\n> > A special shortcut '%' refers to the branch tracked by the current branch.\n> >\n> > Suggested by Pasky.\n> >\n> > Even if a branch name can legally start with a '%' sign, we can use the\n> > special character '%' here, as you can always specify the full ref:\n> > refs/heads/%my-branch (pointed out by doener on IRC).\n> \n> That is not a good argument, as %<name> is (just like name@{-n} is) a\n> substitute way to spell the \"name\" of a branch, not just a random SHA-1,\n> and to some commands it makes a difference between <branchname> and\n> refs/heads/<branchname>.  The latter is not giving the name of the branch,\n> but merely a commit object name.\n> \n> An most obvious one is that \"git checkout branchname\" and \"git checkout\n> refs/heads/branchname\" behave differently.  You cannot checkout a branch\n> called %master after this patch goes in.\n> \n> Just be honest and say \"You may have a branch whose name begins with a '%'\n> and you cannot refer to it anymore in certain contexts.  Too bad.  Don't\n> do it next time you create a new branch\".  I _can_ buy that argument.\n\nBe that as it may, at this point I kick the ball back to the interested \nparties.  I did my duty.\n\nCiao,\nDscho\n"},{"id":"108742","messageId":"7vwsakgjie.fsf@gitster.siamese.dyndns.org","threadId":"18378","inReplyTo":"7v7i2ki0sw.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-20T18:02:33Z","receivedAt":"2009-03-20T18:02:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Just be honest and say \"You may have a branch whose name begins with a '%'\n> and you cannot refer to it anymore in certain contexts.  Too bad.  Don't\n> do it next time you create a new branch\".  I _can_ buy that argument.\n>\n> It however asks for a sane escape hatch.  You cannot \"fix\" such branch\n> names in most obvious ways (if you could, that would be a bug in this %\n> feature).\n>\n>  (1) git branch -m %master percent-master\n>\n>      We would end up renaming what master tracks to new name.\n>\n>  (2) git branch percent-master refs/heads/%master; git branch -d %master\n>\n>      The first part is a good try, but the latter deletes what master\n>      tracks.\n>\n> \"git update-ref -d refs/heads/%master\" needs to replace the second step of\n> the latter.\n\nA naïve question.\n\nHas nobody suggested to use a really illegal characters such as ':'\ninstead?  After all, we are not talking something that you can use in\nrefspecs but another way to spell branch names.\n\nAlternatively, '~master' may have a nice connotation that means \"where\nmaster calls its home\".\n\nI haven't looked at the patch deeply yet, but what does the failure case\ndo?  I think we should die() if %master is asked for and master is not\nmerging from anywhere by default (similarly, if @{-4} is asked and we\nhaven't switched that many times, we should die(), although I do not\nremember how I coded that codepath---I presume it's the same codepath you\nare touching with this round).\n"},{"id":"108749","messageId":"alpine.LNX.1.00.0903201515490.19665@iabervon.org","threadId":"18378","inReplyTo":"7vbprwi1ju.fsf@gitster.siamese.dyndns.org","subject":"Re: ref name troubles, was Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2009-03-20T19:34:43Z","receivedAt":"2009-03-20T19:34:43Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Fri, 20 Mar 2009, Junio C Hamano wrote:\n\n> Petr Baudis <pasky@suse.cz> writes:\n> \n> >> \"git branch\" I agree with, but not \"git update-ref\".  As plumbing, the \n> >> latter should be much more allowing, feeding rope aplenty (but also \n> >> allowing cool tricks we do not think about yet).\n> >\n> > We shouldn't allow creating insane ref names even with update-ref. That\n> > way porcelains cannot rely on update-ref to sanity check the user's\n> > crap. At most, maybe you might want to bypass this check with some force\n> > switch, though I really can't quite imagine why.\n> \n> That's all nice and clean in theory, but it was more or less the same\n> reasoning as what was behind the tightening not to allow anything but\n> refs/heads pointed by HEAD, but you know what fell out of it.  \"Insane\"\n> and \"crap\" are in the eye of the beholder.\n\nI think there's no possible use to being able to use update-ref to create \na ref that rev-parse can't be made to read. I think people will want to do \nall sorts of things that are insane (I'd personally like some refs with \nthe basename \"...\"), but they're only likely to do insane things that \nhappen to work, rather than insane things that aren't prevented but still \ndon't work.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"108750","messageId":"20090320193650.GA26934@coredump.intra.peff.net","threadId":"18378","inReplyTo":"7vwsakgjie.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-03-20T19:36:50Z","receivedAt":"2009-03-20T19:36:50Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Mar 20, 2009 at 11:02:33AM -0700, Junio C Hamano wrote:\n\n> A naïve question.\n> \n> Has nobody suggested to use a really illegal characters such as ':'\n> instead?  After all, we are not talking something that you can use in\n> refspecs but another way to spell branch names.\n\nBut if this goes into dwim_ref, then won't it be usable for refspecs? Or\neven if it isn't, then imagine the user who doesn't know this and types\n\n  git push :foo\n\nunwittingly deleting the remote \"foo\".\n\nYes, that is unlikely (since why would they push the tracking branch of\nfoo?), but I don't think it makes sense to argue that it doesn't have\nconfusing (and potentially dangerous) consequenses.\n\n> Alternatively, '~master' may have a nice connotation that means \"where\n> master calls its home\".\n\nI think that is quite clever and doesn't have any meaning for a revision\nspecifier already. I like it.\n\n-Peff\n"},{"id":"108758","messageId":"alpine.LNX.2.00.0903202022560.12211@reaper.quantumfyre.co.uk","threadId":"18378","inReplyTo":"20090320193650.GA26934@coredump.intra.peff.net","subject":"Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch","fromName":"Julian Phillips","fromEmail":"julian@quantumfyre.co.uk","sentAt":"2009-03-20T20:28:28Z","receivedAt":"2009-03-20T20:28:28Z","isPatch":true,"sender":{"key":"julian@quantumfyre.co.uk","avatar":"https://avatars.githubusercontent.com/u/948888?v=4"},"body":"On Fri, 20 Mar 2009, Jeff King wrote:\n\n> On Fri, Mar 20, 2009 at 11:02:33AM -0700, Junio C Hamano wrote:\n>\n>> A na?ve question.\n>>\n>> Has nobody suggested to use a really illegal characters such as ':'\n>> instead?  After all, we are not talking something that you can use in\n>> refspecs but another way to spell branch names.\n>\n> But if this goes into dwim_ref, then won't it be usable for refspecs? Or\n> even if it isn't, then imagine the user who doesn't know this and types\n>\n>  git push :foo\n>\n> unwittingly deleting the remote \"foo\".\n>\n> Yes, that is unlikely (since why would they push the tracking branch of\n> foo?), but I don't think it makes sense to argue that it doesn't have\n> confusing (and potentially dangerous) consequenses.\n>\n>> Alternatively, '~master' may have a nice connotation that means \"where\n>> master calls its home\".\n>\n> I think that is quite clever and doesn't have any meaning for a revision\n> specifier already. I like it.\n\nI considered suggesting this earlier, but didn't as the behaviour is not \nconsistent.  If you have a user named master then you have to type \n'~master' (including quotes), if you don't you can type ~master, and you \nalways have to type '~' instead of ~.  I didn't particularly fancy typing \nall those quotes, and certainly not explaining the behaviour to people not \noverly familiar with unix shell behaviour.\n\n-- \nJulian\n\n  ---\nIt's very inconvenient to be mortal -- you never know when everything may\nsuddenly stop happening.\n"},{"id":"108761","messageId":"20090320205027.GA28804@coredump.intra.peff.net","threadId":"18378","inReplyTo":"alpine.LNX.2.00.0903202022560.12211@reaper.quantumfyre.co.uk","subject":"Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-03-20T20:50:27Z","receivedAt":"2009-03-20T20:50:27Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Mar 20, 2009 at 08:28:28PM +0000, Julian Phillips wrote:\n\n>> I think that is quite clever and doesn't have any meaning for a revision\n>> specifier already. I like it.\n>\n> I considered suggesting this earlier, but didn't as the behaviour is not  \n> consistent.  If you have a user named master then you have to type  \n> '~master' (including quotes), if you don't you can type ~master, and you  \n> always have to type '~' instead of ~.  I didn't particularly fancy typing  \n> all those quotes, and certainly not explaining the behaviour to people not \n> overly familiar with unix shell behaviour.\n\nOh, good point. I wasn't thinking it through. My initial thought was\nthat there is no problem conflicting with a file ~master/foo, since you\ngenerally don't want to use absolute paths that are likely outside your\ngit repository. But of course the shell doesn't know this and will screw\nyou, which I failed to consider.\n\n-Peff\n"},{"id":"108763","messageId":"alpine.DEB.1.00.0903202246060.6865@intel-tinevez-2-302","threadId":"18378","inReplyTo":"alpine.LNX.1.00.0903201515490.19665@iabervon.org","subject":"Re: ref name troubles, was Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-20T21:48:16Z","receivedAt":"2009-03-20T21:48:16Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 20 Mar 2009, Daniel Barkalow wrote:\n\n> On Fri, 20 Mar 2009, Junio C Hamano wrote:\n> \n> > Petr Baudis <pasky@suse.cz> writes:\n> > \n> > >> \"git branch\" I agree with, but not \"git update-ref\".  As plumbing, \n> > >> the latter should be much more allowing, feeding rope aplenty (but \n> > >> also allowing cool tricks we do not think about yet).\n> > >\n> > > We shouldn't allow creating insane ref names even with update-ref. \n> > > That way porcelains cannot rely on update-ref to sanity check the \n> > > user's crap. At most, maybe you might want to bypass this check with \n> > > some force switch, though I really can't quite imagine why.\n> > \n> > That's all nice and clean in theory, but it was more or less the same \n> > reasoning as what was behind the tightening not to allow anything but \n> > refs/heads pointed by HEAD, but you know what fell out of it.  \n> > \"Insane\" and \"crap\" are in the eye of the beholder.\n> \n> I think there's no possible use to being able to use update-ref to \n> create a ref that rev-parse can't be made to read. I think people will \n> want to do all sorts of things that are insane (I'd personally like some \n> refs with the basename \"...\"), but they're only likely to do insane \n> things that happen to work, rather than insane things that aren't \n> prevented but still don't work.\n\nOf course, you are forgetting that rev-parse may well have been able to \ngrok such a ref at some stage.\n\nAnd at that stage, it becomes not a user error, but a _huge_ mistake by \nus, the Git developers.\n\nDon't blame the user \n(http://www.schneier.com/blog/archives/2009/03/it_security_bla.html).\n\nCiao,\nDscho\n"},{"id":"108771","messageId":"alpine.LNX.2.00.0903202300330.13726@reaper.quantumfyre.co.uk","threadId":"18378","inReplyTo":"7v7i2ki0sw.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch","fromName":"Julian Phillips","fromEmail":"julian@quantumfyre.co.uk","sentAt":"2009-03-20T23:08:42Z","receivedAt":"2009-03-20T23:08:42Z","isPatch":true,"sender":{"key":"julian@quantumfyre.co.uk","avatar":"https://avatars.githubusercontent.com/u/948888?v=4"},"body":"On Fri, 20 Mar 2009, Junio C Hamano wrote:\n\n> An most obvious one is that \"git checkout branchname\" and \"git checkout\n> refs/heads/branchname\" behave differently.  You cannot checkout a branch\n> called %master after this patch goes in.\n>\n> Just be honest and say \"You may have a branch whose name begins with a '%'\n> and you cannot refer to it anymore in certain contexts.  Too bad.  Don't\n> do it next time you create a new branch\".  I _can_ buy that argument.\n>\n> It however asks for a sane escape hatch.  You cannot \"fix\" such branch\n> names in most obvious ways (if you could, that would be a bug in this %\n> feature).\n>\n> (1) git branch -m %master percent-master\n>\n>     We would end up renaming what master tracks to new name.\n>\n> (2) git branch percent-master refs/heads/%master; git branch -d %master\n>\n>     The first part is a good try, but the latter deletes what master\n>     tracks.\n\nHow about adding a generic escape hatch, that would cover this and \nfuture extensions?\n\nLet a ref that starts with a single quote be taken as given and not \nprocessed.  You have to escape it to get it past the shell, but that makes \nit rather unlikely that anyone has used a name that starts with a quote - \nand if they have you can still use this mechanism to rename it.\n\nSo now (1) above could be written:\n\n  git branch -m \"'%master\" percent-master\n\nand other commands, such as\n\n  git branch -d \"'%master\"\n\nor\n\n  git checkout \"'%master\"\n\nwould also do the right thing (i.e. use refs/heads/%master as a branch).\n\n-- \nJulian\n\n  ---\nStewie Griffin:  [looking in the fridge for a drink] Soda... purple stuff... Sunny D, all right!\n"},{"id":"108772","messageId":"fabb9a1e0903201620l456bfc39n2422dcb1e738eb37@mail.gmail.com","threadId":"18378","inReplyTo":"alpine.LNX.2.00.0903202300330.13726@reaper.quantumfyre.co.uk","subject":"Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-03-20T23:20:21Z","receivedAt":"2009-03-20T23:20:21Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Sat, Mar 21, 2009 at 00:08, Julian Phillips <julian@quantumfyre.co.uk> wrote:\n>  git branch -m \"'%master\" percent-master\n\nWhich kinda defeats the purpose of having a short-and-easy-to-write\nrefname, no? \"'%master\" is not that easy to type, I at least get my\nfingers mixed up in the \"'% sequence. Perhaps we should reserve these\nspecial characters now, and deprecate their use? Junio seemed to be\nopen to that (quoted below)...\n\n> Just be honest and say \"You may have a branch whose name begins with a '%'\n> and you cannot refer to it anymore in certain contexts.  Too bad.  Don't\n> do it next time you create a new branch\".  I _can_ buy that argument.\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"108773","messageId":"alpine.LNX.2.00.0903202324170.13726@reaper.quantumfyre.co.uk","threadId":"18378","inReplyTo":"fabb9a1e0903201620l456bfc39n2422dcb1e738eb37@mail.gmail.com","subject":"Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch","fromName":"Julian Phillips","fromEmail":"julian@quantumfyre.co.uk","sentAt":"2009-03-20T23:41:04Z","receivedAt":"2009-03-20T23:41:04Z","isPatch":true,"sender":{"key":"julian@quantumfyre.co.uk","avatar":"https://avatars.githubusercontent.com/u/948888?v=4"},"body":"On Sat, 21 Mar 2009, Sverre Rabbelier wrote:\n\n> Heya,\n>\n> On Sat, Mar 21, 2009 at 00:08, Julian Phillips <julian@quantumfyre.co.uk> wrote:\n>>  git branch -m \"'%master\" percent-master\n>\n> Which kinda defeats the purpose of having a short-and-easy-to-write\n> refname, no? \"'%master\" is not that easy to type, I at least get my\n> fingers mixed up in the \"'% sequence. Perhaps we should reserve these\n> special characters now, and deprecate their use? Junio seemed to be\n> open to that (quoted below)...\n\nBut it's not supposed to be easy to type ...\n\nTo use the new syntax you type %master only.  What I was proposing was a \nway to get at the branch that you had before the wizzy new feature was \nadded.  Something you only do once to rename it - why waste an easy to \ntype sequence on that?\n\nI agree that adding some more reserved characters is a reasonable way \nforward - but I think a way should be provided for people who are \n_already_ using those characters to rename their branches to something that \navoids those characters in a simple (but not necessarily easy to type) \nway.\n\n-- \nJulian\n\n  ---\npanic(\"%s: CORRUPTED BTREE OR SOMETHING\", __FUNCTION__);\n         linux-2.6.6/fs/xfs/xfs_bmap.c\n"},{"id":"108774","messageId":"fabb9a1e0903201645n29256fbav7fc0bde4c5cc05e7@mail.gmail.com","threadId":"18378","inReplyTo":"alpine.LNX.2.00.0903202324170.13726@reaper.quantumfyre.co.uk","subject":"Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-03-20T23:45:03Z","receivedAt":"2009-03-20T23:45:03Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Sat, Mar 21, 2009 at 00:41, Julian Phillips <julian@quantumfyre.co.uk> wrote:\n> To use the new syntax you type %master only.  What I was proposing was a way\n> to get at the branch that you had before the wizzy new feature was added.\n>  Something you only do once to rename it - why waste an easy to type\n> sequence on that?\n\nOooooh, sorry, I totally understood your suggestion the wrong way\naround! In that case, I like it! :)\n\n> I agree that adding some more reserved characters is a reasonable way\n> forward - but I think a way should be provided for people who are _already_\n> using those characters to rename their branches to something that avoids\n> those characters in a simple (but not necessarily easy to type) way.\n\nYour suggestion on how to escape the DWIMery sounds sane to me :).\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"108775","messageId":"200903210135.33729.agruen@suse.de","threadId":"18378","inReplyTo":"alpine.LNX.2.00.0903202300330.13726@reaper.quantumfyre.co.uk","subject":"Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch","fromName":"Andreas Gruenbacher","fromEmail":"agruen@suse.de","sentAt":"2009-03-21T00:35:33Z","receivedAt":"2009-03-21T00:35:33Z","isPatch":true,"sender":{"key":"agruen@suse.de","avatar":null},"body":"On Saturday, 21 March 2009 0:08:42 Julian Phillips wrote:\n> How about adding a generic escape hatch, that would cover this and\n> future extensions?\n>\n> Let a ref that starts with a single quote be taken as given and not\n> processed.  You have to escape it to get it past the shell, but that makes\n> it rather unlikely that anyone has used a name that starts with a quote -\n> and if they have you can still use this mechanism to rename it.\n\nTo me the most obvious escape sequence would be \\x for disabling whatever \nspecial meaning x has (for non-alphabetic x). With quoting you likely \neventually end up needing  \\' in some cases anyway...\n\nAndreas\n"},{"id":"108776","messageId":"87zlff8yuf.fsf@catnip.gol.com","threadId":"18378","inReplyTo":"200903210135.33729.agruen@suse.de","subject":"Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch","fromName":"Miles Bader","fromEmail":"miles@gnu.org","sentAt":"2009-03-21T01:10:48Z","receivedAt":"2009-03-21T01:10:48Z","isPatch":true,"sender":{"key":"miles@gnu.org","avatar":"https://gravatar.com/avatar/01069b69593af7bff28e2f97afeb3644ae6fe2f5f56cb3a8cf34c5fb8c36efe5?d=mp&s=160"},"body":"Andreas Gruenbacher <agruen@suse.de> writes:\n> To me the most obvious escape sequence would be \\x for disabling whatever \n> special meaning x has (for non-alphabetic x). With quoting you likely \n> eventually end up needing  \\' in some cases anyway...\n\nI think it's a good idea to _avoid_ using backslash as an escape when\npossible -- the potential for confusion and screwups from multiple\nlayers all interpreting backslash should be familiar to most people\nhere...  (single-quote suffers from the same problem a bit, but at least\nit's not quite as overused as backslash)\n\n-Miles\n\n-- \nOne of the lessons of history is that nothing is often a good thing to\ndo, and always a clever thing to say.  -- Will Durant\n"},{"id":"108793","messageId":"alpine.LNX.2.00.0903211323010.20272@reaper.quantumfyre.co.uk","threadId":"18378","inReplyTo":"200903210135.33729.agruen@suse.de","subject":"Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch","fromName":"Julian Phillips","fromEmail":"julian@quantumfyre.co.uk","sentAt":"2009-03-21T13:24:33Z","receivedAt":"2009-03-21T13:24:33Z","isPatch":true,"sender":{"key":"julian@quantumfyre.co.uk","avatar":"https://avatars.githubusercontent.com/u/948888?v=4"},"body":"On Sat, 21 Mar 2009, Andreas Gruenbacher wrote:\n\n> On Saturday, 21 March 2009 0:08:42 Julian Phillips wrote:\n>> How about adding a generic escape hatch, that would cover this and\n>> future extensions?\n>>\n>> Let a ref that starts with a single quote be taken as given and not\n>> processed.  You have to escape it to get it past the shell, but that makes\n>> it rather unlikely that anyone has used a name that starts with a quote -\n>> and if they have you can still use this mechanism to rename it.\n>\n> To me the most obvious escape sequence would be \\x for disabling whatever\n> special meaning x has (for non-alphabetic x). With quoting you likely\n> eventually end up needing  \\' in some cases anyway...\n\nExcept that \\ is the escape character for the shell too ... and that can \nget very confusing.  Haven't you ever spent too long trying to figure out \nhow many \\s you needed to get the command to work properly?\n\n-- \nJulian\n\n  ---\nI'm still waiting for the advent of the computer science groupie.\n"},{"id":"108794","messageId":"alpine.LNX.2.00.0903211326390.20324@reaper.quantumfyre.co.uk","threadId":"18378","inReplyTo":"alpine.LNX.2.00.0903211323010.20272@reaper.quantumfyre.co.uk","subject":"Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch","fromName":"Julian Phillips","fromEmail":"julian@quantumfyre.co.uk","sentAt":"2009-03-21T13:28:00Z","receivedAt":"2009-03-21T13:28:00Z","isPatch":true,"sender":{"key":"julian@quantumfyre.co.uk","avatar":"https://avatars.githubusercontent.com/u/948888?v=4"},"body":"On Sat, 21 Mar 2009, Julian Phillips wrote:\n\n> On Sat, 21 Mar 2009, Andreas Gruenbacher wrote:\n>\n>>  On Saturday, 21 March 2009 0:08:42 Julian Phillips wrote:\n>> >  How about adding a generic escape hatch, that would cover this and\n>> >  future extensions?\n>> > \n>> >  Let a ref that starts with a single quote be taken as given and not\n>> >  processed.  You have to escape it to get it past the shell, but that \n>> >  makes\n>> >  it rather unlikely that anyone has used a name that starts with a quote \n>> >  -\n>> >  and if they have you can still use this mechanism to rename it.\n>>\n>>  To me the most obvious escape sequence would be \\x for disabling whatever\n>>  special meaning x has (for non-alphabetic x). With quoting you likely\n>>  eventually end up needing  \\' in some cases anyway...\n>\n> Except that \\ is the escape character for the shell too ... and that can get \n> very confusing.  Haven't you ever spent too long trying to figure out how \n> many \\s you needed to get the command to work properly?\n\nHaving said that, the actual character used doesn't really matter.  That's \njust a what colour do you want your shed type detail ...\n\n-- \nJulian\n\n  ---\nBOFH Excuse #118:\n\nthe router thinks its a printer.\n"},{"id":"108812","messageId":"7vab7eegls.fsf@gitster.siamese.dyndns.org","threadId":"18378","inReplyTo":"20090320004029.GX23521@spearce.org","subject":"Re: ref name troubles, was Re: [PATCH v2] Introduce %<branch> as shortcut to the tracked branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-21T21:00:31Z","receivedAt":"2009-03-21T21:00:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n>> On Fri, 20 Mar 2009, Johannes Schindelin wrote:\n>> \n>> > Just try this:\n>> > \n>> > \t$ git checkout -b %helloworld\n>> \n>> It gets worse.  Much worse.\n>> \n>> Try this (triggered by a comment by Ilari on IRC):\n>> \n>> \t$ git checkout -b '@{1}'\n>> \n>> That _works_! WTH?\n>\n> '@' is not reserved.  Neither is '{' or '}'.  Neither is\n> the combination.\n>\n> Waaaaaay back when I added reflog query syntax I tried to use only\n> '@', people with branch names like 'foo@bar' made a point that they\n> didn't want to reserve it.  We stuck the {} in as a \"highly unlikely\n> to conflict with a branch name\" and others pointed out most shells\n> will do fun things with those, but we kept it to avoid ambiguous\n> meanings of \"foo@noon\" when foo@noon is already a branch.\n\nLet's do something along this line.\n\n-- >8 --\nSubject: [PATCH] check_ref_format(): tighten refname rules\n\nYes, I know that tightening rules retroactively is bad, but this changes\nthe rules for refnames to forbid:\n\n (1) a refname that ends with a dot.\n\n     We already reject a path component that begins with a dot, primarily\n     to avoid ambiguous range interpretation.  If we allowed \".B\" as a\n     valid ref, it is unclear if \"A...B\" means \"in dot-B but not in A\" or\n     \"either in A or B but not in both\".\n\n     But for this to be complete, we need also to forbid \"A.\" to avoid \"in\n     B but not in A-dot\".  This was not a problem in the original range\n     notation, but we should have added this restriction when three-dot\n     notation was introduced.\n\n     Unlike \"no dot at the beginning of any path component\" rule, this\n     rule does not have to be \"no dot at the end of any path component\",\n     because you cannot abbreviate the tail end away, similar to you can\n     say \"dot-B\" to mean \"refs/heads/dot-B\".\n\n (2) a refname that contains \"@{\" in it.\n\n     Some people and foreign SCM converter may have named their branches\n     as frotz@243 and we still want to keep supporting it, but \"git branch\n     @{1}\" is a disaster.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n refs.c |   12 ++++++++----\n 1 files changed, 8 insertions(+), 4 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 8d3c502..abd5623 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -693,7 +693,7 @@ static inline int bad_ref_char(int ch)\n \n int check_ref_format(const char *ref)\n {\n-\tint ch, level, bad_type;\n+\tint ch, level, bad_type, last;\n \tint ret = CHECK_REF_FORMAT_OK;\n \tconst char *cp = ref;\n \n@@ -717,19 +717,23 @@ int check_ref_format(const char *ref)\n \t\t\t\treturn CHECK_REF_FORMAT_ERROR;\n \t\t}\n \n+\t\tlast = ch;\n \t\t/* scan the rest of the path component */\n \t\twhile ((ch = *cp++) != 0) {\n \t\t\tbad_type = bad_ref_char(ch);\n-\t\t\tif (bad_type) {\n+\t\t\tif (bad_type)\n \t\t\t\treturn CHECK_REF_FORMAT_ERROR;\n-\t\t\t}\n \t\t\tif (ch == '/')\n \t\t\t\tbreak;\n-\t\t\tif (ch == '.' && *cp == '.')\n+\t\t\tif (last == '.' && ch == '.')\n+\t\t\t\treturn CHECK_REF_FORMAT_ERROR;\n+\t\t\tif (last == '@' && ch == '{')\n \t\t\t\treturn CHECK_REF_FORMAT_ERROR;\n \t\t}\n \t\tlevel++;\n \t\tif (!ch) {\n+\t\t\tif (ref <= cp - 2 && cp[-2] == '.')\n+\t\t\t\treturn CHECK_REF_FORMAT_ERROR;\n \t\t\tif (level < 2)\n \t\t\t\treturn CHECK_REF_FORMAT_ONELEVEL;\n \t\t\treturn ret;\n-- \n1.6.2.1.299.gda643a\n"},{"id":"108910","messageId":"20090322174016.GE8940@machine.or.cz","threadId":"18378","inReplyTo":"alpine.DEB.1.00.0903201247440.6865@intel-tinevez-2-302","subject":"Re: [PATCH] Document and test the new % shotcut for the tracked branch","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2009-03-22T17:40:16Z","receivedAt":"2009-03-22T17:40:16Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"On Fri, Mar 20, 2009 at 12:48:50PM +0100, Johannes Schindelin wrote:\n> Hi,\n> \n> On Fri, 20 Mar 2009, Petr Baudis wrote:\n> \n> > On Fri, Mar 20, 2009 at 11:31:31AM +0100, Johannes Schindelin wrote:\n> > > I had it ready yesterday!  But the real problem is not addressed by \n> > > your patch, either: '%<branch>' is a legal branch name.\n> > > \n> > > I briefly considered <branch>^{tracked}, but\n> > > \n> > > - the ^{} codepath does not try to substitute branch _names_, so we'd \n> > >   have to duplicate that ^{} detection, and,\n> > > \n> > > - it is really cumbersome to write.\n> > \n> > We already have @{N} to do one branch-based substitution, so what about \n> > following this convention? Can't we have @{t}?\n> \n> Have you ever tried a German keyboard layout?  You would not say that @{} \n> is easy to write if you did.\n\nInteresting, do you really use the regular German keyboard layout while\nworking in shell or programming? Most Czech people I know [*] use either\nthe USA layout or Czech programming layout.\n\n> Besides, @{<string>} is already taken for the date-based reflog.\n\nYes, but some strings can never be dates. ;-)\n\nHas our ref-shed painting fest reached any conclusion yet? I'm not fond\nof spending more one-off sequences (~, //, ../, ...) on this, or\nanything containing a colon (too confusing, IMHO). It would be nice to\nget some generic escaping syntax.\n\nThe cleanest way I can think of is declaring ~ a special character and\nhaving <ref>~<letter> as a generic way for ref-based expansions;\nmaster~t would then expand to tracked branch of master.\n\nThe only(?) downside is that to mangle HEAD ref, you should write \\~t\n(but you won't notice your mistake until user 't' appears), but that's\na tough call...\n\n(Should HEAD~t -> $HEAD~t -> master~t -> origin/master or rather\nHEAD~t -> origin/HEAD? The former is more intuitive, I guess.)\n\n\n[*] Since most Czech people I know are UNIX users, it seems...\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nThe average, healthy, well-adjusted adult gets up at seven-thirty\nin the morning feeling just terrible. -- Jean Kerr\n"}]}