From: "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Harald Nordgren <haraldnordgren@gmail.com>,
Harald Nordgren <haraldnordgren@gmail.com>
Subject: [PATCH] object-name: accept @{p} as short for @{push}
Date: Wed, 30 Sep 2026 19:39:46 +0000 [thread overview]
Message-ID: <pull.2431.git.git.1790797186658.gitgitgadget@gmail.com> (raw)
From: Harald Nordgren <haraldnordgren@gmail.com>
Typing "git log @{p}.." fails with "unknown revision", even though
"@{u}" works as the short form of "@{upstream}". Users who reach for
the one letter spelling of the push destination by analogy get an
error.
Accept "@{p}" wherever "@{push}" is accepted, in any case, just like
"@{u}".
Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
---
object-name: accept @{p} as short for @{push}
@{u} works as the short form of @{upstream}, but @{p} fails with
"unknown revision". This makes @{p} resolve to the same branch as
@{push}, in any case, and documents it next to @{u}.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2431%2FHaraldNordgren%2Fpush-shorthand-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2431/HaraldNordgren/push-shorthand-v1
Pull-Request: https://github.com/git/git/pull/2431
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.<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
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/* &&
base-commit: a018953688f1b10bddf91bff8747068f5f4746a4
--
gitgitgadget
next reply other threads:[~2026-09-30 19:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 19:39 Harald Nordgren via GitGitGadget [this message]
2026-09-30 21:39 ` [PATCH] object-name: accept @{p} as short for @{push} D. Ben Knoble
2026-09-30 22:07 ` Junio C Hamano
2026-09-30 22:39 ` Jeff King
2026-10-01 3:29 ` Junio C Hamano
2026-09-30 22:52 ` Junio C Hamano
2026-10-01 7:05 ` Harald Nordgren
2026-10-02 7:49 ` [PATCH v2] " Harald Nordgren via GitGitGadget
2026-10-02 12:08 ` Ben Knoble
2026-10-02 13:57 ` Harald Nordgren
2026-10-02 14:47 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.2431.git.git.1790797186658.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=haraldnordgren@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.