-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sha1_name: implement @{push} shorthand
In a triangular workflow, each branch may have two distinct points of interest: the @{upstream} that you normally pull from, and the destination that you normally push to. There isn't a shorthand for the latter, but it's useful to have. For instance, you may want to know which commits you haven't pushed yet: git log @{push}.. Or as a more complicated example, imagine that you normally pull changes from origin/master (which you set as your @{upstream}), and push changes to your own personal fork (e.g., as myfork/topic). You may push to your fork from multiple machines, requiring you to integrate the changes from the push destination, rather than upstream. With this patch, you can just do: git rebase @{push} rather than typing out the full name. The heavy lifting is all done by branch_get_push; here we just wire it up to the "@{push}" syntax. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
- Loading branch information
Jeff King
authored and
Junio C Hamano
committed
May 22, 2015
1 parent
48c5847
commit adfe5d0
Showing
3 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/sh | ||
|
||
test_description='test <branch>@{push} syntax' | ||
. ./test-lib.sh | ||
|
||
resolve () { | ||
echo "$2" >expect && | ||
git rev-parse --symbolic-full-name "$1" >actual && | ||
test_cmp expect actual | ||
} | ||
|
||
test_expect_success 'setup' ' | ||
git init --bare parent.git && | ||
git init --bare other.git && | ||
git remote add origin parent.git && | ||
git remote add other other.git && | ||
test_commit base && | ||
git push origin HEAD && | ||
git branch --set-upstream-to=origin/master master && | ||
git branch --track topic origin/master && | ||
git push origin topic && | ||
git push other topic | ||
' | ||
|
||
test_expect_success '@{push} with default=nothing' ' | ||
test_config push.default nothing && | ||
test_must_fail git rev-parse master@{push} | ||
' | ||
|
||
test_expect_success '@{push} with default=simple' ' | ||
test_config push.default simple && | ||
resolve master@{push} refs/remotes/origin/master | ||
' | ||
|
||
test_expect_success 'triangular @{push} fails with default=simple' ' | ||
test_config push.default simple && | ||
test_must_fail git rev-parse topic@{push} | ||
' | ||
|
||
test_expect_success '@{push} with default=current' ' | ||
test_config push.default current && | ||
resolve topic@{push} refs/remotes/origin/topic | ||
' | ||
|
||
test_expect_success '@{push} with default=matching' ' | ||
test_config push.default matching && | ||
resolve topic@{push} refs/remotes/origin/topic | ||
' | ||
|
||
test_expect_success '@{push} with pushremote defined' ' | ||
test_config push.default current && | ||
test_config branch.topic.pushremote other && | ||
resolve topic@{push} 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/* && | ||
git push && | ||
resolve topic@{push} refs/remotes/origin/magic/topic | ||
' | ||
|
||
test_done |