From 2f139044f96227deb8332942627a04b29c70c2bf Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Thu, 8 Dec 2011 18:40:15 +0530 Subject: [PATCH 1/7] t3200 (branch): fix '&&' chaining Breaks in a test assertion's && chain can potentially hide failures from earlier commands in the chain. Fix these breaks. The 'git branch --help' in the test may fail if git manual pages are not installed, but the point of the test is to make sure it does not create a bogus branch "--help", so run it under 'test_might_fail'. Helped-by: Jonathan Nieder Signed-off-by: Ramkumar Ramachandra Acked-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/t3200-branch.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index bc73c2099b..724ff9de4b 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -22,7 +22,7 @@ test_expect_success \ test_expect_success \ 'git branch --help should not have created a bogus branch' ' - git branch --help /dev/null 2>/dev/null; + test_might_fail git branch --help /dev/null 2>/dev/null && test_path_is_missing .git/refs/heads/--help ' @@ -88,7 +88,7 @@ test_expect_success \ test_expect_success \ 'git branch -m n/n n should work' \ 'git branch -l n/n && - git branch -m n/n n + git branch -m n/n n && test_path_is_file .git/logs/refs/heads/n' test_expect_success 'git branch -m o/o o should fail when o/p exists' ' From 02380389c6d4656c0cc94d33f9811636cb5953e4 Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Thu, 8 Dec 2011 18:40:17 +0530 Subject: [PATCH 2/7] test: fix '&&' chaining Breaks in a test assertion's && chain can potentially hide failures from earlier commands in the chain by adding " &&" at the end of line to the commands that need them. Signed-off-by: Ramkumar Ramachandra Acked-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/t1007-hash-object.sh | 2 +- t/t1013-loose-object-format.sh | 2 +- t/t1300-repo-config.sh | 2 +- t/t1412-reflog-loop.sh | 2 +- t/t1510-repo-setup.sh | 4 ++-- t/t1511-rev-parse-caret.sh | 2 +- t/t3310-notes-merge-manual-resolve.sh | 10 +++++----- t/t3400-rebase.sh | 4 ++-- t/t3418-rebase-continue.sh | 4 ++-- t/t3419-rebase-patch-id.sh | 2 +- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh index 6d52b824b1..f83df8eb8b 100755 --- a/t/t1007-hash-object.sh +++ b/t/t1007-hash-object.sh @@ -189,7 +189,7 @@ for args in "-w --stdin-paths" "--stdin-paths -w"; do done test_expect_success 'corrupt tree' ' - echo abc >malformed-tree + echo abc >malformed-tree && test_must_fail git hash-object -t tree malformed-tree ' diff --git a/t/t1013-loose-object-format.sh b/t/t1013-loose-object-format.sh index 0a9cedd374..fbf5f2fc00 100755 --- a/t/t1013-loose-object-format.sh +++ b/t/t1013-loose-object-format.sh @@ -34,7 +34,7 @@ assert_blob_equals() { } test_expect_success setup ' - cp -R "$TEST_DIRECTORY/t1013/objects" .git/ + cp -R "$TEST_DIRECTORY/t1013/objects" .git/ && git --version ' diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 51caff047b..0690e0edf4 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -38,7 +38,7 @@ cat > expect << EOF WhatEver = Second EOF test_expect_success 'similar section' ' - git config Cores.WhatEver Second + git config Cores.WhatEver Second && test_cmp expect .git/config ' diff --git a/t/t1412-reflog-loop.sh b/t/t1412-reflog-loop.sh index 647d888507..3acd895afb 100755 --- a/t/t1412-reflog-loop.sh +++ b/t/t1412-reflog-loop.sh @@ -20,7 +20,7 @@ test_expect_success 'setup reflog with alternating commits' ' ' test_expect_success 'reflog shows all entries' ' - cat >expect <<-\EOF + cat >expect <<-\EOF && topic@{0} reset: moving to two topic@{1} reset: moving to one topic@{2} reset: moving to two diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh index ec50a9ad70..80aedfca8c 100755 --- a/t/t1510-repo-setup.sh +++ b/t/t1510-repo-setup.sh @@ -603,7 +603,7 @@ test_expect_success '#22a: core.worktree = GIT_DIR = .git dir' ' # like case #6. setup_repo 22a "$here/22a/.git" "" unset && - setup_repo 22ab . "" unset + setup_repo 22ab . "" unset && mkdir -p 22a/.git/sub 22a/sub && mkdir -p 22ab/.git/sub 22ab/sub && try_case 22a/.git unset . \ @@ -742,7 +742,7 @@ test_expect_success '#28: core.worktree and core.bare conflict (gitfile case)' ' # Case #29: GIT_WORK_TREE(+core.worktree) overrides core.bare (gitfile case). test_expect_success '#29: setup' ' setup_repo 29 non-existent gitfile true && - mkdir -p 29/sub/sub 29/wt/sub + mkdir -p 29/sub/sub 29/wt/sub && ( cd 29 && GIT_WORK_TREE="$here/29" && diff --git a/t/t1511-rev-parse-caret.sh b/t/t1511-rev-parse-caret.sh index e043cb7c64..eaefc777bd 100755 --- a/t/t1511-rev-parse-caret.sh +++ b/t/t1511-rev-parse-caret.sh @@ -6,7 +6,7 @@ test_description='tests for ref^{stuff}' test_expect_success 'setup' ' echo blob >a-blob && - git tag -a -m blob blob-tag `git hash-object -w a-blob` + git tag -a -m blob blob-tag `git hash-object -w a-blob` && mkdir a-tree && echo moreblobs >a-tree/another-blob && git add . && diff --git a/t/t3310-notes-merge-manual-resolve.sh b/t/t3310-notes-merge-manual-resolve.sh index 4ec4d11450..4367197953 100755 --- a/t/t3310-notes-merge-manual-resolve.sh +++ b/t/t3310-notes-merge-manual-resolve.sh @@ -389,7 +389,7 @@ test_expect_success 'abort notes merge' ' test_must_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && test_cmp /dev/null output && # m has not moved (still == y) - test "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)" + test "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)" && # Verify that other notes refs has not changed (w, x, y and z) verify_notes w && verify_notes x && @@ -525,9 +525,9 @@ EOF test -f .git/NOTES_MERGE_WORKTREE/$commit_sha3 && test -f .git/NOTES_MERGE_WORKTREE/$commit_sha4 && # Refs are unchanged - test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" - test "$(git rev-parse refs/notes/y)" = "$(git rev-parse NOTES_MERGE_PARTIAL^1)" - test "$(git rev-parse refs/notes/m)" != "$(git rev-parse NOTES_MERGE_PARTIAL^1)" + test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" && + test "$(git rev-parse refs/notes/y)" = "$(git rev-parse NOTES_MERGE_PARTIAL^1)" && + test "$(git rev-parse refs/notes/m)" != "$(git rev-parse NOTES_MERGE_PARTIAL^1)" && # Mention refs/notes/m, and its current and expected value in output grep -q "refs/notes/m" output && grep -q "$(git rev-parse refs/notes/m)" output && @@ -545,7 +545,7 @@ test_expect_success 'resolve situation by aborting the notes merge' ' test_must_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && test_cmp /dev/null output && # m has not moved (still == w) - test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" + test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" && # Verify that other notes refs has not changed (w, x, y and z) verify_notes w && verify_notes x && diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh index 6eaecec906..c355533236 100755 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@ -172,8 +172,8 @@ test_expect_success 'fail when upstream arg is missing and not configured' ' test_expect_success 'default to @{upstream} when upstream arg is missing' ' git checkout -b default topic && - git config branch.default.remote . - git config branch.default.merge refs/heads/master + git config branch.default.remote . && + git config branch.default.merge refs/heads/master && git rebase && test "$(git rev-parse default~1)" = "$(git rev-parse master)" ' diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh index 1e855cdae5..2680375628 100755 --- a/t/t3418-rebase-continue.sh +++ b/t/t3418-rebase-continue.sh @@ -51,7 +51,7 @@ test_expect_success 'rebase --continue remembers merge strategy and options' ' test_commit "commit-new-file-F3-on-topic-branch" F3 32 && test_when_finished "rm -fr test-bin funny.was.run" && mkdir test-bin && - cat >test-bin/git-merge-funny <<-EOF + cat >test-bin/git-merge-funny <<-EOF && #!$SHELL_PATH case "\$1" in --opt) ;; *) exit 2 ;; esac shift && @@ -77,7 +77,7 @@ test_expect_success 'rebase --continue remembers merge strategy and options' ' test_expect_success 'rebase --continue remembers --rerere-autoupdate' ' rm -fr .git/rebase-* && git reset --hard commit-new-file-F3-on-topic-branch && - git checkout master + git checkout master && test_commit "commit-new-file-F3" F3 3 && git config rerere.enabled true && test_must_fail git rebase -m master topic && diff --git a/t/t3419-rebase-patch-id.sh b/t/t3419-rebase-patch-id.sh index bd8efaf005..e70ac10a0c 100755 --- a/t/t3419-rebase-patch-id.sh +++ b/t/t3419-rebase-patch-id.sh @@ -39,7 +39,7 @@ run() } test_expect_success 'setup' ' - git commit --allow-empty -m initial + git commit --allow-empty -m initial && git tag root ' From 67b6afe1ed424934679649752c9efb9896bfacf0 Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Thu, 8 Dec 2011 18:40:13 +0530 Subject: [PATCH 3/7] t3030 (merge-recursive): use test_expect_code Use test_expect_code in preference to repeatedly checking exit codes by hand. Signed-off-by: Ramkumar Ramachandra Signed-off-by: Junio C Hamano --- t/t3030-merge-recursive.sh | 72 ++++---------------------------------- 1 file changed, 6 insertions(+), 66 deletions(-) diff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh index 55ef1895d7..a5e3da7e41 100755 --- a/t/t3030-merge-recursive.sh +++ b/t/t3030-merge-recursive.sh @@ -285,17 +285,7 @@ test_expect_success 'merge-recursive simple' ' rm -fr [abcd] && git checkout -f "$c2" && - git merge-recursive "$c0" -- "$c2" "$c1" - status=$? - case "$status" in - 1) - : happy - ;; - *) - echo >&2 "why status $status!!!" - false - ;; - esac + test_expect_code 1 git merge-recursive "$c0" -- "$c2" "$c1" ' test_expect_success 'merge-recursive result' ' @@ -334,17 +324,7 @@ test_expect_success 'merge-recursive remove conflict' ' rm -fr [abcd] && git checkout -f "$c1" && - git merge-recursive "$c0" -- "$c1" "$c5" - status=$? - case "$status" in - 1) - : happy - ;; - *) - echo >&2 "why status $status!!!" - false - ;; - esac + test_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c5" ' test_expect_success 'merge-recursive remove conflict' ' @@ -388,17 +368,7 @@ test_expect_success 'merge-recursive d/f conflict' ' git reset --hard && git checkout -f "$c1" && - git merge-recursive "$c0" -- "$c1" "$c4" - status=$? - case "$status" in - 1) - : happy - ;; - *) - echo >&2 "why status $status!!!" - false - ;; - esac + test_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c4" ' test_expect_success 'merge-recursive d/f conflict result' ' @@ -422,17 +392,7 @@ test_expect_success 'merge-recursive d/f conflict the other way' ' git reset --hard && git checkout -f "$c4" && - git merge-recursive "$c0" -- "$c4" "$c1" - status=$? - case "$status" in - 1) - : happy - ;; - *) - echo >&2 "why status $status!!!" - false - ;; - esac + test_expect_code 1 git merge-recursive "$c0" -- "$c4" "$c1" ' test_expect_success 'merge-recursive d/f conflict result the other way' ' @@ -456,17 +416,7 @@ test_expect_success 'merge-recursive d/f conflict' ' git reset --hard && git checkout -f "$c1" && - git merge-recursive "$c0" -- "$c1" "$c6" - status=$? - case "$status" in - 1) - : happy - ;; - *) - echo >&2 "why status $status!!!" - false - ;; - esac + test_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c6" ' test_expect_success 'merge-recursive d/f conflict result' ' @@ -490,17 +440,7 @@ test_expect_success 'merge-recursive d/f conflict' ' git reset --hard && git checkout -f "$c6" && - git merge-recursive "$c0" -- "$c6" "$c1" - status=$? - case "$status" in - 1) - : happy - ;; - *) - echo >&2 "why status $status!!!" - false - ;; - esac + test_expect_code 1 git merge-recursive "$c0" -- "$c6" "$c1" ' test_expect_success 'merge-recursive d/f conflict result' ' From 7f9a5fc6876a3158cb29b0c2d13ccb226ec7d679 Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Thu, 8 Dec 2011 18:40:16 +0530 Subject: [PATCH 4/7] t1510 (worktree): fix '&&' chaining Breaks in a test assertion's && chain can potentially hide failures from earlier commands in the chain. 'unset' returns non-zero status when the variable passed was already unset on some shells; we need to change these instances to 'sane_unset'. Helped-by: Jonathan Nieder Signed-off-by: Ramkumar Ramachandra Acked-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/t1501-worktree.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh index 63849836c8..e661147c57 100755 --- a/t/t1501-worktree.sh +++ b/t/t1501-worktree.sh @@ -48,7 +48,7 @@ test_expect_success 'setup: helper for testing rev-parse' ' ' test_expect_success 'setup: core.worktree = relative path' ' - unset GIT_WORK_TREE; + sane_unset GIT_WORK_TREE && GIT_DIR=repo.git && GIT_CONFIG="$(pwd)"/$GIT_DIR/config && export GIT_DIR GIT_CONFIG && @@ -89,7 +89,7 @@ test_expect_success 'subdir of work tree' ' ' test_expect_success 'setup: core.worktree = absolute path' ' - unset GIT_WORK_TREE; + sane_unset GIT_WORK_TREE && GIT_DIR=$(pwd)/repo.git && GIT_CONFIG=$GIT_DIR/config && export GIT_DIR GIT_CONFIG && @@ -334,7 +334,7 @@ test_expect_success 'absolute pathspec should fail gracefully' ' ' test_expect_success 'make_relative_path handles double slashes in GIT_DIR' ' - >dummy_file + >dummy_file && echo git --git-dir="$(pwd)//repo.git" --work-tree="$(pwd)" add dummy_file && git --git-dir="$(pwd)//repo.git" --work-tree="$(pwd)" add dummy_file ' From 5e1136227178f2ca48c472a4cc89ccfc92328965 Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Fri, 9 Dec 2011 16:59:13 +0530 Subject: [PATCH 5/7] t3040 (subprojects-basic): fix '&&' chaining, modernize style Breaks in a test assertion's && chain can potentially hide failures from earlier commands in the chain. Fix instances of this. While at it, clean up the style to fit the prevailing style. This means: - Put the opening quote starting each test on the same line as the test_expect_* invocation. - Indent the file with tabs, not spaces. - Use test_expect_code() in preference to checking the exit status of various statements by hand. - Guard commands that prepare test input for individual tests in the same test_expect_success, so that their scope is clearer and errors at that stage can be caught. - Use <<-\EOF in preference to < Signed-off-by: Ramkumar Ramachandra Signed-off-by: Junio C Hamano --- t/t3040-subprojects-basic.sh | 126 +++++++++++++++++------------------ 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/t/t3040-subprojects-basic.sh b/t/t3040-subprojects-basic.sh index f6973e96a5..0a4ff6d824 100755 --- a/t/t3040-subprojects-basic.sh +++ b/t/t3040-subprojects-basic.sh @@ -3,81 +3,81 @@ test_description='Basic subproject functionality' . ./test-lib.sh -test_expect_success 'Super project creation' \ - ': >Makefile && - git add Makefile && - git commit -m "Superproject created"' +test_expect_success 'setup: create superproject' ' + : >Makefile && + git add Makefile && + git commit -m "Superproject created" +' +test_expect_success 'setup: create subprojects' ' + mkdir sub1 && + ( cd sub1 && git init && : >Makefile && git add * && + git commit -q -m "subproject 1" ) && + mkdir sub2 && + ( cd sub2 && git init && : >Makefile && git add * && + git commit -q -m "subproject 2" ) && + git update-index --add sub1 && + git add sub2 && + git commit -q -m "subprojects added" && + git diff-tree --abbrev=5 HEAD^ HEAD |cut -d" " -f-3,5- >current && + git branch save HEAD && + cat >expected <<-\EOF && + :000000 160000 00000... A sub1 + :000000 160000 00000... A sub2 + EOF + test_cmp expected current +' -cat >expected <Makefile && git add * && - git commit -q -m "subproject 1" ) && - mkdir sub2 && - ( cd sub2 && git init && : >Makefile && git add * && - git commit -q -m "subproject 2" ) && - git update-index --add sub1 && - git add sub2 && - git commit -q -m "subprojects added" && - git diff-tree --abbrev=5 HEAD^ HEAD |cut -d" " -f-3,5- >current && - test_cmp expected current' +test_expect_success 'check if fsck ignores the subprojects' ' + git fsck --full +' -git branch save HEAD +test_expect_success 'check if commit in a subproject detected' ' + ( cd sub1 && + echo "all:" >>Makefile && + echo " true" >>Makefile && + git commit -q -a -m "make all" ) && + test_expect_code 1 git diff-files --exit-code +' -test_expect_success 'check if fsck ignores the subprojects' \ - 'git fsck --full' +test_expect_success 'check if a changed subproject HEAD can be committed' ' + git commit -q -a -m "sub1 changed" && + test_expect_code 1 git diff-tree --exit-code HEAD^ HEAD +' -test_expect_success 'check if commit in a subproject detected' \ - '( cd sub1 && - echo "all:" >>Makefile && - echo " true" >>Makefile && - git commit -q -a -m "make all" ) && { - git diff-files --exit-code - test $? = 1 - }' +test_expect_success 'check if diff-index works for subproject elements' ' + test_expect_code 1 git diff-index --exit-code --cached save -- sub1 +' -test_expect_success 'check if a changed subproject HEAD can be committed' \ - 'git commit -q -a -m "sub1 changed" && { - git diff-tree --exit-code HEAD^ HEAD - test $? = 1 - }' +test_expect_success 'check if diff-tree works for subproject elements' ' + test_expect_code 1 git diff-tree --exit-code HEAD^ HEAD -- sub1 +' -test_expect_success 'check if diff-index works for subproject elements' \ - 'git diff-index --exit-code --cached save -- sub1 - test $? = 1' +test_expect_success 'check if git diff works for subproject elements' ' + test_expect_code 1 git diff --exit-code HEAD^ HEAD +' -test_expect_success 'check if diff-tree works for subproject elements' \ - 'git diff-tree --exit-code HEAD^ HEAD -- sub1 - test $? = 1' +test_expect_success 'check if clone works' ' + git ls-files -s >expected && + git clone -l -s . cloned && + ( cd cloned && git ls-files -s ) >current && + test_cmp expected current +' -test_expect_success 'check if git diff works for subproject elements' \ - 'git diff --exit-code HEAD^ HEAD - test $? = 1' - -test_expect_success 'check if clone works' \ - 'git ls-files -s >expected && - git clone -l -s . cloned && - ( cd cloned && git ls-files -s ) >current && - test_cmp expected current' - -test_expect_success 'removing and adding subproject' \ - 'git update-index --force-remove -- sub2 && - mv sub2 sub3 && - git add sub3 && - git commit -q -m "renaming a subproject" && { - git diff -M --name-status --exit-code HEAD^ HEAD - test $? = 1 - }' +test_expect_success 'removing and adding subproject' ' + git update-index --force-remove -- sub2 && + mv sub2 sub3 && + git add sub3 && + git commit -q -m "renaming a subproject" && + test_expect_code 1 git diff -M --name-status --exit-code HEAD^ HEAD +' # the index must contain the object name the HEAD of the # subproject sub1 was at the point "save" -test_expect_success 'checkout in superproject' \ - 'git checkout save && - git diff-index --exit-code --raw --cached save -- sub1' +test_expect_success 'checkout in superproject' ' + git checkout save && + git diff-index --exit-code --raw --cached save -- sub1 +' # just interesting what happened... # git diff --name-status -M save master From f73e5ee5667138bbcb4220189e36e3ec06168c3f Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Fri, 9 Dec 2011 08:59:11 -0800 Subject: [PATCH 6/7] t3401: modernize style Put the opening quote starting each test on the same line as the test_expect_* invocation. Also make sure to use tabs for indentation. Signed-off-by: Martin von Zweigbergk Signed-off-by: Junio C Hamano --- t/t3401-rebase-partial.sh | 67 +++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/t/t3401-rebase-partial.sh b/t/t3401-rebase-partial.sh index aea6685984..d7c874ceb8 100755 --- a/t/t3401-rebase-partial.sh +++ b/t/t3401-rebase-partial.sh @@ -11,51 +11,50 @@ local branch. ' . ./test-lib.sh -test_expect_success \ - 'prepare repository with topic branch' \ - 'echo First > A && - git update-index --add A && - git commit -m "Add A." && +test_expect_success 'prepare repository with topic branch' ' + echo First > A && + git update-index --add A && + git commit -m "Add A." && - git checkout -b my-topic-branch && + git checkout -b my-topic-branch && - echo Second > B && - git update-index --add B && - git commit -m "Add B." && + echo Second > B && + git update-index --add B && + git commit -m "Add B." && - echo AnotherSecond > C && - git update-index --add C && - git commit -m "Add C." && + echo AnotherSecond > C && + git update-index --add C && + git commit -m "Add C." && - git checkout -f master && + git checkout -f master && - echo Third >> A && - git update-index A && - git commit -m "Modify A." + echo Third >> A && + git update-index A && + git commit -m "Modify A." ' -test_expect_success \ - 'pick top patch from topic branch into master' \ - 'git cherry-pick my-topic-branch^0 && - git checkout -f my-topic-branch && - git branch master-merge master && - git branch my-topic-branch-merge my-topic-branch +test_expect_success 'pick top patch from topic branch into master' ' + git cherry-pick my-topic-branch^0 && + git checkout -f my-topic-branch && + git branch master-merge master && + git branch my-topic-branch-merge my-topic-branch ' -test_debug \ - 'git cherry master && - git format-patch -k --stdout --full-index master >/dev/null && - gitk --all & sleep 1 +test_debug ' + git cherry master && + git format-patch -k --stdout --full-index master >/dev/null && + gitk --all & sleep 1 ' -test_expect_success \ - 'rebase topic branch against new master and check git am did not get halted' \ - 'git rebase master && test ! -d .git/rebase-apply' +test_expect_success 'rebase topic branch against new master and check git am did not get halted' ' + git rebase master && + test ! -d .git/rebase-apply +' -test_expect_success \ - 'rebase --merge topic branch that was partially merged upstream' \ - 'git checkout -f my-topic-branch-merge && - git rebase --merge master-merge && - test ! -d .git/rebase-merge' +test_expect_success 'rebase --merge topic branch that was partially merged upstream' ' + git checkout -f my-topic-branch-merge && + git rebase --merge master-merge && + test ! -d .git/rebase-merge +' test_done From 13c907c4fe9b0d96a68c04f7d64f66873e0db8b7 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sat, 10 Dec 2011 00:17:54 -0800 Subject: [PATCH 7/7] t3401: use test_commit in setup Simplify t3401 by using test_commit in the setup. This lets us refer to commits using their tags and there is no longer a need to create the branch my-topic-branch-merge. Also, the branch master-merge points to the same commit as master (even before this change), so that branch does not need to be created either. While at it, replace "test ! -d" by "test_path_is_missing". Signed-off-by: Martin von Zweigbergk Signed-off-by: Junio C Hamano --- t/t3401-rebase-partial.sh | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/t/t3401-rebase-partial.sh b/t/t3401-rebase-partial.sh index d7c874ceb8..7ba17974c5 100755 --- a/t/t3401-rebase-partial.sh +++ b/t/t3401-rebase-partial.sh @@ -12,32 +12,17 @@ local branch. . ./test-lib.sh test_expect_success 'prepare repository with topic branch' ' - echo First > A && - git update-index --add A && - git commit -m "Add A." && - + test_commit A && git checkout -b my-topic-branch && - - echo Second > B && - git update-index --add B && - git commit -m "Add B." && - - echo AnotherSecond > C && - git update-index --add C && - git commit -m "Add C." && - + test_commit B && + test_commit C && git checkout -f master && - - echo Third >> A && - git update-index A && - git commit -m "Modify A." + test_commit A2 A.t ' test_expect_success 'pick top patch from topic branch into master' ' - git cherry-pick my-topic-branch^0 && - git checkout -f my-topic-branch && - git branch master-merge master && - git branch my-topic-branch-merge my-topic-branch + git cherry-pick C && + git checkout -f my-topic-branch ' test_debug ' @@ -48,13 +33,13 @@ test_debug ' test_expect_success 'rebase topic branch against new master and check git am did not get halted' ' git rebase master && - test ! -d .git/rebase-apply + test_path_is_missing .git/rebase-apply ' test_expect_success 'rebase --merge topic branch that was partially merged upstream' ' - git checkout -f my-topic-branch-merge && - git rebase --merge master-merge && - test ! -d .git/rebase-merge + git reset --hard C && + git rebase --merge master && + test_path_is_missing .git/rebase-merge ' test_done