{"thread":{"id":"33688","subject":"[PATCH v2 0/6] New @ shortcut for HEAD","startedAt":"2013-04-30T21:49:08Z","lastAt":"2013-05-02T16:49:48Z","messageCount":22,"participants":["Felipe Contreras","Junio C Hamano","Duy Nguyen"],"isPatch":true,"patchVersion":2,"patchTotal":6},"messages":[{"id":"216066","messageId":"1367358554-4257-1-git-send-email-felipe.contreras@gmail.com","threadId":"33688","inReplyTo":null,"subject":"[PATCH v2 0/6] New @ shortcut for HEAD","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-04-30T21:49:08Z","receivedAt":"2013-04-30T21:49:08Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Hi,\n\nSame as before, except that now only '@' changes, 'master@' remains the same as\nbefore.\n\nAlso, cleanups for sha1_name, and an update so '@@{u}' works.\n\nFelipe Contreras (6):\n  sha1_name: remove no-op\n  sha1_name: remove unnecessary braces\n  sha1_name: avoid Yoda conditions\n  sha1_name: refactor reinterpret()\n  Add new @ shortcut for HEAD\n  sha1_name: allow @@{u} to work\n\n Documentation/git-check-ref-format.txt |  2 +\n Documentation/revisions.txt            |  3 ++\n refs.c                                 |  4 ++\n sha1_name.c                            | 78 +++++++++++++++++++++++-----------\n t/t1508-at-combinations.sh             |  3 ++\n 5 files changed, 65 insertions(+), 25 deletions(-)\n\n-- \n1.8.3.rc0.395.gfe9a10d\n"},{"id":"216067","messageId":"1367358554-4257-2-git-send-email-felipe.contreras@gmail.com","threadId":"33688","inReplyTo":"1367358554-4257-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 1/6] sha1_name: remove no-op","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-04-30T21:49:09Z","receivedAt":"2013-04-30T21:49:09Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"'at' is always 0, since we can reach this point only if\n!len && reflog_len, and len=at when reflog is assigned.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n sha1_name.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 3820f28..01e49a9 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -464,7 +464,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)\n \t\tstruct strbuf buf = STRBUF_INIT;\n \t\tint ret;\n \t\t/* try the @{-N} syntax for n-th checkout */\n-\t\tret = interpret_branch_name(str+at, &buf);\n+\t\tret = interpret_branch_name(str, &buf);\n \t\tif (ret > 0) {\n \t\t\t/* substitute this branch name and restart */\n \t\t\treturn get_sha1_1(buf.buf, buf.len, sha1, 0);\n-- \n1.8.3.rc0.395.gfe9a10d\n"},{"id":"216068","messageId":"1367358554-4257-3-git-send-email-felipe.contreras@gmail.com","threadId":"33688","inReplyTo":"1367358554-4257-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 2/6] sha1_name: remove unnecessary braces","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-04-30T21:49:10Z","receivedAt":"2013-04-30T21:49:10Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n sha1_name.c | 5 ++---\n 1 file changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 01e49a9..6530ddd 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -465,12 +465,11 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)\n \t\tint ret;\n \t\t/* try the @{-N} syntax for n-th checkout */\n \t\tret = interpret_branch_name(str, &buf);\n-\t\tif (ret > 0) {\n+\t\tif (ret > 0)\n \t\t\t/* substitute this branch name and restart */\n \t\t\treturn get_sha1_1(buf.buf, buf.len, sha1, 0);\n-\t\t} else if (ret == 0) {\n+\t\telse if (ret == 0)\n \t\t\treturn -1;\n-\t\t}\n \t\t/* allow \"@{...}\" to mean the current branch reflog */\n \t\trefs_found = dwim_ref(\"HEAD\", 4, sha1, &real_ref);\n \t} else if (reflog_len)\n-- \n1.8.3.rc0.395.gfe9a10d\n"},{"id":"216069","messageId":"1367358554-4257-4-git-send-email-felipe.contreras@gmail.com","threadId":"33688","inReplyTo":"1367358554-4257-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 3/6] sha1_name: avoid Yoda conditions","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-04-30T21:49:11Z","receivedAt":"2013-04-30T21:49:11Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n sha1_name.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 6530ddd..93c4e8c 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -996,9 +996,9 @@ int interpret_branch_name(const char *name, struct strbuf *buf)\n \n \tif (!len)\n \t\treturn len; /* syntax Ok, not enough switches */\n-\tif (0 < len && len == namelen)\n+\tif (len > 0 && len == namelen)\n \t\treturn len; /* consumed all */\n-\telse if (0 < len) {\n+\telse if (len > 0) {\n \t\t/* we have extra data, which might need further processing */\n \t\tstruct strbuf tmp = STRBUF_INIT;\n \t\tint used = buf->len;\n-- \n1.8.3.rc0.395.gfe9a10d\n"},{"id":"216071","messageId":"1367358554-4257-5-git-send-email-felipe.contreras@gmail.com","threadId":"33688","inReplyTo":"1367358554-4257-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 4/6] sha1_name: refactor reinterpret()","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-04-30T21:49:12Z","receivedAt":"2013-04-30T21:49:12Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"This code essentially replaces part of ref with another ref, for example\n'@{-1}@{u}' is replaced with 'master@{u}', but this can be reused for\nother purposes other than nth prior checkouts.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n sha1_name.c | 42 +++++++++++++++++++++++-------------------\n 1 file changed, 23 insertions(+), 19 deletions(-)\n\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 93c4e8c..76e3219 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -965,6 +965,27 @@ int get_sha1_mb(const char *name, unsigned char *sha1)\n \treturn st;\n }\n \n+static int reinterpret(const char *name, int namelen, int len, struct strbuf *buf)\n+{\n+\t/* we have extra data, which might need further processing */\n+\tstruct strbuf tmp = STRBUF_INIT;\n+\tint used = buf->len;\n+\tint ret;\n+\n+\tstrbuf_add(buf, name + len, namelen - len);\n+\tret = interpret_branch_name(buf->buf, &tmp);\n+\t/* that data was not interpreted, remove our cruft */\n+\tif (ret < 0) {\n+\t\tstrbuf_setlen(buf, used);\n+\t\treturn len;\n+\t}\n+\tstrbuf_reset(buf);\n+\tstrbuf_addbuf(buf, &tmp);\n+\tstrbuf_release(&tmp);\n+\t/* tweak for size of {-N} versus expanded ref name */\n+\treturn ret - used + len;\n+}\n+\n /*\n  * This reads short-hand syntax that not only evaluates to a commit\n  * object name, but also can act as if the end user spelled the name\n@@ -998,25 +1019,8 @@ int interpret_branch_name(const char *name, struct strbuf *buf)\n \t\treturn len; /* syntax Ok, not enough switches */\n \tif (len > 0 && len == namelen)\n \t\treturn len; /* consumed all */\n-\telse if (len > 0) {\n-\t\t/* we have extra data, which might need further processing */\n-\t\tstruct strbuf tmp = STRBUF_INIT;\n-\t\tint used = buf->len;\n-\t\tint ret;\n-\n-\t\tstrbuf_add(buf, name + len, namelen - len);\n-\t\tret = interpret_branch_name(buf->buf, &tmp);\n-\t\t/* that data was not interpreted, remove our cruft */\n-\t\tif (ret < 0) {\n-\t\t\tstrbuf_setlen(buf, used);\n-\t\t\treturn len;\n-\t\t}\n-\t\tstrbuf_reset(buf);\n-\t\tstrbuf_addbuf(buf, &tmp);\n-\t\tstrbuf_release(&tmp);\n-\t\t/* tweak for size of {-N} versus expanded ref name */\n-\t\treturn ret - used + len;\n-\t}\n+\telse if (len > 0)\n+\t\treturn reinterpret(name, namelen, len, buf);\n \n \tcp = strchr(name, '@');\n \tif (!cp)\n-- \n1.8.3.rc0.395.gfe9a10d\n"},{"id":"216070","messageId":"1367358554-4257-6-git-send-email-felipe.contreras@gmail.com","threadId":"33688","inReplyTo":"1367358554-4257-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 5/6] Add new @ shortcut for HEAD","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-04-30T21:49:13Z","receivedAt":"2013-04-30T21:49:13Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"So HEAD@{0}~0^0 is too much to type, but we can remove '^0', and we can\nremove '~0', and we can remove 'HEAD', which leaves us with @{0}, but we\ncan't remove '{0}'?\n\nThis patch allows '@' to be the same as 'HEAD'.\n\nSo now we can use 'git show @~1', and all that goody goodness.\n\nUntil now '@' was a valid name, but it conflicts with this idea, so lets\nmake it invalid. Very few people if any probably used this name, if they\ndid, they can rename it by using the full-path (e.g. refs/heads/@).\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n Documentation/git-check-ref-format.txt | 2 ++\n Documentation/revisions.txt            | 3 +++\n refs.c                                 | 4 ++++\n sha1_name.c                            | 6 +++++-\n t/t1508-at-combinations.sh             | 3 +++\n 5 files changed, 17 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-check-ref-format.txt b/Documentation/git-check-ref-format.txt\nindex ec1739a..e8035ec 100644\n--- a/Documentation/git-check-ref-format.txt\n+++ b/Documentation/git-check-ref-format.txt\n@@ -54,6 +54,8 @@ Git imposes the following rules on how references are named:\n \n . They cannot contain a sequence `@{`.\n \n+. They cannot be the single character `@`.\n+\n . They cannot contain a `\\`.\n \n These rules make it easy for shell script based tools to parse\ndiff --git a/Documentation/revisions.txt b/Documentation/revisions.txt\nindex d477b3f..09896a3 100644\n--- a/Documentation/revisions.txt\n+++ b/Documentation/revisions.txt\n@@ -58,6 +58,9 @@ the '$GIT_DIR/refs' directory or from the '$GIT_DIR/packed-refs' file.\n While the ref name encoding is unspecified, UTF-8 is preferred as\n some output processing may assume ref names in UTF-8.\n \n+'@'::\n+  '@' alone is a shortcut for 'HEAD'.\n+\n '<refname>@\\{<date>\\}', e.g. 'master@\\{yesterday\\}', 'HEAD@\\{5 minutes ago\\}'::\n   A ref followed by the suffix '@' with a date specification\n   enclosed in a brace\ndiff --git a/refs.c b/refs.c\nindex de2d8eb..4e70b3e 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -72,6 +72,10 @@ int check_refname_format(const char *refname, int flags)\n {\n \tint component_len, component_count = 0;\n \n+\tif (!strcmp(refname, \"@\"))\n+\t\t/* Refname is a single character '@'. */\n+\t\treturn -1;\n+\n \twhile (1) {\n \t\t/* We are at the start of a path component. */\n \t\tcomponent_len = check_refname_component(refname, flags);\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 76e3219..887de6c 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -437,11 +437,13 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)\n \tstatic const char *warn_msg = \"refname '%.*s' is ambiguous.\";\n \tchar *real_ref = NULL;\n \tint refs_found = 0;\n-\tint at, reflog_len;\n+\tint at, reflog_len, only_at;\n \n \tif (len == 40 && !get_sha1_hex(str, sha1))\n \t\treturn 0;\n \n+\tonly_at = len == 1 && str[0] == '@';\n+\n \t/* basic@{time or number or -number} format to query ref-log */\n \treflog_len = at = 0;\n \tif (len && str[len-1] == '}') {\n@@ -474,6 +476,8 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)\n \t\trefs_found = dwim_ref(\"HEAD\", 4, sha1, &real_ref);\n \t} else if (reflog_len)\n \t\trefs_found = dwim_log(str, len, sha1, &real_ref);\n+\telse if (only_at)\n+\t\trefs_found = dwim_ref(\"HEAD\", 4, sha1, &real_ref);\n \telse\n \t\trefs_found = dwim_ref(str, len, sha1, &real_ref);\n \ndiff --git a/t/t1508-at-combinations.sh b/t/t1508-at-combinations.sh\nindex d5d6244..50035cd 100755\n--- a/t/t1508-at-combinations.sh\n+++ b/t/t1508-at-combinations.sh\n@@ -45,6 +45,9 @@ check \"@{u}\" upstream-two\n check \"@{u}@{1}\" upstream-one\n check \"@{-1}@{u}\" master-two\n check \"@{-1}@{u}@{1}\" master-one\n+check \"@\" new-two\n+check \"HEAD@{u}\" upstream-two\n+check \"@@{u}\" upstream-two failure\n nonsense \"@{u}@{-1}\"\n nonsense \"@{1}@{u}\"\n \n-- \n1.8.3.rc0.395.gfe9a10d\n"},{"id":"216072","messageId":"1367358554-4257-7-git-send-email-felipe.contreras@gmail.com","threadId":"33688","inReplyTo":"1367358554-4257-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 6/6] sha1_name: allow @@{u} to work","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-04-30T21:49:14Z","receivedAt":"2013-04-30T21:49:14Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n sha1_name.c                | 21 +++++++++++++++++++++\n t/t1508-at-combinations.sh |  2 +-\n 2 files changed, 22 insertions(+), 1 deletion(-)\n\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 887de6c..8f65bad 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -969,6 +969,21 @@ int get_sha1_mb(const char *name, unsigned char *sha1)\n \treturn st;\n }\n \n+static int interpret_empty_at(const char *name, int namelen, int len, struct strbuf *buf)\n+{\n+\tif (namelen - len <= 1 || name[len + 1] == '{')\n+\t\treturn -1;\n+\n+\tstrbuf_reset(buf);\n+\tif (len == 0) {\n+\t\tstrbuf_add(buf, \"HEAD\", 4);\n+\t\treturn 1;\n+\t} else {\n+\t\tstrbuf_add(buf, name, len);\n+\t\treturn len + 1;\n+\t}\n+}\n+\n static int reinterpret(const char *name, int namelen, int len, struct strbuf *buf)\n {\n \t/* we have extra data, which might need further processing */\n@@ -1029,9 +1044,15 @@ int interpret_branch_name(const char *name, struct strbuf *buf)\n \tcp = strchr(name, '@');\n \tif (!cp)\n \t\treturn -1;\n+\n+\tlen = interpret_empty_at(name, namelen, cp - name, buf);\n+\tif (len > 0)\n+\t\treturn reinterpret(name, namelen, len, buf);\n+\n \ttmp_len = upstream_mark(cp, namelen - (cp - name));\n \tif (!tmp_len)\n \t\treturn -1;\n+\n \tlen = cp + tmp_len - name;\n \tcp = xstrndup(name, cp - name);\n \tupstream = branch_get(*cp ? cp : NULL);\ndiff --git a/t/t1508-at-combinations.sh b/t/t1508-at-combinations.sh\nindex 50035cd..65584c0 100755\n--- a/t/t1508-at-combinations.sh\n+++ b/t/t1508-at-combinations.sh\n@@ -47,7 +47,7 @@ check \"@{-1}@{u}\" master-two\n check \"@{-1}@{u}@{1}\" master-one\n check \"@\" new-two\n check \"HEAD@{u}\" upstream-two\n-check \"@@{u}\" upstream-two failure\n+check \"@@{u}\" upstream-two\n nonsense \"@{u}@{-1}\"\n nonsense \"@{1}@{u}\"\n \n-- \n1.8.3.rc0.395.gfe9a10d\n"},{"id":"216074","messageId":"7vehdrbrvz.fsf@alter.siamese.dyndns.org","threadId":"33688","inReplyTo":"1367358554-4257-4-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v2 3/6] sha1_name: avoid Yoda conditions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-04-30T22:00:48Z","receivedAt":"2013-04-30T22:00:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"What is a Yoda condition?\n"},{"id":"216075","messageId":"7va9ofbrug.fsf@alter.siamese.dyndns.org","threadId":"33688","inReplyTo":"1367358554-4257-5-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v2 4/6] sha1_name: refactor reinterpret()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-04-30T22:01:43Z","receivedAt":"2013-04-30T22:01:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> This code essentially replaces part of ref with another ref, for example\n> '@{-1}@{u}' is replaced with 'master@{u}', but this can be reused for\n> other purposes other than nth prior checkouts.\n>\n> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n> ---\n\nMakes sense.\n\n\n>  sha1_name.c | 42 +++++++++++++++++++++++-------------------\n>  1 file changed, 23 insertions(+), 19 deletions(-)\n>\n> diff --git a/sha1_name.c b/sha1_name.c\n> index 93c4e8c..76e3219 100644\n> --- a/sha1_name.c\n> +++ b/sha1_name.c\n> @@ -965,6 +965,27 @@ int get_sha1_mb(const char *name, unsigned char *sha1)\n>  \treturn st;\n>  }\n>  \n> +static int reinterpret(const char *name, int namelen, int len, struct strbuf *buf)\n> +{\n> +\t/* we have extra data, which might need further processing */\n> +\tstruct strbuf tmp = STRBUF_INIT;\n> +\tint used = buf->len;\n> +\tint ret;\n> +\n> +\tstrbuf_add(buf, name + len, namelen - len);\n> +\tret = interpret_branch_name(buf->buf, &tmp);\n> +\t/* that data was not interpreted, remove our cruft */\n> +\tif (ret < 0) {\n> +\t\tstrbuf_setlen(buf, used);\n> +\t\treturn len;\n> +\t}\n> +\tstrbuf_reset(buf);\n> +\tstrbuf_addbuf(buf, &tmp);\n> +\tstrbuf_release(&tmp);\n> +\t/* tweak for size of {-N} versus expanded ref name */\n> +\treturn ret - used + len;\n> +}\n> +\n>  /*\n>   * This reads short-hand syntax that not only evaluates to a commit\n>   * object name, but also can act as if the end user spelled the name\n> @@ -998,25 +1019,8 @@ int interpret_branch_name(const char *name, struct strbuf *buf)\n>  \t\treturn len; /* syntax Ok, not enough switches */\n>  \tif (len > 0 && len == namelen)\n>  \t\treturn len; /* consumed all */\n> -\telse if (len > 0) {\n> -\t\t/* we have extra data, which might need further processing */\n> -\t\tstruct strbuf tmp = STRBUF_INIT;\n> -\t\tint used = buf->len;\n> -\t\tint ret;\n> -\n> -\t\tstrbuf_add(buf, name + len, namelen - len);\n> -\t\tret = interpret_branch_name(buf->buf, &tmp);\n> -\t\t/* that data was not interpreted, remove our cruft */\n> -\t\tif (ret < 0) {\n> -\t\t\tstrbuf_setlen(buf, used);\n> -\t\t\treturn len;\n> -\t\t}\n> -\t\tstrbuf_reset(buf);\n> -\t\tstrbuf_addbuf(buf, &tmp);\n> -\t\tstrbuf_release(&tmp);\n> -\t\t/* tweak for size of {-N} versus expanded ref name */\n> -\t\treturn ret - used + len;\n> -\t}\n> +\telse if (len > 0)\n> +\t\treturn reinterpret(name, namelen, len, buf);\n>  \n>  \tcp = strchr(name, '@');\n>  \tif (!cp)\n"},{"id":"216076","messageId":"CAMP44s3osZJO1P6_KoPVON0cOSAD5D-OZmL=aKGkcWReortiCw@mail.gmail.com","threadId":"33688","inReplyTo":"7vehdrbrvz.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 3/6] sha1_name: avoid Yoda conditions","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-04-30T22:04:57Z","receivedAt":"2013-04-30T22:04:57Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, Apr 30, 2013 at 5:00 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> What is a Yoda condition?\n\n---\nUsing if (constant == variable) instead of if (variable == constant),\nlike if (4 == foo).\n\nBecause it's like saying \"if blue is the sky\" or \"if tall is the man\".\n---\n\n-- \nFelipe Contreras\n"},{"id":"216077","messageId":"7v61z3brlh.fsf@alter.siamese.dyndns.org","threadId":"33688","inReplyTo":"1367358554-4257-6-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v2 5/6] Add new @ shortcut for HEAD","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-04-30T22:07:06Z","receivedAt":"2013-04-30T22:07:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> So HEAD@{0}~0^0 is too much to type, but we can remove '^0', and we can\n> remove '~0', and we can remove 'HEAD', which leaves us with @{0}, but we\n> can't remove '{0}'?\n>\n> This patch allows '@' to be the same as 'HEAD'.\n>\n> So now we can use 'git show @~1', and all that goody goodness.\n>\n> Until now '@' was a valid name, but it conflicts with this idea, so lets\n> make it invalid. Very few people if any probably used this name, if they\n> did, they can rename it by using the full-path (e.g. refs/heads/@).\n>\n> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n> ---\n>  Documentation/git-check-ref-format.txt | 2 ++\n>  Documentation/revisions.txt            | 3 +++\n>  refs.c                                 | 4 ++++\n>  sha1_name.c                            | 6 +++++-\n>  t/t1508-at-combinations.sh             | 3 +++\n>  5 files changed, 17 insertions(+), 1 deletion(-)\n>\n> diff --git a/Documentation/git-check-ref-format.txt b/Documentation/git-check-ref-format.txt\n> index ec1739a..e8035ec 100644\n> --- a/Documentation/git-check-ref-format.txt\n> +++ b/Documentation/git-check-ref-format.txt\n> @@ -54,6 +54,8 @@ Git imposes the following rules on how references are named:\n>  \n>  . They cannot contain a sequence `@{`.\n>  \n> +. They cannot be the single character `@`.\n> +\n>  . They cannot contain a `\\`.\n>  \n>  These rules make it easy for shell script based tools to parse\n> diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt\n> index d477b3f..09896a3 100644\n> --- a/Documentation/revisions.txt\n> +++ b/Documentation/revisions.txt\n> @@ -58,6 +58,9 @@ the '$GIT_DIR/refs' directory or from the '$GIT_DIR/packed-refs' file.\n>  While the ref name encoding is unspecified, UTF-8 is preferred as\n>  some output processing may assume ref names in UTF-8.\n>  \n> +'@'::\n> +  '@' alone is a shortcut for 'HEAD'.\n> +\n>  '<refname>@\\{<date>\\}', e.g. 'master@\\{yesterday\\}', 'HEAD@\\{5 minutes ago\\}'::\n>    A ref followed by the suffix '@' with a date specification\n>    enclosed in a brace\n> diff --git a/refs.c b/refs.c\n> index de2d8eb..4e70b3e 100644\n> --- a/refs.c\n> +++ b/refs.c\n> @@ -72,6 +72,10 @@ int check_refname_format(const char *refname, int flags)\n>  {\n>  \tint component_len, component_count = 0;\n>  \n> +\tif (!strcmp(refname, \"@\"))\n> +\t\t/* Refname is a single character '@'. */\n> +\t\treturn -1;\n\nThis checks the single character \"@\" which is consistent with the\ndocumentation update, but does not seem to mesh well with \"they can\nrename it by using the full-path refs/heads/@\".\n\nI do not personally think it is wrong to end the log message with\n\"if they did, too bad.\", though ;-).\n"},{"id":"216079","messageId":"7v1u9rbrb4.fsf@alter.siamese.dyndns.org","threadId":"33688","inReplyTo":"CAMP44s3osZJO1P6_KoPVON0cOSAD5D-OZmL=aKGkcWReortiCw@mail.gmail.com","subject":"Re: [PATCH v2 3/6] sha1_name: avoid Yoda conditions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-04-30T22:13:19Z","receivedAt":"2013-04-30T22:13:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> On Tue, Apr 30, 2013 at 5:00 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> What is a Yoda condition?\n>\n> ---\n> Using if (constant == variable) instead of if (variable == constant),\n> like if (4 == foo).\n>\n> Because it's like saying \"if blue is the sky\" or \"if tall is the man\".\n\nThat is an invalid analogy, as the sentences do not make sense.\n\nA much better explanation I heard on this list is that people do not\nsay \"If 1 is smaller than the number of your wives, you have a big\nproblem\".\n\nI actually was not asking why people find the convention to visually\nalign comparison with number lines unusual. We discussed this style\nlong time ago on this list.  I haven't heard the \"Yoda condtion\"\nexpression and was asking about the \"Yoda\" part.\n"},{"id":"216081","messageId":"CAMP44s3K8BOfnUdc0514KgvYsbncSBO4DRSyfqhFQJomGrZN0A@mail.gmail.com","threadId":"33688","inReplyTo":"7v1u9rbrb4.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 3/6] sha1_name: avoid Yoda conditions","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-04-30T22:20:30Z","receivedAt":"2013-04-30T22:20:30Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, Apr 30, 2013 at 5:13 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>\n>> On Tue, Apr 30, 2013 at 5:00 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>>> What is a Yoda condition?\n>>\n>> ---\n>> Using if (constant == variable) instead of if (variable == constant),\n>> like if (4 == foo).\n>>\n>> Because it's like saying \"if blue is the sky\" or \"if tall is the man\".\n>\n> That is an invalid analogy, as the sentences do not make sense.\n>\n> A much better explanation I heard on this list is that people do not\n> say \"If 1 is smaller than the number of your wives, you have a big\n> problem\".\n>\n> I actually was not asking why people find the convention to visually\n> align comparison with number lines unusual. We discussed this style\n> long time ago on this list.  I haven't heard the \"Yoda condtion\"\n> expression and was asking about the \"Yoda\" part.\n\nIt's popular culture.\n\nhttp://en.wikipedia.org/wiki/Yoda\n\n-- \nFelipe Contreras\n"},{"id":"216082","messageId":"7vwqrjacd3.fsf@alter.siamese.dyndns.org","threadId":"33688","inReplyTo":"1367358554-4257-7-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v2 6/6] sha1_name: allow @@{u} to work","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-04-30T22:21:28Z","receivedAt":"2013-04-30T22:21:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n> ---\n>  sha1_name.c                | 21 +++++++++++++++++++++\n>  t/t1508-at-combinations.sh |  2 +-\n>  2 files changed, 22 insertions(+), 1 deletion(-)\n>\n> diff --git a/sha1_name.c b/sha1_name.c\n> index 887de6c..8f65bad 100644\n> --- a/sha1_name.c\n> +++ b/sha1_name.c\n> @@ -969,6 +969,21 @@ int get_sha1_mb(const char *name, unsigned char *sha1)\n>  \treturn st;\n>  }\n>  \n> +static int interpret_empty_at(const char *name, int namelen, int len, struct strbuf *buf)\n\nCan we have a comment to clarify what \"empty\"-ness this name refers to?\nIs it <empty>@<something>?  <something>@<empty>?  Something else?\n\n> +{\n> +\tif (namelen - len <= 1 || name[len + 1] == '{')\n> +\t\treturn -1;\n> +\n> +\tstrbuf_reset(buf);\n> +\tif (len == 0) {\n> +\t\tstrbuf_add(buf, \"HEAD\", 4);\n> +\t\treturn 1;\n> +\t} else {\n> +\t\tstrbuf_add(buf, name, len);\n> +\t\treturn len + 1;\n> +\t}\n> +}\n> +\n>  static int reinterpret(const char *name, int namelen, int len, struct strbuf *buf)\n>  {\n>  \t/* we have extra data, which might need further processing */\n> @@ -1029,9 +1044,15 @@ int interpret_branch_name(const char *name, struct strbuf *buf)\n>  \tcp = strchr(name, '@');\n>  \tif (!cp)\n>  \t\treturn -1;\n> +\n> +\tlen = interpret_empty_at(name, namelen, cp - name, buf);\n> +\tif (len > 0)\n> +\t\treturn reinterpret(name, namelen, len, buf);\n> +\n>  \ttmp_len = upstream_mark(cp, namelen - (cp - name));\n>  \tif (!tmp_len)\n>  \t\treturn -1;\n> +\n>  \tlen = cp + tmp_len - name;\n>  \tcp = xstrndup(name, cp - name);\n>  \tupstream = branch_get(*cp ? cp : NULL);\n> diff --git a/t/t1508-at-combinations.sh b/t/t1508-at-combinations.sh\n> index 50035cd..65584c0 100755\n> --- a/t/t1508-at-combinations.sh\n> +++ b/t/t1508-at-combinations.sh\n> @@ -47,7 +47,7 @@ check \"@{-1}@{u}\" master-two\n>  check \"@{-1}@{u}@{1}\" master-one\n>  check \"@\" new-two\n>  check \"HEAD@{u}\" upstream-two\n> -check \"@@{u}\" upstream-two failure\n> +check \"@@{u}\" upstream-two\n>  nonsense \"@{u}@{-1}\"\n>  nonsense \"@{1}@{u}\"\n"},{"id":"216084","messageId":"7vobcvabxi.fsf@alter.siamese.dyndns.org","threadId":"33688","inReplyTo":"CAMP44s3K8BOfnUdc0514KgvYsbncSBO4DRSyfqhFQJomGrZN0A@mail.gmail.com","subject":"Re: [PATCH v2 3/6] sha1_name: avoid Yoda conditions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-04-30T22:30:49Z","receivedAt":"2013-04-30T22:30:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> On Tue, Apr 30, 2013 at 5:13 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>>\n>>> On Tue, Apr 30, 2013 at 5:00 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>>>> What is a Yoda condition?\n>>>\n>>> ---\n>>> Using if (constant == variable) instead of if (variable == constant),\n>>> like if (4 == foo).\n>>>\n>>> Because it's like saying \"if blue is the sky\" or \"if tall is the man\".\n>>\n>> That is an invalid analogy, as the sentences do not make sense.\n>>\n>> A much better explanation I heard on this list is that people do not\n>> say \"If 1 is smaller than the number of your wives, you have a big\n>> problem\".\n>>\n>> I actually was not asking why people find the convention to visually\n>> align comparison with number lines unusual. We discussed this style\n>> long time ago on this list.  I haven't heard the \"Yoda condtion\"\n>> expression and was asking about the \"Yoda\" part.\n>\n> It's popular culture.\n>\n> http://en.wikipedia.org/wiki/Yoda\n\nI know who Yoda is.  What I was puzzled with was what it has to do\nwith \"if blue is the sky\" (which is a bad analogy for \"if (0 < len)\"\nanyway)?\n"},{"id":"216085","messageId":"7vk3njabvc.fsf@alter.siamese.dyndns.org","threadId":"33688","inReplyTo":"7vobcvabxi.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 3/6] sha1_name: avoid Yoda conditions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-04-30T22:32:07Z","receivedAt":"2013-04-30T22:32:07Z","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> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>\n>> On Tue, Apr 30, 2013 at 5:13 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>>> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>>>\n>>>> On Tue, Apr 30, 2013 at 5:00 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>>>>> What is a Yoda condition?\n>>>>\n>>>> ---\n>>>> Using if (constant == variable) instead of if (variable == constant),\n>>>> like if (4 == foo).\n>>>>\n>>>> Because it's like saying \"if blue is the sky\" or \"if tall is the man\".\n>>>\n>>> That is an invalid analogy, as the sentences do not make sense.\n>>>\n>>> A much better explanation I heard on this list is that people do not\n>>> say \"If 1 is smaller than the number of your wives, you have a big\n>>> problem\".\n>>>\n>>> I actually was not asking why people find the convention to visually\n>>> align comparison with number lines unusual. We discussed this style\n>>> long time ago on this list.  I haven't heard the \"Yoda condtion\"\n>>> expression and was asking about the \"Yoda\" part.\n>>\n>> It's popular culture.\n>>\n>> http://en.wikipedia.org/wiki/Yoda\n>\n> I know who Yoda is.  What I was puzzled with was what it has to do\n> with \"if blue is the sky\" (which is a bad analogy for \"if (0 < len)\"\n> anyway)?\n\nI found http://de.wikipedia.org/wiki/Yoda_Conditions which does not\nseem to have many other languages.\n\nNo need to reply, thanks.\n"},{"id":"216089","messageId":"CAMP44s26oZf0=xdqp5sr_J1TNhK83=88A7KH5n_LnstFe6o5gA@mail.gmail.com","threadId":"33688","inReplyTo":"7vobcvabxi.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 3/6] sha1_name: avoid Yoda conditions","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-04-30T22:45:26Z","receivedAt":"2013-04-30T22:45:26Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, Apr 30, 2013 at 5:30 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>\n>> On Tue, Apr 30, 2013 at 5:13 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>>> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>>>\n>>>> On Tue, Apr 30, 2013 at 5:00 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>>>>> What is a Yoda condition?\n>>>>\n>>>> ---\n>>>> Using if (constant == variable) instead of if (variable == constant),\n>>>> like if (4 == foo).\n>>>>\n>>>> Because it's like saying \"if blue is the sky\" or \"if tall is the man\".\n>>>\n>>> That is an invalid analogy, as the sentences do not make sense.\n>>>\n>>> A much better explanation I heard on this list is that people do not\n>>> say \"If 1 is smaller than the number of your wives, you have a big\n>>> problem\".\n>>>\n>>> I actually was not asking why people find the convention to visually\n>>> align comparison with number lines unusual. We discussed this style\n>>> long time ago on this list.  I haven't heard the \"Yoda condtion\"\n>>> expression and was asking about the \"Yoda\" part.\n>>\n>> It's popular culture.\n>>\n>> http://en.wikipedia.org/wiki/Yoda\n>\n> I know who Yoda is.  What I was puzzled with was what it has to do\n> with \"if blue is the sky\" (which is a bad analogy for \"if (0 < len)\"\n> anyway)?\n\nYoda speaks in reverse \"Stopped they must be; on this all depends\".\n\"if (0 < len)\" says \"if zero is less than len\", which is in reverse,\nas reverse as \"if 1.50 is taller than you\". It's all reversed: \"if you\nare taller than 1.50\", \"if len is greater than zero\", \"They must be\nstopped; all depends on this\".\n\nI don't understand what is not clear.\n\n-- \nFelipe Contreras\n"},{"id":"216093","messageId":"7v7gjjaagb.fsf@alter.siamese.dyndns.org","threadId":"33688","inReplyTo":"CAMP44s26oZf0=xdqp5sr_J1TNhK83=88A7KH5n_LnstFe6o5gA@mail.gmail.com","subject":"Re: [PATCH v2 3/6] sha1_name: avoid Yoda conditions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-04-30T23:02:44Z","receivedAt":"2013-04-30T23:02:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> Yoda speaks in reverse \"Stopped they must be; on this all depends\".\n> \"if (0 < len)\" says \"if zero is less than len\", which is in reverse,\n> as reverse as \"if 1.50 is taller than you\". It's all reversed: \"if you\n> are taller than 1.50\", \"if len is greater than zero\", \"They must be\n> stopped; all depends on this\".\n>\n> I don't understand what is not clear.\n\nI never said anything is \"not clear\", did I [*1*]?\n\nI've retitled it to \"compare variable with constant, not constant\nwith variable\" to make it easier to understand to those who did not\nknow the jargon (like me ;-).\n\nBy the way, after web-searching \"Yoda condition\", all mentions of\n\"Yoda condition\" I found were of the\n\n\tif (constant == variable)\n\nform, and people's justification why this form is bad, which I\nhappen to agree with [*2*].\n\n\n[Footnote]\n\n*1* \"zero is less than len\" and \"len is more than zero\" are saying\nexactly the same thing, even though people may find it harder to\nread.  While \"blue is the sky\" and \"the sky is blue\" are not saying\nthe same thing in the first place, and that is why I said it is not\na good analogy.\n\n\n*2* I do not write equality comparison in the \"constant == variable\"\norder myself.  For people reading from sidelines, the previous\nthread on this topic is this:\n\n    http://thread.gmane.org/gmane.comp.version-control.git/3903/focus=3907\n\nwhich explains why these were written as \"if (smaller < larger)\".\n"},{"id":"216094","messageId":"7v38u7aa95.fsf@alter.siamese.dyndns.org","threadId":"33688","inReplyTo":"7v7gjjaagb.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 3/6] sha1_name: avoid Yoda conditions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-04-30T23:07:02Z","receivedAt":"2013-04-30T23:07:02Z","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> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>\n>> Yoda speaks in reverse \"Stopped they must be; on this all depends\".\n>> \"if (0 < len)\" says \"if zero is less than len\", which is in reverse,\n>> as reverse as \"if 1.50 is taller than you\". It's all reversed: \"if you\n>> are taller than 1.50\", \"if len is greater than zero\", \"They must be\n>> stopped; all depends on this\".\n>>\n>> I don't understand what is not clear.\n>\n> I never said anything is \"not clear\", did I [*1*]?\n\nAhh, OK.\n\nEarlier I did not see the link between \"Yoda\" and \"const op var\"\nthat is \"speak in reverse\".  So I did say \"not clear\" or an\nequivalent of it, and you clarified it with \"reverse\" here.\n\nThanks.\n"},{"id":"216117","messageId":"CACsJy8D_-S_BvQAa5b2+XpfM2-fJcEQ5EJa4RRtV1vQPEe1emA@mail.gmail.com","threadId":"33688","inReplyTo":"1367358554-4257-6-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v2 5/6] Add new @ shortcut for HEAD","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-05-01T02:03:51Z","receivedAt":"2013-05-01T02:03:51Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, May 1, 2013 at 4:49 AM, Felipe Contreras\n<felipe.contreras@gmail.com> wrote:\n> So HEAD@{0}~0^0 is too much to type, but we can remove '^0', and we can\n> remove '~0', and we can remove 'HEAD', which leaves us with @{0}, but we\n> can't remove '{0}'?\n>\n> This patch allows '@' to be the same as 'HEAD'.\n>\n> So now we can use 'git show @~1', and all that goody goodness.\n>\n> Until now '@' was a valid name, but it conflicts with this idea, so lets\n> make it invalid. Very few people if any probably used this name, if they\n> did, they can rename it by using the full-path (e.g. refs/heads/@).\n\nPeople can write master short for refs/heads/master, but can't with\nrefs/heads/@. Would it be better to detect if dwim_ref(\"@\") exists,\nthen disable special '@' and warn user to rename '@' to something\nelse? After they have renamed it, make '@' special and forbid it in\nany component in the ref (i.e. refs/heads/@ is forbidden too).\n--\nDuy\n"},{"id":"216228","messageId":"CAMP44s0yd8EFWCkdFpHzUbdB-www=R6e1Yk-nPwiJDFPaAfYHQ@mail.gmail.com","threadId":"33688","inReplyTo":"CACsJy8D_-S_BvQAa5b2+XpfM2-fJcEQ5EJa4RRtV1vQPEe1emA@mail.gmail.com","subject":"Re: [PATCH v2 5/6] Add new @ shortcut for HEAD","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-02T02:44:56Z","receivedAt":"2013-05-02T02:44:56Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, Apr 30, 2013 at 9:03 PM, Duy Nguyen <pclouds@gmail.com> wrote:\n> On Wed, May 1, 2013 at 4:49 AM, Felipe Contreras\n> <felipe.contreras@gmail.com> wrote:\n>> So HEAD@{0}~0^0 is too much to type, but we can remove '^0', and we can\n>> remove '~0', and we can remove 'HEAD', which leaves us with @{0}, but we\n>> can't remove '{0}'?\n>>\n>> This patch allows '@' to be the same as 'HEAD'.\n>>\n>> So now we can use 'git show @~1', and all that goody goodness.\n>>\n>> Until now '@' was a valid name, but it conflicts with this idea, so lets\n>> make it invalid. Very few people if any probably used this name, if they\n>> did, they can rename it by using the full-path (e.g. refs/heads/@).\n>\n> People can write master short for refs/heads/master, but can't with\n> refs/heads/@. Would it be better to detect if dwim_ref(\"@\") exists,\n> then disable special '@' and warn user to rename '@' to something\n> else? After they have renamed it, make '@' special and forbid it in\n> any component in the ref (i.e. refs/heads/@ is forbidden too).\n\nI think that would be extremely tricky. If they have refs/heads/@, we\ncould try to warn them about the conflict, but I think it would be\npretty clear when 'git foo @' doesn't do what they want, and still\nthey, can use 'git foo refs/heads/@'.\n\nI think it's overkill to worry prematurely about users that most\nlikely don't exist. If say, we introduce this for 1.8.4, and some\npeople suffer from the decision, then we can do something about it for\n1.8.4.1, but it's more likely that they would just do 'git branch -m\nrefs/heads/@ whatever' (we should probably fix that because it doesn't\nactually work with any refs/heads/X). Of course, the much much more\nlikely scenario is that nothing will happen.\n\nIf there was an easy fix, we should go for that, but I just don't see any.\n\n-- \nFelipe Contreras\n"},{"id":"216273","messageId":"7vobct1g43.fsf@alter.siamese.dyndns.org","threadId":"33688","inReplyTo":"CACsJy8D_-S_BvQAa5b2+XpfM2-fJcEQ5EJa4RRtV1vQPEe1emA@mail.gmail.com","subject":"Re: [PATCH v2 5/6] Add new @ shortcut for HEAD","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-05-02T16:49:48Z","receivedAt":"2013-05-02T16:49:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> On Wed, May 1, 2013 at 4:49 AM, Felipe Contreras\n> <felipe.contreras@gmail.com> wrote:\n>> So HEAD@{0}~0^0 is too much to type, but we can remove '^0', and we can\n>> remove '~0', and we can remove 'HEAD', which leaves us with @{0}, but we\n>> can't remove '{0}'?\n>>\n>> This patch allows '@' to be the same as 'HEAD'.\n>>\n>> So now we can use 'git show @~1', and all that goody goodness.\n>>\n>> Until now '@' was a valid name, but it conflicts with this idea, so lets\n>> make it invalid. Very few people if any probably used this name, if they\n>> did, they can rename it by using the full-path (e.g. refs/heads/@).\n>\n> People can write master short for refs/heads/master, but can't with\n> refs/heads/@.\n\nIs it a new problem?\n\nYou can not say HEAD to refer to refs/heads/HEAD, either.  To avoid\nconfusion, we teach \"git branch HEAD $commit\" to error out (but it\nseems that \"git checkout -b HEAD $commit\" does not).\n\nWe probably would want to do the same for '@' when we refactor to\nhave a central place that knows what the \"make sense as refnames at\nthe syntactic level, but are forbidden for operational purposes\"\nbranch names are. And use it to update \"git checkout -b\".\n"}]}