Skip to content

Commit 2c2b664

Browse files
committed
Revert "Add new @ shortcut for HEAD"
This reverts commit cdfd948, as it does not just apply to "@" (and forms with modifiers like @{u} applied to it), but also affects e.g. "refs/heads/@/foo", which it shouldn't. The basic idea of giving a short-hand might be good, and the topic can be retried later, but let's revert to avoid affecting existing use cases for now for the upcoming release.
1 parent c1ebd90 commit 2c2b664

File tree

5 files changed

+0
-28
lines changed

5 files changed

+0
-28
lines changed

Documentation/git-check-ref-format.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ Git imposes the following rules on how references are named:
5454

5555
. They cannot contain a sequence `@{`.
5656

57-
. They cannot be the single character `@`.
58-
5957
. They cannot contain a `\`.
6058

6159
These rules make it easy for shell script based tools to parse

Documentation/revisions.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ the '$GIT_DIR/refs' directory or from the '$GIT_DIR/packed-refs' file.
5858
While the ref name encoding is unspecified, UTF-8 is preferred as
5959
some output processing may assume ref names in UTF-8.
6060

61-
'@'::
62-
'@' alone is a shortcut for 'HEAD'.
63-
6461
'<refname>@\{<date>\}', e.g. 'master@\{yesterday\}', 'HEAD@\{5 minutes ago\}'::
6562
A ref followed by the suffix '@' with a date specification
6663
enclosed in a brace

refs.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ int check_refname_format(const char *refname, int flags)
7272
{
7373
int component_len, component_count = 0;
7474

75-
if (!strcmp(refname, "@"))
76-
/* Refname is a single character '@'. */
77-
return -1;
78-
7975
while (1) {
8076
/* We are at the start of a path component. */
8177
component_len = check_refname_component(refname, flags);

sha1_name.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,17 +1004,6 @@ int get_sha1_mb(const char *name, unsigned char *sha1)
10041004
return st;
10051005
}
10061006

1007-
/* parse @something syntax, when 'something' is not {.*} */
1008-
static int interpret_empty_at(const char *name, int namelen, int len, struct strbuf *buf)
1009-
{
1010-
if (len || name[1] == '{')
1011-
return -1;
1012-
1013-
strbuf_reset(buf);
1014-
strbuf_add(buf, "HEAD", 4);
1015-
return 1;
1016-
}
1017-
10181007
static int reinterpret(const char *name, int namelen, int len, struct strbuf *buf)
10191008
{
10201009
/* we have extra data, which might need further processing */
@@ -1077,15 +1066,9 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
10771066
cp = strchr(name, '@');
10781067
if (!cp)
10791068
return -1;
1080-
1081-
len = interpret_empty_at(name, namelen, cp - name, buf);
1082-
if (len > 0)
1083-
return reinterpret(name, namelen, len, buf);
1084-
10851069
tmp_len = upstream_mark(cp, namelen - (cp - name));
10861070
if (!tmp_len)
10871071
return -1;
1088-
10891072
len = cp + tmp_len - name;
10901073
cp = xstrndup(name, cp - name);
10911074
upstream = branch_get(*cp ? cp : NULL);

t/t1508-at-combinations.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ check "HEAD@{u}" ref refs/heads/upstream-branch
5555
check "@{u}@{1}" commit upstream-one
5656
check "@{-1}@{u}" ref refs/heads/master
5757
check "@{-1}@{u}@{1}" commit master-one
58-
check "@" commit new-two
59-
check "@@{u}" ref refs/heads/upstream-branch
6058
nonsense "@{u}@{-1}"
6159
nonsense "@{0}@{0}"
6260
nonsense "@{1}@{u}"

0 commit comments

Comments
 (0)