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

[PATCH v2 2/3] rev-parse: add @{p} as a synonym for @{push}

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Mar 26, 2017, 12:16 UTC
Message-ID
<20170326121654.22035-3-avarab@gmail.com>
In-Reply-To
<20170326121654.22035-1-avarab@gmail.com>

Add @{p} as a shorthand for @{push} for consistency with the @{u} shorthand for @{upstream}.

This wasn't added when @{push} was introduced in commit adfe5d0434 ("sha1_name: implement @{push} shorthand", 2015-05-21), but it can be added without any ambiguity and saves the user some typing.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 Documentation/revisions.txt | 8 ++++----
 sha1_name.c                 | 2 +-
 t/t1514-rev-parse-push.sh   | 2 ++
 3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt
index 09e0d51b9e..5fe90e411d 100644
--- a/Documentation/revisions.txt
+++ b/Documentation/revisions.txt
@@ -99,8 +99,8 @@ some output processing may assume ref names in UTF-8.
   current one. These suffixes are accepted when spelled in uppercase, and
   they mean the same thing no matter the case.
 
-'<branchname>@\{push\}', e.g. 'master@\{push\}', '@\{push\}'::
-  The suffix '@\{push}' reports the branch "where we would push to" if
+'<branchname>@\{push\}', e.g. 'master@\{push\}', '@\{p\}'::
+  The suffix '@\{push}' (short form '@\{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). Since our push destination is
   in a remote repository, of course, we report the local tracking branch
@@ -124,8 +124,8 @@ Note in the example that we set up a triangular workflow, where we pull
 from one location and push to another. In a non-triangular workflow,
 '@\{push}' is the same as '@\{upstream}', and there is no need for it.
 +
-This suffix is accepted when spelled in uppercase, and means the same
-thing no matter the case.
+These suffixes are accepted when spelled in uppercase, and they mean
+the same thing no matter the case.
 
 '<rev>{caret}', e.g. 'HEAD{caret}, v1.5.1{caret}0'::
   A suffix '{caret}' to a revision parameter means the first parent of
diff --git a/sha1_name.c b/sha1_name.c
index d9d1b2fce8..2deb9bfdf6 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -563,7 +563,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 788cc91e45..db9aaf88f8 100755
--- a/t/t1514-rev-parse-push.sh
+++ b/t/t1514-rev-parse-push.sh
@@ -31,6 +31,8 @@ test_expect_success '@{push} with default=nothing' '
 
 test_expect_success '@{push} with default=simple' '
 	test_config push.default simple &&
+	resolve master@{p} refs/remotes/origin/master &&
+	resolve master@{P} refs/remotes/origin/master &&
 	resolve master@{push} refs/remotes/origin/master &&
 	resolve master@{PUSH} refs/remotes/origin/master &&
 	resolve master@{pUSh} refs/remotes/origin/master
-- 
2.11.0
Previous: Ævar Arnfjörð BjarmasonNext: Jeff King
Message 13 of 24 in “rev-parse: match @{u}, @{push} and ^{<type>} case-insensitively”
  1. rev-parse: match @{u}, @{push} and ^{<type>} case-insensitivelyÆvar Arnfjörð Bjarmason, Mar 18, 2017
  2. Duy NguyenMar 19, 2017
  3. Ævar Arnfjörð BjarmasonMar 19, 2017
  4. Junio C HamanoMar 19, 2017
  5. Ævar Arnfjörð BjarmasonMar 19, 2017
  6. Junio C HamanoMar 19, 2017
  7. 0/3 rev-parse case insensitivity & @{p} synonymÆvar Arnfjörð Bjarmason, Mar 26, 2017
  8. 1/3 rev-parse: match @{upstream}, @{u} and @{push} case-insensitivelyÆvar Arnfjörð Bjarmason, Mar 26, 2017
  9. Junio C HamanoMar 27, 2017
  10. rev-parse: match @{upstream}, @{u} and @{push} case-insensitivelyÆvar Arnfjörð Bjarmason, Mar 27, 2017
  11. Junio C HamanoMar 27, 2017
  12. Ævar Arnfjörð BjarmasonMar 27, 2017
  13. 2/3 rev-parse: add @{p} as a synonym for @{push}Ævar Arnfjörð Bjarmason, Mar 26, 2017
  14. Jeff KingMar 27, 2017
  15. Ævar Arnfjörð BjarmasonMar 27, 2017
  16. 3/3 rev-parse: match ^{<type>} case-insensitivelyÆvar Arnfjörð Bjarmason, Mar 26, 2017
  17. Junio C HamanoMar 27, 2017
  18. Jeff KingMar 27, 2017
  19. Junio C HamanoMar 27, 2017
  20. Jeff KingMar 27, 2017
  21. Ævar Arnfjörð BjarmasonMar 27, 2017
  22. Ævar Arnfjörð BjarmasonMar 21, 2017
  23. Junio C HamanoMar 21, 2017
  24. Jeff KingMar 21, 2017

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.