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>
2015-05-21 04:45:47 +00:00
|
|
|
#!/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 &&
|
2017-03-27 11:16:55 +00:00
|
|
|
test_must_fail git rev-parse master@{push} &&
|
|
|
|
test_must_fail git rev-parse master@{PUSH} &&
|
|
|
|
test_must_fail git rev-parse master@{PuSH}
|
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>
2015-05-21 04:45:47 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '@{push} with default=simple' '
|
|
|
|
test_config push.default simple &&
|
2017-03-27 11:16:55 +00:00
|
|
|
resolve master@{push} refs/remotes/origin/master &&
|
|
|
|
resolve master@{PUSH} refs/remotes/origin/master &&
|
|
|
|
resolve master@{pUSh} refs/remotes/origin/master
|
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>
2015-05-21 04:45:47 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
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
|
|
|
|
'
|
|
|
|
|
2017-01-07 01:12:15 +00:00
|
|
|
test_expect_success 'resolving @{push} fails with a detached HEAD' '
|
|
|
|
git checkout HEAD^0 &&
|
|
|
|
test_when_finished "git checkout -" &&
|
|
|
|
test_must_fail git rev-parse @{push}
|
|
|
|
'
|
|
|
|
|
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>
2015-05-21 04:45:47 +00:00
|
|
|
test_done
|