object-name: accept @{p} as short for @{push}

"git log @{p}" fails with "unknown revision", even though "@{u}"
works for "@{upstream}".

The "@{upstream}" notation came with its "@{u}" short form from the
very beginning in 28fb84382b (Introduce <branch>@{upstream} notation,
2009-09-10). When "@{push}" was added in adfe5d0434 (sha1_name:
implement @{push} shorthand, 2015-05-21), "@{p}" was held back to
avoid confusion with a proposed "@{publish}" and talk of an "@{pull}".
Neither of those was ever added.

Add the missing "@{p}" for symmetry with "@{u}".

Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Harald Nordgren authored and Junio C Hamano committed 2026-10-02 07:38:17 -07:00
1 parent a018953688
commit 72c41c3ee0
3 files changed
+9 -2

No files matched your search

+1 -1
View File
@@ -122,7 +122,7 @@ some output processing may assume ref names in UTF-8.
`branch.<name>.remote`). B@{u} refers to the remote-tracking branch for
the branch X taken from remote R, typically found at `refs/remotes/R/X`.
'[<branchname>]@\{push\}', e.g. 'master@\{push\}', '@\{push\}'::
'[<branchname>]@\{push\}', e.g. 'master@\{push\}', '@\{p\}'::
The suffix '@\{push}' reports the branch "where we would push to" if
`git push` were run while `branchname` was checked out (or the current
`HEAD` if no branchname is specified). Like for '@\{upstream\}', we report
+1 -1
View File
@@ -657,7 +657,7 @@ static inline int upstream_mark(const char *string, int len)
static inline int push_mark(const char *string, int len)
{
const char *suffix[] = { "@{push}" };
const char *suffix[] = { "@{push}", "@{p}" };
return at_mark(string, len, suffix, ARRAY_SIZE(suffix));
}
+7
View File
@@ -60,6 +60,13 @@ test_expect_success '@{push} with pushremote defined' '
resolve topic@{push} refs/remotes/other/topic
'
test_expect_success '@{p} is short for @{push}' '
test_config push.default current &&
test_config branch.topic.pushremote other &&
resolve topic@{p} refs/remotes/other/topic &&
resolve topic@{P} refs/remotes/other/topic
'
test_expect_success '@{push} with push refspecs' '
test_config push.default nothing &&
test_config remote.origin.push refs/heads/*:refs/heads/magic/* &&