Skip to content

Commit 42e1cc5

Browse files
committed
Merge branch 'ab/case-insensitive-upstream-and-push-marker'
On many keyboards, typing "@{" involves holding down SHIFT key and one can easily end up with "@{Up..." when typing "@{upstream}". As the upstream/push keywords do not appear anywhere else in the syntax, we can safely accept them case insensitively without introducing ambiguity or confusion to solve this. * ab/case-insensitive-upstream-and-push-marker: rev-parse: match @{upstream}, @{u} and @{push} case-insensitively
2 parents e7cbfd9 + 244ea1b commit 42e1cc5

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

Documentation/revisions.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ some output processing may assume ref names in UTF-8.
9696
refers to the branch that the branch specified by branchname is set to build on
9797
top of (configured with `branch.<name>.remote` and
9898
`branch.<name>.merge`). A missing branchname defaults to the
99-
current one.
99+
current one. These suffixes are also accepted when spelled in uppercase, and
100+
they mean the same thing no matter the case.
100101

101102
'<branchname>@\{push\}', e.g. 'master@\{push\}', '@\{push\}'::
102103
The suffix '@\{push}' reports the branch "where we would push to" if
@@ -122,6 +123,9 @@ refs/remotes/myfork/mybranch
122123
Note in the example that we set up a triangular workflow, where we pull
123124
from one location and push to another. In a non-triangular workflow,
124125
'@\{push}' is the same as '@\{upstream}', and there is no need for it.
126+
+
127+
This suffix is also accepted when spelled in uppercase, and means the same
128+
thing no matter the case.
125129

126130
'<rev>{caret}', e.g. 'HEAD{caret}, v1.5.1{caret}0'::
127131
A suffix '{caret}' to a revision parameter means the first parent of

sha1_name.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ static inline int at_mark(const char *string, int len,
549549
for (i = 0; i < nr; i++) {
550550
int suffix_len = strlen(suffix[i]);
551551
if (suffix_len <= len
552-
&& !memcmp(string, suffix[i], suffix_len))
552+
&& !strncasecmp(string, suffix[i], suffix_len))
553553
return suffix_len;
554554
}
555555
return 0;

t/t1507-rev-parse-upstream.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,14 @@ error_message () {
4646
}
4747

4848
test_expect_success '@{upstream} resolves to correct full name' '
49-
test refs/remotes/origin/master = "$(full_name @{upstream})"
49+
test refs/remotes/origin/master = "$(full_name @{upstream})" &&
50+
test refs/remotes/origin/master = "$(full_name @{UPSTREAM})" &&
51+
test refs/remotes/origin/master = "$(full_name @{UpSTReam})"
5052
'
5153

5254
test_expect_success '@{u} resolves to correct full name' '
53-
test refs/remotes/origin/master = "$(full_name @{u})"
55+
test refs/remotes/origin/master = "$(full_name @{u})" &&
56+
test refs/remotes/origin/master = "$(full_name @{U})"
5457
'
5558

5659
test_expect_success 'my-side@{upstream} resolves to correct full name' '
@@ -60,6 +63,8 @@ test_expect_success 'my-side@{upstream} resolves to correct full name' '
6063
test_expect_success 'upstream of branch with @ in middle' '
6164
full_name fun@ny@{u} >actual &&
6265
echo refs/remotes/origin/side >expect &&
66+
test_cmp expect actual &&
67+
full_name fun@ny@{U} >actual &&
6368
test_cmp expect actual
6469
'
6570

@@ -96,12 +101,14 @@ test_expect_success 'not-tracking@{u} fails' '
96101
test_expect_success '<branch>@{u}@{1} resolves correctly' '
97102
test_commit 6 &&
98103
(cd clone && git fetch) &&
99-
test 5 = $(commit_subject my-side@{u}@{1})
104+
test 5 = $(commit_subject my-side@{u}@{1}) &&
105+
test 5 = $(commit_subject my-side@{U}@{1})
100106
'
101107

102108
test_expect_success '@{u} without specifying branch fails on a detached HEAD' '
103109
git checkout HEAD^0 &&
104-
test_must_fail git rev-parse @{u}
110+
test_must_fail git rev-parse @{u} &&
111+
test_must_fail git rev-parse @{U}
105112
'
106113

107114
test_expect_success 'checkout -b new my-side@{u} forks from the same' '

t/t1514-rev-parse-push.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ test_expect_success 'setup' '
2424

2525
test_expect_success '@{push} with default=nothing' '
2626
test_config push.default nothing &&
27-
test_must_fail git rev-parse master@{push}
27+
test_must_fail git rev-parse master@{push} &&
28+
test_must_fail git rev-parse master@{PUSH} &&
29+
test_must_fail git rev-parse master@{PuSH}
2830
'
2931

3032
test_expect_success '@{push} with default=simple' '
3133
test_config push.default simple &&
32-
resolve master@{push} refs/remotes/origin/master
34+
resolve master@{push} refs/remotes/origin/master &&
35+
resolve master@{PUSH} refs/remotes/origin/master &&
36+
resolve master@{pUSh} refs/remotes/origin/master
3337
'
3438

3539
test_expect_success 'triangular @{push} fails with default=simple' '

0 commit comments

Comments
 (0)