From 72c41c3ee0bc8f0e12f21f0c55bd9d07d19f75f6 Mon Sep 17 00:00:00 2001 From: Harald Nordgren Date: Fri, 2 Oct 2026 07:49:59 +0000 Subject: [PATCH] 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 @{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 Signed-off-by: Junio C Hamano --- Documentation/revisions.adoc | 2 +- object-name.c | 2 +- t/t1514-rev-parse-push.sh | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Documentation/revisions.adoc b/Documentation/revisions.adoc index 3fbfbd3d5f..68ce6f3dc2 100644 --- a/Documentation/revisions.adoc +++ b/Documentation/revisions.adoc @@ -122,7 +122,7 @@ some output processing may assume ref names in UTF-8. `branch..remote`). B@{u} refers to the remote-tracking branch for the branch X taken from remote R, typically found at `refs/remotes/R/X`. -'[]@\{push\}', e.g. 'master@\{push\}', '@\{push\}':: +'[]@\{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 diff --git a/object-name.c b/object-name.c index 4eda8c8eac..6546685760 100644 --- a/object-name.c +++ b/object-name.c @@ -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)); } diff --git a/t/t1514-rev-parse-push.sh b/t/t1514-rev-parse-push.sh index d868a08110..5a4f16867a 100755 --- a/t/t1514-rev-parse-push.sh +++ b/t/t1514-rev-parse-push.sh @@ -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/* &&