git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] object-name: accept @{p} as short for @{push}

From
Harald Nordgren via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 2, 2026, 07:49 UTC
Message-ID
<pull.2431.v2.git.git.1790927399813.gitgitgadget@gmail.com>
In-Reply-To
<pull.2431.git.git.1790797186658.gitgitgadget@gmail.com>
From: Harald Nordgren <haraldnordgren@gmail.com>

"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>
---
    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}.
    
    Changes in v2:
    
     * Commit message explains history.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2431%2FHaraldNordgren%2Fpush-shorthand-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2431/HaraldNordgren/push-shorthand-v2
Pull-Request: https://github.com/git/git/pull/2431
Range-diff vs v1:
 1:  f772f79954 ! 1:  1097f119a3 object-name: accept @{p} as short for @{push}
     @@ Metadata
       ## Commit message ##
          object-name: accept @{p} as short for @{push}
      
     -    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.
     +    "git log @{p}" fails with "unknown revision", even though "@{u}"
     +    works for "@{upstream}".
      
     -    Accept "@{p}" wherever "@{push}" is accepted, in any case, just like
     -    "@{u}".
     +    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>
      
 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
Previous: Harald NordgrenNext: Ben Knoble
Message 8 of 11 in “object-name: accept @{p} as short for @{push}”
  1. object-name: accept @{p} as short for @{push}Harald Nordgren via GitGitGadget, Sep 30, 2026
  2. D. Ben KnobleSep 30, 2026
  3. Junio C HamanoSep 30, 2026
  4. Jeff KingSep 30, 2026
  5. Junio C HamanoOct 1, 2026
  6. Junio C HamanoSep 30, 2026
  7. Harald NordgrenOct 1, 2026
  8. object-name: accept @{p} as short for @{push}Harald Nordgren via GitGitGadget, Oct 2, 2026
  9. Ben KnobleOct 2, 2026
  10. Harald NordgrenOct 2, 2026
  11. Junio C HamanoOct 2, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.