* [PATCH 0/4] t: branch: fixes and cleanups
@ 2013-08-31 4:31 Felipe Contreras
2013-08-31 4:31 ` [PATCH 1/4] t: branch: trivial style fix Felipe Contreras
` (3 more replies)
0 siblings, 4 replies; 14+ messages in thread
From: Felipe Contreras @ 2013-08-31 4:31 UTC (permalink / raw)
To: git; +Cc: Felipe Contreras
Felipe Contreras (4):
t: branch: trivial style fix
t: branch: fix typo
t: branch: fix broken && chains
t: branch: improve test rollback
t/t3200-branch.sh | 82 +++++++++++++++++++++++++++----------------------------
1 file changed, 41 insertions(+), 41 deletions(-)
--
1.8.4-fc
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/4] t: branch: trivial style fix
2013-08-31 4:31 [PATCH 0/4] t: branch: fixes and cleanups Felipe Contreras
@ 2013-08-31 4:31 ` Felipe Contreras
2013-09-03 19:13 ` Junio C Hamano
2013-08-31 4:31 ` [PATCH 2/4] t: branch: fix typo Felipe Contreras
` (2 subsequent siblings)
3 siblings, 1 reply; 14+ messages in thread
From: Felipe Contreras @ 2013-08-31 4:31 UTC (permalink / raw)
To: git; +Cc: Felipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
t/t3200-branch.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 44ec6a4..ea548f9 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -14,7 +14,8 @@ test_expect_success 'prepare a trivial repository' '
echo World >>A &&
git update-index --add A &&
git commit -m "Second commit." &&
- HEAD=$(git rev-parse --verify HEAD)'
+ HEAD=$(git rev-parse --verify HEAD)
+'
test_expect_success 'git branch --help should not have created a bogus branch' '
test_might_fail git branch --help </dev/null >/dev/null 2>/dev/null &&
--
1.8.4-fc
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/4] t: branch: fix typo
2013-08-31 4:31 [PATCH 0/4] t: branch: fixes and cleanups Felipe Contreras
2013-08-31 4:31 ` [PATCH 1/4] t: branch: trivial style fix Felipe Contreras
@ 2013-08-31 4:31 ` Felipe Contreras
2013-08-31 4:31 ` [PATCH 3/4] t: branch: fix broken && chains Felipe Contreras
2013-08-31 4:31 ` [PATCH 4/4] t: branch: improve test rollback Felipe Contreras
3 siblings, 0 replies; 14+ messages in thread
From: Felipe Contreras @ 2013-08-31 4:31 UTC (permalink / raw)
To: git; +Cc: Felipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
t/t3200-branch.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index ea548f9..3134652 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -351,7 +351,7 @@ test_expect_success 'test overriding tracking setup via --no-track' '
test_expect_success 'no tracking without .fetch entries' '
git config branch.autosetupmerge true &&
git branch my6 s &&
- git config branch.automsetupmerge false &&
+ git config branch.autosetupmerge false &&
test -z "$(git config branch.my6.remote)" &&
test -z "$(git config branch.my6.merge)"
'
--
1.8.4-fc
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 3/4] t: branch: fix broken && chains
2013-08-31 4:31 [PATCH 0/4] t: branch: fixes and cleanups Felipe Contreras
2013-08-31 4:31 ` [PATCH 1/4] t: branch: trivial style fix Felipe Contreras
2013-08-31 4:31 ` [PATCH 2/4] t: branch: fix typo Felipe Contreras
@ 2013-08-31 4:31 ` Felipe Contreras
2013-08-31 4:31 ` [PATCH 4/4] t: branch: improve test rollback Felipe Contreras
3 siblings, 0 replies; 14+ messages in thread
From: Felipe Contreras @ 2013-08-31 4:31 UTC (permalink / raw)
To: git; +Cc: Felipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
t/t3200-branch.sh | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 3134652..d85306f 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -425,14 +425,14 @@ test_expect_success '--set-upstream-to fails on a non-ref' '
test_expect_success 'use --set-upstream-to modify HEAD' '
test_config branch.master.remote foo &&
test_config branch.master.merge foo &&
- git branch my12
+ git branch my12 &&
git branch --set-upstream-to my12 &&
test "$(git config branch.master.remote)" = "." &&
test "$(git config branch.master.merge)" = "refs/heads/my12"
'
test_expect_success 'use --set-upstream-to modify a particular branch' '
- git branch my13
+ git branch my13 &&
git branch --set-upstream-to master my13 &&
test "$(git config branch.my13.remote)" = "." &&
test "$(git config branch.my13.merge)" = "refs/heads/master"
@@ -443,7 +443,7 @@ test_expect_success '--unset-upstream should fail if given a non-existent branch
'
test_expect_success 'test --unset-upstream on HEAD' '
- git branch my14
+ git branch my14 &&
test_config branch.master.remote foo &&
test_config branch.master.merge foo &&
git branch --set-upstream-to my14 &&
@@ -465,7 +465,7 @@ test_expect_success '--unset-upstream should fail on detached HEAD' '
'
test_expect_success 'test --unset-upstream on a particular branch' '
- git branch my15
+ git branch my15 &&
git branch --set-upstream-to master my14 &&
git branch --unset-upstream my14 &&
test_must_fail git config branch.my14.remote &&
--
1.8.4-fc
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 4/4] t: branch: improve test rollback
2013-08-31 4:31 [PATCH 0/4] t: branch: fixes and cleanups Felipe Contreras
` (2 preceding siblings ...)
2013-08-31 4:31 ` [PATCH 3/4] t: branch: fix broken && chains Felipe Contreras
@ 2013-08-31 4:31 ` Felipe Contreras
2013-09-03 19:32 ` Junio C Hamano
3 siblings, 1 reply; 14+ messages in thread
From: Felipe Contreras @ 2013-08-31 4:31 UTC (permalink / raw)
To: git; +Cc: Felipe Contreras
After every test the environment should be as close as to how it was
before as possible.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
t/t3200-branch.sh | 71 +++++++++++++++++++++++++++----------------------------
1 file changed, 35 insertions(+), 36 deletions(-)
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index d85306f..3d4f634 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -328,7 +328,7 @@ test_expect_success 'tracking setup fails on non-matching refspec' '
'
test_expect_success 'test tracking setup via config' '
- git config branch.autosetupmerge true &&
+ test_config branch.autosetupmerge true &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
@@ -338,20 +338,18 @@ test_expect_success 'test tracking setup via config' '
'
test_expect_success 'test overriding tracking setup via --no-track' '
- git config branch.autosetupmerge true &&
+ test_config branch.autosetupmerge true &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
git branch --no-track my2 local/master &&
- git config branch.autosetupmerge false &&
! test "$(git config branch.my2.remote)" = local &&
! test "$(git config branch.my2.merge)" = refs/heads/master
'
test_expect_success 'no tracking without .fetch entries' '
- git config branch.autosetupmerge true &&
+ test_config branch.autosetupmerge true &&
git branch my6 s &&
- git config branch.autosetupmerge false &&
test -z "$(git config branch.my6.remote)" &&
test -z "$(git config branch.my6.merge)"
'
@@ -386,9 +384,8 @@ test_expect_success 'test --track without .fetch entries' '
'
test_expect_success 'branch from non-branch HEAD w/autosetupmerge=always' '
- git config branch.autosetupmerge always &&
- git branch my9 HEAD^ &&
- git config branch.autosetupmerge false
+ test_config branch.autosetupmerge always &&
+ git branch my9 HEAD^
'
test_expect_success 'branch from non-branch HEAD w/--track causes failure' '
@@ -405,9 +402,9 @@ test_expect_success '--set-upstream-to fails on multiple branches' '
'
test_expect_success '--set-upstream-to fails on detached HEAD' '
+ test_when_finished "git checkout -" &&
git checkout HEAD^{} &&
- test_must_fail git branch --set-upstream-to master &&
- git checkout -
+ test_must_fail git branch --set-upstream-to master
'
test_expect_success '--set-upstream-to fails on a missing dst branch' '
@@ -459,9 +456,9 @@ test_expect_success '--unset-upstream should fail on multiple branches' '
'
test_expect_success '--unset-upstream should fail on detached HEAD' '
+ test_when_finished "git checkout -" &&
git checkout HEAD^{} &&
- test_must_fail git branch --unset-upstream &&
- git checkout -
+ test_must_fail git branch --unset-upstream
'
test_expect_success 'test --unset-upstream on a particular branch' '
@@ -540,7 +537,8 @@ test_expect_success 'checkout -b with -l makes reflog when core.logAllRefUpdates
'
test_expect_success 'avoid ambiguous track' '
- git config branch.autosetupmerge true &&
+ test_when_finished "git remote rm ambi1 && git remote rm ambi2" &&
+ test_config branch.autosetupmerge true &&
git config remote.ambi1.url lalala &&
git config remote.ambi1.fetch refs/heads/lalala:refs/heads/master &&
git config remote.ambi2.url lilili &&
@@ -552,7 +550,7 @@ test_expect_success 'avoid ambiguous track' '
test_expect_success 'autosetuprebase local on a tracked local branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- git config branch.autosetuprebase local &&
+ test_config branch.autosetuprebase local &&
(git show-ref -q refs/remotes/local/o || git fetch local) &&
git branch mybase &&
git branch --track myr1 mybase &&
@@ -564,7 +562,7 @@ test_expect_success 'autosetuprebase local on a tracked local branch' '
test_expect_success 'autosetuprebase always on a tracked local branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- git config branch.autosetuprebase always &&
+ test_config branch.autosetuprebase always &&
(git show-ref -q refs/remotes/local/o || git fetch local) &&
git branch mybase2 &&
git branch --track myr2 mybase &&
@@ -576,7 +574,7 @@ test_expect_success 'autosetuprebase always on a tracked local branch' '
test_expect_success 'autosetuprebase remote on a tracked local branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- git config branch.autosetuprebase remote &&
+ test_config branch.autosetuprebase remote &&
(git show-ref -q refs/remotes/local/o || git fetch local) &&
git branch mybase3 &&
git branch --track myr3 mybase2 &&
@@ -588,7 +586,7 @@ test_expect_success 'autosetuprebase remote on a tracked local branch' '
test_expect_success 'autosetuprebase never on a tracked local branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- git config branch.autosetuprebase never &&
+ test_config branch.autosetuprebase never &&
(git show-ref -q refs/remotes/local/o || git fetch local) &&
git branch mybase4 &&
git branch --track myr4 mybase2 &&
@@ -600,7 +598,7 @@ test_expect_success 'autosetuprebase never on a tracked local branch' '
test_expect_success 'autosetuprebase local on a tracked remote branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- git config branch.autosetuprebase local &&
+ test_config branch.autosetuprebase local &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
git branch --track myr5 local/master &&
test "$(git config branch.myr5.remote)" = local &&
@@ -611,7 +609,7 @@ test_expect_success 'autosetuprebase local on a tracked remote branch' '
test_expect_success 'autosetuprebase never on a tracked remote branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- git config branch.autosetuprebase never &&
+ test_config branch.autosetuprebase never &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
git branch --track myr6 local/master &&
test "$(git config branch.myr6.remote)" = local &&
@@ -622,7 +620,7 @@ test_expect_success 'autosetuprebase never on a tracked remote branch' '
test_expect_success 'autosetuprebase remote on a tracked remote branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- git config branch.autosetuprebase remote &&
+ test_config branch.autosetuprebase remote &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
git branch --track myr7 local/master &&
test "$(git config branch.myr7.remote)" = local &&
@@ -633,7 +631,7 @@ test_expect_success 'autosetuprebase remote on a tracked remote branch' '
test_expect_success 'autosetuprebase always on a tracked remote branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- git config branch.autosetuprebase remote &&
+ test_config branch.autosetuprebase remote &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
git branch --track myr8 local/master &&
test "$(git config branch.myr8.remote)" = local &&
@@ -642,7 +640,7 @@ test_expect_success 'autosetuprebase always on a tracked remote branch' '
'
test_expect_success 'autosetuprebase unconfigured on a tracked remote branch' '
- git config --unset branch.autosetuprebase &&
+ test_unconfig branch.autosetuprebase &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
@@ -684,7 +682,7 @@ test_expect_success 'autosetuprebase unconfigured on untracked remote branch' '
'
test_expect_success 'autosetuprebase never on an untracked local branch' '
- git config branch.autosetuprebase never &&
+ test_config branch.autosetuprebase never &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
@@ -695,7 +693,7 @@ test_expect_success 'autosetuprebase never on an untracked local branch' '
'
test_expect_success 'autosetuprebase local on an untracked local branch' '
- git config branch.autosetuprebase local &&
+ test_config branch.autosetuprebase local &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
@@ -706,7 +704,7 @@ test_expect_success 'autosetuprebase local on an untracked local branch' '
'
test_expect_success 'autosetuprebase remote on an untracked local branch' '
- git config branch.autosetuprebase remote &&
+ test_config branch.autosetuprebase remote &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
@@ -717,7 +715,7 @@ test_expect_success 'autosetuprebase remote on an untracked local branch' '
'
test_expect_success 'autosetuprebase always on an untracked local branch' '
- git config branch.autosetuprebase always &&
+ test_config branch.autosetuprebase always &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
@@ -728,7 +726,7 @@ test_expect_success 'autosetuprebase always on an untracked local branch' '
'
test_expect_success 'autosetuprebase never on an untracked remote branch' '
- git config branch.autosetuprebase never &&
+ test_config branch.autosetuprebase never &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
@@ -739,7 +737,7 @@ test_expect_success 'autosetuprebase never on an untracked remote branch' '
'
test_expect_success 'autosetuprebase local on an untracked remote branch' '
- git config branch.autosetuprebase local &&
+ test_config branch.autosetuprebase local &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
@@ -750,7 +748,7 @@ test_expect_success 'autosetuprebase local on an untracked remote branch' '
'
test_expect_success 'autosetuprebase remote on an untracked remote branch' '
- git config branch.autosetuprebase remote &&
+ test_config branch.autosetuprebase remote &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
@@ -761,7 +759,7 @@ test_expect_success 'autosetuprebase remote on an untracked remote branch' '
'
test_expect_success 'autosetuprebase always on an untracked remote branch' '
- git config branch.autosetuprebase always &&
+ test_config branch.autosetuprebase always &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
@@ -772,8 +770,8 @@ test_expect_success 'autosetuprebase always on an untracked remote branch' '
'
test_expect_success 'autosetuprebase always on detached HEAD' '
- git config branch.autosetupmerge always &&
- test_when_finished git checkout master &&
+ test_when_finished "git checkout -" &&
+ test_config branch.autosetupmerge always &&
git checkout HEAD^0 &&
git branch my11 &&
test -z "$(git config branch.my11.remote)" &&
@@ -781,15 +779,15 @@ test_expect_success 'autosetuprebase always on detached HEAD' '
'
test_expect_success 'detect misconfigured autosetuprebase (bad value)' '
- git config branch.autosetuprebase garbage &&
+ test_config branch.autosetuprebase garbage &&
test_must_fail git branch
'
test_expect_success 'detect misconfigured autosetuprebase (no value)' '
- git config --unset branch.autosetuprebase &&
+ test_when_finished "test_unconfig branch.autosetuprebase" &&
+ test_unconfig branch.autosetuprebase &&
echo "[branch] autosetuprebase" >>.git/config &&
- test_must_fail git branch &&
- git config --unset branch.autosetuprebase
+ test_must_fail git branch
'
test_expect_success 'attempt to delete a branch without base and unmerged to HEAD' '
@@ -856,6 +854,7 @@ test_expect_success 'detect typo in branch name when using --edit-description' '
'
test_expect_success 'refuse --edit-description on unborn branch for now' '
+ test_when_finished "git checkout -" &&
write_script editor <<-\EOF &&
echo "New contents" >"$1"
EOF
--
1.8.4-fc
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 1/4] t: branch: trivial style fix
2013-08-31 4:31 ` [PATCH 1/4] t: branch: trivial style fix Felipe Contreras
@ 2013-09-03 19:13 ` Junio C Hamano
0 siblings, 0 replies; 14+ messages in thread
From: Junio C Hamano @ 2013-09-03 19:13 UTC (permalink / raw)
To: Felipe Contreras; +Cc: git
The first three are trivially correct and good changes. I still have
to read the last one, but wanted to give a Thanks before doing so,
which would take more time.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 4/4] t: branch: improve test rollback
2013-08-31 4:31 ` [PATCH 4/4] t: branch: improve test rollback Felipe Contreras
@ 2013-09-03 19:32 ` Junio C Hamano
2013-09-03 22:10 ` Felipe Contreras
0 siblings, 1 reply; 14+ messages in thread
From: Junio C Hamano @ 2013-09-03 19:32 UTC (permalink / raw)
To: Felipe Contreras; +Cc: git
Felipe Contreras <felipe.contreras@gmail.com> writes:
> After every test the environment should be as close as to how it was
> before as possible.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
Very good in general; a few points (not "the patch breaks things",
but more like "tests after the patch are still depending on the
previous state") below, though.
> t/t3200-branch.sh | 71 +++++++++++++++++++++++++++----------------------------
> 1 file changed, 35 insertions(+), 36 deletions(-)
>
> diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
> index d85306f..3d4f634 100755
> --- a/t/t3200-branch.sh
> +++ b/t/t3200-branch.sh
> @@ -328,7 +328,7 @@ test_expect_success 'tracking setup fails on non-matching refspec' '
> '
>
> test_expect_success 'test tracking setup via config' '
> - git config branch.autosetupmerge true &&
> + test_config branch.autosetupmerge true &&
> git config remote.local.url . &&
> git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
> (git show-ref -q refs/remotes/local/master || git fetch local) &&
> @@ -338,20 +338,18 @@ test_expect_success 'test tracking setup via config' '
> '
>
> test_expect_success 'test overriding tracking setup via --no-track' '
> - git config branch.autosetupmerge true &&
> + test_config branch.autosetupmerge true &&
> git config remote.local.url . &&
> git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
> (git show-ref -q refs/remotes/local/master || git fetch local) &&
> git branch --no-track my2 local/master &&
> - git config branch.autosetupmerge false &&
> ! test "$(git config branch.my2.remote)" = local &&
> ! test "$(git config branch.my2.merge)" = refs/heads/master
> '
>
> test_expect_success 'no tracking without .fetch entries' '
> - git config branch.autosetupmerge true &&
> + test_config branch.autosetupmerge true &&
> git branch my6 s &&
> - git config branch.autosetupmerge false &&
> test -z "$(git config branch.my6.remote)" &&
> test -z "$(git config branch.my6.merge)"
> '
The four tests after this one used to expect to start with
branch.autosetupmerge explicitly set to false, but this change
leaves the variable unset---as a side effect we start testing a
different thing. As long as we do not introduce a bug that allows
an exlicit branch.autosetupmerge=false defeat --track on the command
line, this side effect does not hurt, but I think the 'test tracking
setup via --track but deeper' was the only test that checks this
interaction between 'false in config, --track on the command line'
combination.
> @@ -386,9 +384,8 @@ test_expect_success 'test --track without .fetch entries' '
> '
>
> test_expect_success 'branch from non-branch HEAD w/autosetupmerge=always' '
> - git config branch.autosetupmerge always &&
> - git branch my9 HEAD^ &&
> - git config branch.autosetupmerge false
> + test_config branch.autosetupmerge always &&
> + git branch my9 HEAD^
> '
Likewise for three subsequent tests but what they test are not
primarily whether tracking is done, so it does not matter as much as
the previous.
> test_expect_success 'branch from non-branch HEAD w/--track causes failure' '
> @@ -405,9 +402,9 @@ test_expect_success '--set-upstream-to fails on multiple branches' '
> '
>
> test_expect_success '--set-upstream-to fails on detached HEAD' '
> + test_when_finished "git checkout -" &&
> git checkout HEAD^{} &&
> - test_must_fail git branch --set-upstream-to master &&
> - git checkout -
> + test_must_fail git branch --set-upstream-to master
> '
>
> test_expect_success '--set-upstream-to fails on a missing dst branch' '
> @@ -459,9 +456,9 @@ test_expect_success '--unset-upstream should fail on multiple branches' '
> '
>
> test_expect_success '--unset-upstream should fail on detached HEAD' '
> + test_when_finished "git checkout -" &&
> git checkout HEAD^{} &&
> - test_must_fail git branch --unset-upstream &&
> - git checkout -
> + test_must_fail git branch --unset-upstream
> '
>
> test_expect_success 'test --unset-upstream on a particular branch' '
> @@ -540,7 +537,8 @@ test_expect_success 'checkout -b with -l makes reflog when core.logAllRefUpdates
> '
>
> test_expect_success 'avoid ambiguous track' '
> - git config branch.autosetupmerge true &&
> + test_when_finished "git remote rm ambi1 && git remote rm ambi2" &&
> + test_config branch.autosetupmerge true &&
> git config remote.ambi1.url lalala &&
> git config remote.ambi1.fetch refs/heads/lalala:refs/heads/master &&
> git config remote.ambi2.url lilili &&
> @@ -552,7 +550,7 @@ test_expect_success 'avoid ambiguous track' '
> test_expect_success 'autosetuprebase local on a tracked local branch' '
> git config remote.local.url . &&
> git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
> - git config branch.autosetuprebase local &&
> + test_config branch.autosetuprebase local &&
> (git show-ref -q refs/remotes/local/o || git fetch local) &&
> git branch mybase &&
> git branch --track myr1 mybase &&
> @@ -564,7 +562,7 @@ test_expect_success 'autosetuprebase local on a tracked local branch' '
> test_expect_success 'autosetuprebase always on a tracked local branch' '
> git config remote.local.url . &&
> git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
> - git config branch.autosetuprebase always &&
> + test_config branch.autosetuprebase always &&
> (git show-ref -q refs/remotes/local/o || git fetch local) &&
> git branch mybase2 &&
> git branch --track myr2 mybase &&
> @@ -576,7 +574,7 @@ test_expect_success 'autosetuprebase always on a tracked local branch' '
> test_expect_success 'autosetuprebase remote on a tracked local branch' '
> git config remote.local.url . &&
> git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
> - git config branch.autosetuprebase remote &&
> + test_config branch.autosetuprebase remote &&
> (git show-ref -q refs/remotes/local/o || git fetch local) &&
> git branch mybase3 &&
> git branch --track myr3 mybase2 &&
> @@ -588,7 +586,7 @@ test_expect_success 'autosetuprebase remote on a tracked local branch' '
> test_expect_success 'autosetuprebase never on a tracked local branch' '
> git config remote.local.url . &&
> git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
> - git config branch.autosetuprebase never &&
> + test_config branch.autosetuprebase never &&
> (git show-ref -q refs/remotes/local/o || git fetch local) &&
> git branch mybase4 &&
> git branch --track myr4 mybase2 &&
> @@ -600,7 +598,7 @@ test_expect_success 'autosetuprebase never on a tracked local branch' '
> test_expect_success 'autosetuprebase local on a tracked remote branch' '
> git config remote.local.url . &&
> git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
> - git config branch.autosetuprebase local &&
> + test_config branch.autosetuprebase local &&
> (git show-ref -q refs/remotes/local/master || git fetch local) &&
> git branch --track myr5 local/master &&
> test "$(git config branch.myr5.remote)" = local &&
> @@ -611,7 +609,7 @@ test_expect_success 'autosetuprebase local on a tracked remote branch' '
> test_expect_success 'autosetuprebase never on a tracked remote branch' '
> git config remote.local.url . &&
> git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
> - git config branch.autosetuprebase never &&
> + test_config branch.autosetuprebase never &&
> (git show-ref -q refs/remotes/local/master || git fetch local) &&
> git branch --track myr6 local/master &&
> test "$(git config branch.myr6.remote)" = local &&
> @@ -622,7 +620,7 @@ test_expect_success 'autosetuprebase never on a tracked remote branch' '
> test_expect_success 'autosetuprebase remote on a tracked remote branch' '
> git config remote.local.url . &&
> git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
> - git config branch.autosetuprebase remote &&
> + test_config branch.autosetuprebase remote &&
> (git show-ref -q refs/remotes/local/master || git fetch local) &&
> git branch --track myr7 local/master &&
> test "$(git config branch.myr7.remote)" = local &&
> @@ -633,7 +631,7 @@ test_expect_success 'autosetuprebase remote on a tracked remote branch' '
> test_expect_success 'autosetuprebase always on a tracked remote branch' '
> git config remote.local.url . &&
> git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
> - git config branch.autosetuprebase remote &&
> + test_config branch.autosetuprebase remote &&
> (git show-ref -q refs/remotes/local/master || git fetch local) &&
> git branch --track myr8 local/master &&
> test "$(git config branch.myr8.remote)" = local &&
> @@ -642,7 +640,7 @@ test_expect_success 'autosetuprebase always on a tracked remote branch' '
> '
>
> test_expect_success 'autosetuprebase unconfigured on a tracked remote branch' '
> - git config --unset branch.autosetuprebase &&
> + test_unconfig branch.autosetuprebase &&
> git config remote.local.url . &&
> git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
> (git show-ref -q refs/remotes/local/master || git fetch local) &&
> @@ -684,7 +682,7 @@ test_expect_success 'autosetuprebase unconfigured on untracked remote branch' '
> '
>
> test_expect_success 'autosetuprebase never on an untracked local branch' '
> - git config branch.autosetuprebase never &&
> + test_config branch.autosetuprebase never &&
> git config remote.local.url . &&
> git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
> (git show-ref -q refs/remotes/local/master || git fetch local) &&
> @@ -695,7 +693,7 @@ test_expect_success 'autosetuprebase never on an untracked local branch' '
> '
>
> test_expect_success 'autosetuprebase local on an untracked local branch' '
> - git config branch.autosetuprebase local &&
> + test_config branch.autosetuprebase local &&
> git config remote.local.url . &&
> git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
> (git show-ref -q refs/remotes/local/master || git fetch local) &&
> @@ -706,7 +704,7 @@ test_expect_success 'autosetuprebase local on an untracked local branch' '
> '
>
> test_expect_success 'autosetuprebase remote on an untracked local branch' '
> - git config branch.autosetuprebase remote &&
> + test_config branch.autosetuprebase remote &&
> git config remote.local.url . &&
> git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
> (git show-ref -q refs/remotes/local/master || git fetch local) &&
> @@ -717,7 +715,7 @@ test_expect_success 'autosetuprebase remote on an untracked local branch' '
> '
>
> test_expect_success 'autosetuprebase always on an untracked local branch' '
> - git config branch.autosetuprebase always &&
> + test_config branch.autosetuprebase always &&
> git config remote.local.url . &&
> git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
> (git show-ref -q refs/remotes/local/master || git fetch local) &&
> @@ -728,7 +726,7 @@ test_expect_success 'autosetuprebase always on an untracked local branch' '
> '
>
> test_expect_success 'autosetuprebase never on an untracked remote branch' '
> - git config branch.autosetuprebase never &&
> + test_config branch.autosetuprebase never &&
> git config remote.local.url . &&
> git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
> (git show-ref -q refs/remotes/local/master || git fetch local) &&
> @@ -739,7 +737,7 @@ test_expect_success 'autosetuprebase never on an untracked remote branch' '
> '
>
> test_expect_success 'autosetuprebase local on an untracked remote branch' '
> - git config branch.autosetuprebase local &&
> + test_config branch.autosetuprebase local &&
> git config remote.local.url . &&
> git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
> (git show-ref -q refs/remotes/local/master || git fetch local) &&
> @@ -750,7 +748,7 @@ test_expect_success 'autosetuprebase local on an untracked remote branch' '
> '
>
> test_expect_success 'autosetuprebase remote on an untracked remote branch' '
> - git config branch.autosetuprebase remote &&
> + test_config branch.autosetuprebase remote &&
> git config remote.local.url . &&
> git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
> (git show-ref -q refs/remotes/local/master || git fetch local) &&
> @@ -761,7 +759,7 @@ test_expect_success 'autosetuprebase remote on an untracked remote branch' '
> '
>
> test_expect_success 'autosetuprebase always on an untracked remote branch' '
> - git config branch.autosetuprebase always &&
> + test_config branch.autosetuprebase always &&
> git config remote.local.url . &&
> git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
> (git show-ref -q refs/remotes/local/master || git fetch local) &&
> @@ -772,8 +770,8 @@ test_expect_success 'autosetuprebase always on an untracked remote branch' '
> '
>
> test_expect_success 'autosetuprebase always on detached HEAD' '
> - git config branch.autosetupmerge always &&
> - test_when_finished git checkout master &&
> + test_when_finished "git checkout -" &&
I think the explicit 'master' was better. We are not in the
business of checking @{-1} completion here, and depending on the
outcome of the "git checkout" in the test, "checkout -" will take us
to a different place, no?
> + test_config branch.autosetupmerge always &&
This used to be propagated down, but now branch.autosetupmerge is
kept unset after this. The tests after this one do not seem to
newly create branches that need auto-setup-merge, so I think this
change is very good.
> git checkout HEAD^0 &&
> git branch my11 &&
> test -z "$(git config branch.my11.remote)" &&
> @@ -781,15 +779,15 @@ test_expect_success 'autosetuprebase always on detached HEAD' '
> '
>
> test_expect_success 'detect misconfigured autosetuprebase (bad value)' '
> - git config branch.autosetuprebase garbage &&
> + test_config branch.autosetuprebase garbage &&
> test_must_fail git branch
> '
>
> test_expect_success 'detect misconfigured autosetuprebase (no value)' '
> - git config --unset branch.autosetuprebase &&
> + test_when_finished "test_unconfig branch.autosetuprebase" &&
> + test_unconfig branch.autosetuprebase &&
> echo "[branch] autosetuprebase" >>.git/config &&
> - test_must_fail git branch &&
> - git config --unset branch.autosetuprebase
> + test_must_fail git branch
> '
>
> test_expect_success 'attempt to delete a branch without base and unmerged to HEAD' '
> @@ -856,6 +854,7 @@ test_expect_success 'detect typo in branch name when using --edit-description' '
> '
>
> test_expect_success 'refuse --edit-description on unborn branch for now' '
> + test_when_finished "git checkout -" &&
I am not sure if this is a good change. Depending on the outcome of
the "git checkout" in the test (it may succeed and set @{-1} to the
branch we were on when we entered the test, or it may fail and leave
@{-1} to the branch before we were on when we entered the test),
this will take us to a different place, no?
> write_script editor <<-\EOF &&
> echo "New contents" >"$1"
> EOF
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 4/4] t: branch: improve test rollback
2013-09-03 19:32 ` Junio C Hamano
@ 2013-09-03 22:10 ` Felipe Contreras
2013-09-03 22:59 ` Junio C Hamano
0 siblings, 1 reply; 14+ messages in thread
From: Felipe Contreras @ 2013-09-03 22:10 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Tue, Sep 3, 2013 at 2:32 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>> test_expect_success 'refuse --edit-description on unborn branch for now' '
>> + test_when_finished "git checkout -" &&
>
> I am not sure if this is a good change. Depending on the outcome of
> the "git checkout" in the test (it may succeed and set @{-1} to the
> branch we were on when we entered the test, or it may fail and leave
> @{-1} to the branch before we were on when we entered the test),
> this will take us to a different place, no?
It is better than leaving Git in an unborn branch. Many tests could
not care which is the current branch, as long as HEAD does points to a
branch, and that is the default, the tests should be messing with the
default.
--
Felipe Contreras
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 4/4] t: branch: improve test rollback
2013-09-03 22:10 ` Felipe Contreras
@ 2013-09-03 22:59 ` Junio C Hamano
2013-09-03 23:03 ` Felipe Contreras
0 siblings, 1 reply; 14+ messages in thread
From: Junio C Hamano @ 2013-09-03 22:59 UTC (permalink / raw)
To: Felipe Contreras; +Cc: git
Felipe Contreras <felipe.contreras@gmail.com> writes:
> On Tue, Sep 3, 2013 at 2:32 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>>> test_expect_success 'refuse --edit-description on unborn branch for now' '
>>> + test_when_finished "git checkout -" &&
>>
>> I am not sure if this is a good change. Depending on the outcome of
>> the "git checkout" in the test (it may succeed and set @{-1} to the
>> branch we were on when we entered the test, or it may fail and leave
>> @{-1} to the branch before we were on when we entered the test),
>> this will take us to a different place, no?
>
> It is better than leaving Git in an unborn branch.
True, but it falls short of "After every test the environment should
be as close as to how it was before as possible.", doesn't it?
I think the fix is just to use the name of a concrete branch,
instead of "-", which could be far quickly done than making excuses
like that.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 4/4] t: branch: improve test rollback
2013-09-03 22:59 ` Junio C Hamano
@ 2013-09-03 23:03 ` Felipe Contreras
2013-09-04 17:19 ` Junio C Hamano
0 siblings, 1 reply; 14+ messages in thread
From: Felipe Contreras @ 2013-09-03 23:03 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Tue, Sep 3, 2013 at 5:59 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> On Tue, Sep 3, 2013 at 2:32 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>
>>>> test_expect_success 'refuse --edit-description on unborn branch for now' '
>>>> + test_when_finished "git checkout -" &&
>>>
>>> I am not sure if this is a good change. Depending on the outcome of
>>> the "git checkout" in the test (it may succeed and set @{-1} to the
>>> branch we were on when we entered the test, or it may fail and leave
>>> @{-1} to the branch before we were on when we entered the test),
>>> this will take us to a different place, no?
>>
>> It is better than leaving Git in an unborn branch.
>
> True, but it falls short of "After every test the environment should
> be as close as to how it was before as possible.", doesn't it?
No it doesn't. Closer is closer.
> I think the fix is just to use the name of a concrete branch,
> instead of "-", which could be far quickly done than making excuses
> like that.
The fix is to write a test_checkout that would save the previous HEAD
and restore it after the test, or something similar. But I'm not going
to write that, and I bet nobody else is, so unless you want the tests
to remain in the crappy state they are, "git checkout -" is the best
sensible option.
--
Felipe Contreras
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 4/4] t: branch: improve test rollback
2013-09-03 23:03 ` Felipe Contreras
@ 2013-09-04 17:19 ` Junio C Hamano
2013-09-08 3:02 ` Felipe Contreras
0 siblings, 1 reply; 14+ messages in thread
From: Junio C Hamano @ 2013-09-04 17:19 UTC (permalink / raw)
To: Felipe Contreras; +Cc: git
Felipe Contreras <felipe.contreras@gmail.com> writes:
> On Tue, Sep 3, 2013 at 5:59 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>
>>> On Tue, Sep 3, 2013 at 2:32 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>>
>>>>> test_expect_success 'refuse --edit-description on unborn branch for now' '
>>>>> + test_when_finished "git checkout -" &&
>>>>
>>>> I am not sure if this is a good change. Depending on the outcome of
>>>> the "git checkout" in the test (it may succeed and set @{-1} to the
>>>> branch we were on when we entered the test, or it may fail and leave
>>>> @{-1} to the branch before we were on when we entered the test),
>>>> this will take us to a different place, no?
>>>
>>> It is better than leaving Git in an unborn branch.
>>
>> True, but it falls short of "After every test the environment should
>> be as close as to how it was before as possible.", doesn't it?
>
> No it doesn't. Closer is closer.
Closer is not "as close as ... possible".
I think the fix is just to use the name of a concrete branch we want
the next test to start on, instead of "-", which could be far
quickly done than making excuses like that.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 4/4] t: branch: improve test rollback
2013-09-04 17:19 ` Junio C Hamano
@ 2013-09-08 3:02 ` Felipe Contreras
2013-09-08 4:56 ` Jeff King
0 siblings, 1 reply; 14+ messages in thread
From: Felipe Contreras @ 2013-09-08 3:02 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Wed, Sep 4, 2013 at 12:19 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> On Tue, Sep 3, 2013 at 5:59 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>>
>>>> On Tue, Sep 3, 2013 at 2:32 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>>>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>>>
>>>>>> test_expect_success 'refuse --edit-description on unborn branch for now' '
>>>>>> + test_when_finished "git checkout -" &&
>>>>>
>>>>> I am not sure if this is a good change. Depending on the outcome of
>>>>> the "git checkout" in the test (it may succeed and set @{-1} to the
>>>>> branch we were on when we entered the test, or it may fail and leave
>>>>> @{-1} to the branch before we were on when we entered the test),
>>>>> this will take us to a different place, no?
>>>>
>>>> It is better than leaving Git in an unborn branch.
>>>
>>> True, but it falls short of "After every test the environment should
>>> be as close as to how it was before as possible.", doesn't it?
>>
>> No it doesn't. Closer is closer.
>
> Closer is not "as close as ... possible".
Yes it is, because there are no better alternatives within our
ability, capacity, or realization.
http://www.merriam-webster.com/dictionary/possible
> I think the fix is just to use the name of a concrete branch we want
> the next test to start on, instead of "-", which could be far
> quickly done than making excuses like that.
No, what if that test is skipped for some reason? Ideally each test
case should do 'git checkout $branch_i_need', not rely on the previous
tests to checkout the branch they need, but that requires too much
work to fix.
'git checkout -' works perfectly fine, and it's the closest we have to
my suggested test_checkout() which I think would be ideal, but I'm not
going to work on.
--
Felipe Contreras
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 4/4] t: branch: improve test rollback
2013-09-08 3:02 ` Felipe Contreras
@ 2013-09-08 4:56 ` Jeff King
2013-09-08 5:01 ` Felipe Contreras
0 siblings, 1 reply; 14+ messages in thread
From: Jeff King @ 2013-09-08 4:56 UTC (permalink / raw)
To: Felipe Contreras; +Cc: Junio C Hamano, git
On Sat, Sep 07, 2013 at 10:02:59PM -0500, Felipe Contreras wrote:
> 'git checkout -' works perfectly fine, and it's the closest we have to
> my suggested test_checkout() which I think would be ideal, but I'm not
> going to work on.
I do not think it works perfectly fine if the checkout itself fails. For
example, after your patch, one of the tests reads:
test_when_finished "git checkout -" &&
git checkout HEAD^{} &&
test_must_fail git branch --set-upstream-to master
The cleanup is undoing what happened on the second line. So if we fail
on the third line, it does what we want. If we fail on the second line,
then what branch are switching to?
I think you would at least want to reverse the order as:
git checkout HEAD^{} &&
test_when_finished "git checkout -" &&
test_must_fail git branch --set-upstream-to master
so that you know you are actually going to the pre-test state.
-Peff
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 4/4] t: branch: improve test rollback
2013-09-08 4:56 ` Jeff King
@ 2013-09-08 5:01 ` Felipe Contreras
0 siblings, 0 replies; 14+ messages in thread
From: Felipe Contreras @ 2013-09-08 5:01 UTC (permalink / raw)
To: Jeff King; +Cc: Junio C Hamano, git
On Sat, Sep 7, 2013 at 11:56 PM, Jeff King <peff@peff.net> wrote:
> On Sat, Sep 07, 2013 at 10:02:59PM -0500, Felipe Contreras wrote:
>
>> 'git checkout -' works perfectly fine, and it's the closest we have to
>> my suggested test_checkout() which I think would be ideal, but I'm not
>> going to work on.
>
> I do not think it works perfectly fine if the checkout itself fails. For
> example, after your patch, one of the tests reads:
>
> test_when_finished "git checkout -" &&
> git checkout HEAD^{} &&
> test_must_fail git branch --set-upstream-to master
>
> The cleanup is undoing what happened on the second line. So if we fail
> on the third line, it does what we want. If we fail on the second line,
> then what branch are switching to?
>
> I think you would at least want to reverse the order as:
>
> git checkout HEAD^{} &&
> test_when_finished "git checkout -" &&
> test_must_fail git branch --set-upstream-to master
>
> so that you know you are actually going to the pre-test state.
Yeah, that would be better and easily achievable.
--
Felipe Contreras
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2013-09-08 5:01 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-31 4:31 [PATCH 0/4] t: branch: fixes and cleanups Felipe Contreras
2013-08-31 4:31 ` [PATCH 1/4] t: branch: trivial style fix Felipe Contreras
2013-09-03 19:13 ` Junio C Hamano
2013-08-31 4:31 ` [PATCH 2/4] t: branch: fix typo Felipe Contreras
2013-08-31 4:31 ` [PATCH 3/4] t: branch: fix broken && chains Felipe Contreras
2013-08-31 4:31 ` [PATCH 4/4] t: branch: improve test rollback Felipe Contreras
2013-09-03 19:32 ` Junio C Hamano
2013-09-03 22:10 ` Felipe Contreras
2013-09-03 22:59 ` Junio C Hamano
2013-09-03 23:03 ` Felipe Contreras
2013-09-04 17:19 ` Junio C Hamano
2013-09-08 3:02 ` Felipe Contreras
2013-09-08 4:56 ` Jeff King
2013-09-08 5:01 ` Felipe Contreras
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).