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(-)
Show changes to 3 files +9 −2
Documentation/revisions.adoc, object-name.c, t/t1514-rev-parse-push.sh
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