2009-09-10 17:25:57 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='test <branch>@{upstream} syntax'
|
|
|
|
|
2020-11-19 00:44:21 +01:00
|
|
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
tests: mark tests relying on the current default for `init.defaultBranch`
In addition to the manual adjustment to let the `linux-gcc` CI job run
the test suite with `master` and then with `main`, this patch makes sure
that GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME is set in all test scripts
that currently rely on the initial branch name being `master by default.
To determine which test scripts to mark up, the first step was to
force-set the default branch name to `master` in
- all test scripts that contain the keyword `master`,
- t4211, which expects `t/t4211/history.export` with a hard-coded ref to
initialize the default branch,
- t5560 because it sources `t/t556x_common` which uses `master`,
- t8002 and t8012 because both source `t/annotate-tests.sh` which also
uses `master`)
This trick was performed by this command:
$ sed -i '/^ *\. \.\/\(test-lib\|lib-\(bash\|cvs\|git-svn\)\|gitweb-lib\)\.sh$/i\
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
' $(git grep -l master t/t[0-9]*.sh) \
t/t4211*.sh t/t5560*.sh t/t8002*.sh t/t8012*.sh
After that, careful, manual inspection revealed that some of the test
scripts containing the needle `master` do not actually rely on a
specific default branch name: either they mention `master` only in a
comment, or they initialize that branch specificially, or they do not
actually refer to the current default branch. Therefore, the
aforementioned modification was undone in those test scripts thusly:
$ git checkout HEAD -- \
t/t0027-auto-crlf.sh t/t0060-path-utils.sh \
t/t1011-read-tree-sparse-checkout.sh \
t/t1305-config-include.sh t/t1309-early-config.sh \
t/t1402-check-ref-format.sh t/t1450-fsck.sh \
t/t2024-checkout-dwim.sh \
t/t2106-update-index-assume-unchanged.sh \
t/t3040-subprojects-basic.sh t/t3301-notes.sh \
t/t3308-notes-merge.sh t/t3423-rebase-reword.sh \
t/t3436-rebase-more-options.sh \
t/t4015-diff-whitespace.sh t/t4257-am-interactive.sh \
t/t5323-pack-redundant.sh t/t5401-update-hooks.sh \
t/t5511-refspec.sh t/t5526-fetch-submodules.sh \
t/t5529-push-errors.sh t/t5530-upload-pack-error.sh \
t/t5548-push-porcelain.sh \
t/t5552-skipping-fetch-negotiator.sh \
t/t5572-pull-submodule.sh t/t5608-clone-2gb.sh \
t/t5614-clone-submodules-shallow.sh \
t/t7508-status.sh t/t7606-merge-custom.sh \
t/t9302-fast-import-unpack-limit.sh
We excluded one set of test scripts in these commands, though: the range
of `git p4` tests. The reason? `git p4` stores the (foreign) remote
branch in the branch called `p4/master`, which is obviously not the
default branch. Manual analysis revealed that only five of these tests
actually require a specific default branch name to pass; They were
modified thusly:
$ sed -i '/^ *\. \.\/lib-git-p4\.sh$/i\
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
' t/t980[0167]*.sh t/t9811*.sh
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-11-19 00:44:19 +01:00
|
|
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
|
|
|
|
2009-09-10 17:25:57 +02:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
|
|
|
|
test_expect_success 'setup' '
|
|
|
|
|
|
|
|
test_commit 1 &&
|
|
|
|
git checkout -b side &&
|
|
|
|
test_commit 2 &&
|
2020-11-19 00:44:21 +01:00
|
|
|
git checkout main &&
|
2009-09-10 17:25:57 +02:00
|
|
|
git clone . clone &&
|
|
|
|
test_commit 3 &&
|
|
|
|
(cd clone &&
|
|
|
|
test_commit 4 &&
|
2012-04-14 09:54:31 +02:00
|
|
|
git branch --track my-side origin/side &&
|
2020-11-19 00:44:21 +01:00
|
|
|
git branch --track local-main main &&
|
interpret_branch_name: find all possible @-marks
When we parse a string like "foo@{upstream}", we look for
the first "@"-sign, and check to see if it is an upstream
mark. However, since branch names can contain an @, we may
also see "@foo@{upstream}". In this case, we check only the
first @, and ignore the second. As a result, we do not find
the upstream.
We can solve this by iterating through all @-marks in the
string, and seeing if any is a legitimate upstream or
empty-at mark.
Another strategy would be to parse from the right-hand side
of the string. However, that does not work for the
"empty_at" case, which allows "@@{upstream}". We need to
find the left-most one in this case (and we then recurse as
"HEAD@{upstream}").
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-15 09:40:46 +01:00
|
|
|
git branch --track fun@ny origin/side &&
|
|
|
|
git branch --track @funny origin/side &&
|
|
|
|
git branch --track funny@ origin/side &&
|
2020-11-19 00:44:21 +01:00
|
|
|
git remote add -t main main-only .. &&
|
|
|
|
git fetch main-only &&
|
2012-04-14 09:54:31 +02:00
|
|
|
git branch bad-upstream &&
|
2020-11-19 00:44:21 +01:00
|
|
|
git config branch.bad-upstream.remote main-only &&
|
2012-04-14 09:54:31 +02:00
|
|
|
git config branch.bad-upstream.merge refs/heads/side
|
|
|
|
)
|
2009-09-10 17:25:57 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
commit_subject () {
|
|
|
|
(cd clone &&
|
2019-12-20 19:16:00 +01:00
|
|
|
git show -s --pretty=tformat:%s "$@")
|
2009-09-10 17:25:57 +02:00
|
|
|
}
|
|
|
|
|
2012-04-14 09:54:31 +02:00
|
|
|
error_message () {
|
|
|
|
(cd clone &&
|
2018-02-24 00:39:43 +01:00
|
|
|
test_must_fail git rev-parse --verify "$@" 2>../error)
|
2012-04-14 09:54:31 +02:00
|
|
|
}
|
|
|
|
|
2009-09-10 17:25:57 +02:00
|
|
|
test_expect_success '@{upstream} resolves to correct full name' '
|
2020-11-19 00:44:21 +01:00
|
|
|
echo refs/remotes/origin/main >expect &&
|
2019-12-20 19:16:02 +01:00
|
|
|
git -C clone rev-parse --symbolic-full-name @{upstream} >actual &&
|
2019-12-20 19:16:00 +01:00
|
|
|
test_cmp expect actual &&
|
2019-12-20 19:16:02 +01:00
|
|
|
git -C clone rev-parse --symbolic-full-name @{UPSTREAM} >actual &&
|
2019-12-20 19:16:00 +01:00
|
|
|
test_cmp expect actual &&
|
2019-12-20 19:16:02 +01:00
|
|
|
git -C clone rev-parse --symbolic-full-name @{UpSTReam} >actual &&
|
2019-12-20 19:16:00 +01:00
|
|
|
test_cmp expect actual
|
2009-09-10 17:25:57 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '@{u} resolves to correct full name' '
|
2020-11-19 00:44:21 +01:00
|
|
|
echo refs/remotes/origin/main >expect &&
|
2019-12-20 19:16:02 +01:00
|
|
|
git -C clone rev-parse --symbolic-full-name @{u} >actual &&
|
2019-12-20 19:16:00 +01:00
|
|
|
test_cmp expect actual &&
|
2019-12-20 19:16:02 +01:00
|
|
|
git -C clone rev-parse --symbolic-full-name @{U} >actual &&
|
2019-12-20 19:16:00 +01:00
|
|
|
test_cmp expect actual
|
2009-09-10 17:25:57 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'my-side@{upstream} resolves to correct full name' '
|
2019-12-20 19:16:00 +01:00
|
|
|
echo refs/remotes/origin/side >expect &&
|
2019-12-20 19:16:02 +01:00
|
|
|
git -C clone rev-parse --symbolic-full-name my-side@{u} >actual &&
|
2019-12-20 19:16:00 +01:00
|
|
|
test_cmp expect actual
|
2009-09-10 17:25:57 +02:00
|
|
|
'
|
|
|
|
|
interpret_branch_name: find all possible @-marks
When we parse a string like "foo@{upstream}", we look for
the first "@"-sign, and check to see if it is an upstream
mark. However, since branch names can contain an @, we may
also see "@foo@{upstream}". In this case, we check only the
first @, and ignore the second. As a result, we do not find
the upstream.
We can solve this by iterating through all @-marks in the
string, and seeing if any is a legitimate upstream or
empty-at mark.
Another strategy would be to parse from the right-hand side
of the string. However, that does not work for the
"empty_at" case, which allows "@@{upstream}". We need to
find the left-most one in this case (and we then recurse as
"HEAD@{upstream}").
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-15 09:40:46 +01:00
|
|
|
test_expect_success 'upstream of branch with @ in middle' '
|
2019-12-20 19:16:02 +01:00
|
|
|
git -C clone rev-parse --symbolic-full-name fun@ny@{u} >actual &&
|
interpret_branch_name: find all possible @-marks
When we parse a string like "foo@{upstream}", we look for
the first "@"-sign, and check to see if it is an upstream
mark. However, since branch names can contain an @, we may
also see "@foo@{upstream}". In this case, we check only the
first @, and ignore the second. As a result, we do not find
the upstream.
We can solve this by iterating through all @-marks in the
string, and seeing if any is a legitimate upstream or
empty-at mark.
Another strategy would be to parse from the right-hand side
of the string. However, that does not work for the
"empty_at" case, which allows "@@{upstream}". We need to
find the left-most one in this case (and we then recurse as
"HEAD@{upstream}").
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-15 09:40:46 +01:00
|
|
|
echo refs/remotes/origin/side >expect &&
|
2017-03-27 13:16:55 +02:00
|
|
|
test_cmp expect actual &&
|
2019-12-20 19:16:02 +01:00
|
|
|
git -C clone rev-parse --symbolic-full-name fun@ny@{U} >actual &&
|
interpret_branch_name: find all possible @-marks
When we parse a string like "foo@{upstream}", we look for
the first "@"-sign, and check to see if it is an upstream
mark. However, since branch names can contain an @, we may
also see "@foo@{upstream}". In this case, we check only the
first @, and ignore the second. As a result, we do not find
the upstream.
We can solve this by iterating through all @-marks in the
string, and seeing if any is a legitimate upstream or
empty-at mark.
Another strategy would be to parse from the right-hand side
of the string. However, that does not work for the
"empty_at" case, which allows "@@{upstream}". We need to
find the left-most one in this case (and we then recurse as
"HEAD@{upstream}").
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-15 09:40:46 +01:00
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'upstream of branch with @ at start' '
|
2019-12-20 19:16:02 +01:00
|
|
|
git -C clone rev-parse --symbolic-full-name @funny@{u} >actual &&
|
interpret_branch_name: find all possible @-marks
When we parse a string like "foo@{upstream}", we look for
the first "@"-sign, and check to see if it is an upstream
mark. However, since branch names can contain an @, we may
also see "@foo@{upstream}". In this case, we check only the
first @, and ignore the second. As a result, we do not find
the upstream.
We can solve this by iterating through all @-marks in the
string, and seeing if any is a legitimate upstream or
empty-at mark.
Another strategy would be to parse from the right-hand side
of the string. However, that does not work for the
"empty_at" case, which allows "@@{upstream}". We need to
find the left-most one in this case (and we then recurse as
"HEAD@{upstream}").
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-15 09:40:46 +01:00
|
|
|
echo refs/remotes/origin/side >expect &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'upstream of branch with @ at end' '
|
2019-12-20 19:16:02 +01:00
|
|
|
git -C clone rev-parse --symbolic-full-name funny@@{u} >actual &&
|
interpret_branch_name: find all possible @-marks
When we parse a string like "foo@{upstream}", we look for
the first "@"-sign, and check to see if it is an upstream
mark. However, since branch names can contain an @, we may
also see "@foo@{upstream}". In this case, we check only the
first @, and ignore the second. As a result, we do not find
the upstream.
We can solve this by iterating through all @-marks in the
string, and seeing if any is a legitimate upstream or
empty-at mark.
Another strategy would be to parse from the right-hand side
of the string. However, that does not work for the
"empty_at" case, which allows "@@{upstream}". We need to
find the left-most one in this case (and we then recurse as
"HEAD@{upstream}").
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-15 09:40:46 +01:00
|
|
|
echo refs/remotes/origin/side >expect &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2013-03-17 23:17:09 +01:00
|
|
|
test_expect_success 'refs/heads/my-side@{upstream} does not resolve to my-side{upstream}' '
|
2019-12-20 19:16:02 +01:00
|
|
|
test_must_fail git -C clone rev-parse --symbolic-full-name refs/heads/my-side@{upstream}
|
2013-03-17 23:17:09 +01:00
|
|
|
'
|
|
|
|
|
2009-09-10 17:25:57 +02:00
|
|
|
test_expect_success 'my-side@{u} resolves to correct commit' '
|
|
|
|
git checkout side &&
|
|
|
|
test_commit 5 &&
|
|
|
|
(cd clone && git fetch) &&
|
2019-12-20 19:16:00 +01:00
|
|
|
echo 2 >expect &&
|
|
|
|
commit_subject my-side >actual &&
|
|
|
|
test_cmp expect actual &&
|
|
|
|
echo 5 >expect &&
|
|
|
|
commit_subject my-side@{u} >actual
|
2009-09-10 17:25:57 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'not-tracking@{u} fails' '
|
2019-12-20 19:16:02 +01:00
|
|
|
test_must_fail git -C clone rev-parse --symbolic-full-name non-tracking@{u} &&
|
2009-09-10 17:25:57 +02:00
|
|
|
(cd clone && git checkout --no-track -b non-tracking) &&
|
2019-12-20 19:16:02 +01:00
|
|
|
test_must_fail git -C clone rev-parse --symbolic-full-name non-tracking@{u}
|
2009-09-10 17:25:57 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '<branch>@{u}@{1} resolves correctly' '
|
|
|
|
test_commit 6 &&
|
|
|
|
(cd clone && git fetch) &&
|
2019-12-20 19:16:00 +01:00
|
|
|
echo 5 >expect &&
|
|
|
|
commit_subject my-side@{u}@{1} >actual &&
|
|
|
|
test_cmp expect actual &&
|
|
|
|
commit_subject my-side@{U}@{1} >actual &&
|
|
|
|
test_cmp expect actual
|
2009-09-10 17:25:57 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '@{u} without specifying branch fails on a detached HEAD' '
|
|
|
|
git checkout HEAD^0 &&
|
2017-03-27 13:16:55 +02:00
|
|
|
test_must_fail git rev-parse @{u} &&
|
|
|
|
test_must_fail git rev-parse @{U}
|
2009-09-10 17:25:57 +02:00
|
|
|
'
|
|
|
|
|
2010-01-20 10:08:48 +01:00
|
|
|
test_expect_success 'checkout -b new my-side@{u} forks from the same' '
|
|
|
|
(
|
|
|
|
cd clone &&
|
|
|
|
git checkout -b new my-side@{u} &&
|
|
|
|
git rev-parse --symbolic-full-name my-side@{u} >expect &&
|
|
|
|
git rev-parse --symbolic-full-name new@{u} >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2010-01-20 08:17:11 +01:00
|
|
|
test_expect_success 'merge my-side@{u} records the correct name' '
|
2010-01-20 10:08:48 +01:00
|
|
|
(
|
2018-07-02 02:23:41 +02:00
|
|
|
cd clone &&
|
2020-11-19 00:44:21 +01:00
|
|
|
git checkout main &&
|
2018-07-02 02:23:41 +02:00
|
|
|
test_might_fail git branch -D new &&
|
2010-01-20 10:08:48 +01:00
|
|
|
git branch -t new my-side@{u} &&
|
|
|
|
git merge -s ours new@{u} &&
|
2014-05-15 00:12:45 +02:00
|
|
|
git show -s --pretty=tformat:%s >actual &&
|
2020-07-30 19:06:42 +02:00
|
|
|
echo "Merge remote-tracking branch ${SQ}origin/side${SQ}" >expect &&
|
2010-01-20 10:08:48 +01:00
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2010-01-20 08:17:11 +01:00
|
|
|
test_expect_success 'branch -d other@{u}' '
|
2020-11-19 00:44:21 +01:00
|
|
|
git checkout -t -b other main &&
|
2010-01-20 10:08:48 +01:00
|
|
|
git branch -d @{u} &&
|
2020-11-19 00:44:21 +01:00
|
|
|
git for-each-ref refs/heads/main >actual &&
|
2018-07-27 19:48:11 +02:00
|
|
|
test_must_be_empty actual
|
2010-01-20 10:08:48 +01:00
|
|
|
'
|
|
|
|
|
2010-01-20 08:17:11 +01:00
|
|
|
test_expect_success 'checkout other@{u}' '
|
2020-11-19 00:44:21 +01:00
|
|
|
git branch -f main HEAD &&
|
|
|
|
git checkout -t -b another main &&
|
2010-01-20 10:08:48 +01:00
|
|
|
git checkout @{u} &&
|
|
|
|
git symbolic-ref HEAD >actual &&
|
2020-11-19 00:44:21 +01:00
|
|
|
echo refs/heads/main >expect &&
|
2010-01-20 10:08:48 +01:00
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2012-04-14 09:54:31 +02:00
|
|
|
test_expect_success 'branch@{u} works when tracking a local branch' '
|
2020-11-19 00:44:21 +01:00
|
|
|
echo refs/heads/main >expect &&
|
|
|
|
git -C clone rev-parse --symbolic-full-name local-main@{u} >actual &&
|
2019-12-20 19:16:00 +01:00
|
|
|
test_cmp expect actual
|
2012-04-14 09:54:31 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'branch@{u} error message when no upstream' '
|
|
|
|
cat >expect <<-EOF &&
|
2019-09-06 00:10:05 +02:00
|
|
|
fatal: no upstream configured for branch ${SQ}non-tracking${SQ}
|
2012-04-14 09:54:31 +02:00
|
|
|
EOF
|
2018-02-24 00:39:43 +01:00
|
|
|
error_message non-tracking@{u} &&
|
2021-02-11 02:53:53 +01:00
|
|
|
test_cmp expect error
|
2012-04-14 09:54:31 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '@{u} error message when no upstream' '
|
|
|
|
cat >expect <<-EOF &&
|
2020-11-19 00:44:21 +01:00
|
|
|
fatal: no upstream configured for branch ${SQ}main${SQ}
|
2012-04-14 09:54:31 +02:00
|
|
|
EOF
|
|
|
|
test_must_fail git rev-parse --verify @{u} 2>actual &&
|
2021-02-11 02:53:53 +01:00
|
|
|
test_cmp expect actual
|
2012-04-14 09:54:31 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'branch@{u} error message with misspelt branch' '
|
|
|
|
cat >expect <<-EOF &&
|
2019-09-06 00:10:05 +02:00
|
|
|
fatal: no such branch: ${SQ}no-such-branch${SQ}
|
2012-04-14 09:54:31 +02:00
|
|
|
EOF
|
2018-02-24 00:39:43 +01:00
|
|
|
error_message no-such-branch@{u} &&
|
2021-02-11 02:53:53 +01:00
|
|
|
test_cmp expect error
|
2012-04-14 09:54:31 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '@{u} error message when not on a branch' '
|
|
|
|
cat >expect <<-EOF &&
|
sha1_name: fix error message for @{u}
Currently, when no (valid) upstream is configured for a branch, you get
an error like:
$ git show @{u}
error: No upstream configured for branch 'upstream-error'
error: No upstream configured for branch 'upstream-error'
fatal: ambiguous argument '@{u}': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
The "error: " line actually appears twice, and the rest of the error
message is useless. In sha1_name.c:interpret_branch_name(), there is
really no point in processing further if @{u} couldn't be resolved, and
we might as well die() instead of returning an error(). After making
this change, you get:
$ git show @{u}
fatal: No upstream configured for branch 'upstream-error'
Also tweak a few tests in t1507 to expect this output.
This only turns error() that may be called after we know we are
dealing with an @{upstream} marker into die(), without touching
silent error returns "return -1" from the function. Any caller that
wants to handle an error condition itself will not be hurt by this
change, unless they want to see the message from error() and then
exit silently without giving its own message, which needs to be
fixed anyway.
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-05-22 12:39:54 +02:00
|
|
|
fatal: HEAD does not point to a branch
|
2012-04-14 09:54:31 +02:00
|
|
|
EOF
|
|
|
|
git checkout HEAD^0 &&
|
|
|
|
test_must_fail git rev-parse --verify @{u} 2>actual &&
|
2021-02-11 02:53:53 +01:00
|
|
|
test_cmp expect actual
|
2012-04-14 09:54:31 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'branch@{u} error message if upstream branch not fetched' '
|
|
|
|
cat >expect <<-EOF &&
|
2019-09-06 00:10:05 +02:00
|
|
|
fatal: upstream branch ${SQ}refs/heads/side${SQ} not stored as a remote-tracking branch
|
2012-04-14 09:54:31 +02:00
|
|
|
EOF
|
2018-02-24 00:39:43 +01:00
|
|
|
error_message bad-upstream@{u} &&
|
2021-02-11 02:53:53 +01:00
|
|
|
test_cmp expect error
|
2012-04-14 09:54:31 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'pull works when tracking a local branch' '
|
|
|
|
(
|
|
|
|
cd clone &&
|
2020-11-19 00:44:21 +01:00
|
|
|
git checkout local-main &&
|
2012-04-14 09:54:31 +02:00
|
|
|
git pull
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
# makes sense if the previous one succeeded
|
|
|
|
test_expect_success '@{u} works when tracking a local branch' '
|
2020-11-19 00:44:21 +01:00
|
|
|
echo refs/heads/main >expect &&
|
2019-12-20 19:16:02 +01:00
|
|
|
git -C clone rev-parse --symbolic-full-name @{u} >actual &&
|
2019-12-20 19:16:00 +01:00
|
|
|
test_cmp expect actual
|
2012-04-14 09:54:31 +02:00
|
|
|
'
|
|
|
|
|
2010-01-26 22:48:28 +01:00
|
|
|
test_expect_success 'log -g other@{u}' '
|
2019-12-20 19:16:01 +01:00
|
|
|
commit=$(git rev-parse HEAD) &&
|
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit $commit
|
2020-11-19 00:44:21 +01:00
|
|
|
Reflog: main@{0} (C O Mitter <committer@example.com>)
|
2019-12-20 19:16:01 +01:00
|
|
|
Reflog message: branch: Created from HEAD
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:15:13 2005 -0700
|
|
|
|
|
|
|
|
3
|
|
|
|
EOF
|
2010-01-26 22:48:28 +01:00
|
|
|
git log -1 -g other@{u} >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'log -g other@{u}@{now}' '
|
2019-12-20 19:16:01 +01:00
|
|
|
commit=$(git rev-parse HEAD) &&
|
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit $commit
|
2020-11-19 00:44:21 +01:00
|
|
|
Reflog: main@{Thu Apr 7 15:17:13 2005 -0700} (C O Mitter <committer@example.com>)
|
2019-12-20 19:16:01 +01:00
|
|
|
Reflog message: branch: Created from HEAD
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:15:13 2005 -0700
|
|
|
|
|
|
|
|
3
|
|
|
|
EOF
|
2010-01-26 22:48:28 +01:00
|
|
|
git log -1 -g other@{u}@{now} >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
interpret_branch_name: avoid @{upstream} past colon
get_sha1() cannot currently parse a valid object name like
"HEAD:@{upstream}" (assuming that such an oddly named file
exists in the HEAD commit). It takes two passes to parse the
string:
1. It first considers the whole thing as a ref, which
results in looking for the upstream of "HEAD:".
2. It finds the colon, parses "HEAD" as a tree-ish, and then
finds the path "@{upstream}" in the tree.
For a path that looks like a normal reflog (e.g.,
"HEAD:@{yesterday}"), the first pass is a no-op. We try to
dwim_ref("HEAD:"), that returns zero refs, and we proceed
with colon-parsing.
For "HEAD:@{upstream}", though, the first pass ends up in
interpret_upstream_mark, which tries to find the branch
"HEAD:". When it sees that the branch does not exist, it
actually dies rather than returning an error to the caller.
As a result, we never make it to the second pass.
One obvious way of fixing this would be to teach
interpret_upstream_mark to simply report "no, this isn't an
upstream" in such a case. However, that would make the
error-reporting for legitimate upstream cases significantly
worse. Something like "bogus@{upstream}" would simply report
"unknown revision: bogus@{upstream}", while the current code
diagnoses a wide variety of possible misconfigurations (no
such branch, branch exists but does not have upstream, etc).
However, we can take advantage of the fact that a branch
name cannot contain a colon. Therefore even if we find an
upstream mark, any prefix with a colon must mean that
the upstream mark we found is actually a pathname, and
should be disregarded completely. This patch implements that
logic.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-15 09:37:23 +01:00
|
|
|
test_expect_success '@{reflog}-parsing does not look beyond colon' '
|
|
|
|
echo content >@{yesterday} &&
|
|
|
|
git add @{yesterday} &&
|
|
|
|
git commit -m "funny reflog file" &&
|
|
|
|
git hash-object @{yesterday} >expect &&
|
|
|
|
git rev-parse HEAD:@{yesterday} >actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '@{upstream}-parsing does not look beyond colon' '
|
|
|
|
echo content >@{upstream} &&
|
|
|
|
git add @{upstream} &&
|
|
|
|
git commit -m "funny upstream file" &&
|
|
|
|
git hash-object @{upstream} >expect &&
|
|
|
|
git rev-parse HEAD:@{upstream} >actual
|
|
|
|
'
|
|
|
|
|
2009-09-10 17:25:57 +02:00
|
|
|
test_done
|