modernizing the test scripts
cover modernizing the test scripts
This is my first patch series to the GIT mailing list. I followed the link[1] and t7001 patches to modernize and clean up the test scripts.
This patch series :
-modernize the three test scripts : t7101 , t7201 and t102.
- cleans up with 5 types of changes in all the three scripts.
1. Converting the old old style test format to new one
2. Removing blankspaces in test bodies
3. Removing whitespaces after the redirect operator, according to Codingguidelines .
4. Using git -C instead of cd
5. Placing all commands in seperate lines.
Also, I have tested the scripts and set up travis CI[2]. [1]https://lore.kernel.org/git/CAPig+cQpUu2UO-+jWn1nTaDykWnxwuEitzVB7PnW2SS_b7V8Hg@mail.gmail.com/ [2]https://travis-ci.org/github/charvi-077/git/branches
charvi-077 (5):
t7101,t7102,t7201: modernize test formatting t7102,t7201: remove unnecessary blank spaces in test body t7102,t7201: remove whitespace after redirect operator
t7201: avoid using cd outside of subshells
t7201: place each command in its own line
t/t7101-reset-empty-subdirs.sh | 66 ++++++++++----------- t/t7102-reset.sh | 63 ++++++++------------ t/t7201-co.sh | 102 +++++++++++++-------------------- 3 files changed, 96 insertions(+), 135 deletions(-)
Signature · 1 line
2.29.0.rc1
PATCH 1/5 t7101,t7102,t7201: modernize test formatting
Some tests in this script are formatted using a very old style:
test_expect_success \
'title' \
'body line 1 &&
body line 2'Updating the formatting to the modern style:
test_expect_success 'title' '
body line 1 &&
body line 2
'
--- t/t7101-reset-empty-subdirs.sh | 66 +++++++++++++++++----------------- t/t7102-reset.sh | 24 +++++-------- t/t7201-co.sh | 31 ++++++++-------- 3 files changed, 56 insertions(+), 65 deletions(-)
t/t7101-reset-empty-subdirs.sh +33 -33
@@ -6,16 +6,15 @@ test_description='git reset should cull empty subdirs' . ./test-lib.sh -test_expect_success \ - 'creating initial files' \ - 'mkdir path0 && +test_expect_success 'creating initial files' ' + mkdir path0 && cp "$TEST_DIRECTORY"/../COPYING path0/COPYING && git add path0/COPYING && - git commit -m add -a' + git commit -m add -a +' -test_expect_success \ - 'creating second files' \ - 'mkdir path1 && +test_expect_success 'creating second files' ' + mkdir path1 && mkdir path1/path2 && cp "$TEST_DIRECTORY"/../COPYING path1/path2/COPYING && cp "$TEST_DIRECTORY"/../COPYING path1/COPYING &&
@@ -25,39 +24,40 @@ test_expect_success \ git add path1/COPYING && git add COPYING && git add path0/COPYING-TOO && - git commit -m change -a' + git commit -m change -a +' -test_expect_success \ - 'resetting tree HEAD^' \ - 'git reset --hard HEAD^' +test_expect_success 'resetting tree HEAD^' ' + git reset --hard HEAD^ +' -test_expect_success \ - 'checking initial files exist after rewind' \ - 'test -d path0 && - test -f path0/COPYING' +test_expect_success 'checking initial files exist after rewind' ' + test -d path0 && + test -f path0/COPYING +' -test_expect_success \ - 'checking lack of path1/path2/COPYING' \ - '! test -f path1/path2/COPYING' +test_expect_success 'checking lack of path1/path2/COPYING' ' + ! test -f path1/path2/COPYING +' -test_expect_success \ - 'checking lack of path1/COPYING' \ - '! test -f path1/COPYING' +test_expect_success 'checking lack of path1/COPYING' ' + ! test -f path1/COPYING +' -test_expect_success \ - 'checking lack of COPYING' \ - '! test -f COPYING' +test_expect_success 'checking lack of COPYING' ' + ! test -f COPYING +' -test_expect_success \ - 'checking checking lack of path1/COPYING-TOO' \ - '! test -f path0/COPYING-TOO' +test_expect_success 'checking checking lack of path1/COPYING-TOO' ' + ! test -f path0/COPYING-TOO +' -test_expect_success \ - 'checking lack of path1/path2' \ - '! test -d path1/path2' +test_expect_success 'checking lack of path1/path2' ' + ! test -d path1/path2 +' -test_expect_success \ - 'checking lack of path1' \ - '! test -d path1' +test_expect_success 'checking lack of path1' ' + ! test -d path1 +' test_done
t/t7102-reset.sh +8 -16
@@ -107,8 +107,7 @@ test_expect_success 'reset --soft with unmerged index should fail' ' git rm --cached -- un ' -test_expect_success \ - 'giving paths with options different than --mixed should fail' ' +test_expect_success 'giving paths with options different than --mixed should fail' ' test_must_fail git reset --soft -- first && test_must_fail git reset --hard -- first && test_must_fail git reset --soft HEAD^ -- first &&
@@ -128,8 +127,7 @@ test_expect_success 'giving unrecognized options should fail' ' check_changes $head5 ' -test_expect_success \ - 'trying to do reset --soft with pending merge should fail' ' +test_expect_success 'trying to do reset --soft with pending merge should fail' ' git branch branch1 && git branch branch2 &&
@@ -152,8 +150,7 @@ test_expect_success \ check_changes $head5 ' -test_expect_success \ - 'trying to do reset --soft with pending checkout merge should fail' ' +test_expect_success 'trying to do reset --soft with pending checkout merge should fail' ' git branch branch3 && git branch branch4 &&
@@ -175,8 +172,7 @@ test_expect_success \ check_changes $head5 ' -test_expect_success \ - 'resetting to HEAD with no changes should succeed and do nothing' ' +test_expect_success 'resetting to HEAD with no changes should succeed and do nothing' ' git reset --hard && check_changes $head5 && git reset --hard HEAD &&
@@ -226,8 +222,7 @@ secondfile: 2nd line 2nd file 3rd line 2nd file EOF -test_expect_success \ - 'changing files and redo the last commit should succeed' ' +test_expect_success 'changing files and redo the last commit should succeed' ' echo "3rd line 2nd file" >>secondfile && git commit -a -C ORIG_HEAD && head4=$(git rev-parse --verify HEAD) &&
@@ -245,8 +240,7 @@ first: second: 2nd file EOF -test_expect_success \ - '--hard reset should change the files and undo commits permanently' ' +test_expect_success '--hard reset should change the files and undo commits permanently' ' git reset --hard HEAD~2 && check_changes $head5p2 && test "$(git rev-parse ORIG_HEAD)" = \
@@ -284,8 +278,7 @@ secondfile: 1st line 2nd file 2nd line 2nd file EOF -test_expect_success \ - 'redoing changes adding them without commit them should succeed' ' +test_expect_success 'redoing changes adding them without commit them should succeed' ' git rm first && git mv second secondfile &&
@@ -380,8 +373,7 @@ secondfile: 1st line 2nd file 2nd line 2nd file EOF -test_expect_success \ - '--hard reset to ORIG_HEAD should clear a fast-forward merge' ' +test_expect_success '--hard reset to ORIG_HEAD should clear a fast-forward merge' ' git reset --hard HEAD^ && check_changes $head5 &&
t/t7201-co.sh +15 -16
@@ -62,7 +62,7 @@ test_expect_success setup ' git checkout master ' -test_expect_success "checkout from non-existing branch" ' +test_expect_success 'checkout from non-existing branch' ' git checkout -b delete-me master && git update-ref -d --no-deref refs/heads/delete-me &&
@@ -71,7 +71,7 @@ test_expect_success "checkout from non-existing branch" ' test refs/heads/master = "$(git symbolic-ref HEAD)" ' -test_expect_success "checkout with dirty tree without -m" ' +test_expect_success 'checkout with dirty tree without -m' ' fill 0 1 2 3 4 5 6 7 8 >one && if git checkout side
@@ -84,7 +84,7 @@ test_expect_success "checkout with dirty tree without -m" ' ' -test_expect_success "checkout with unrelated dirty tree without -m" ' +test_expect_success 'checkout with unrelated dirty tree without -m' ' git checkout -f master && fill 0 1 2 3 4 5 6 7 8 >same &&
@@ -95,7 +95,7 @@ test_expect_success "checkout with unrelated dirty tree without -m" ' test_cmp messages.expect messages ' -test_expect_success "checkout -m with dirty tree" ' +test_expect_success 'checkout -m with dirty tree' ' git checkout -f master && git clean -f &&
@@ -120,7 +120,7 @@ test_expect_success "checkout -m with dirty tree" ' test_must_be_empty current.index ' -test_expect_success "checkout -m with dirty tree, renamed" ' +test_expect_success 'checkout -m with dirty tree, renamed' ' git checkout -f master && git clean -f &&
@@ -388,22 +388,22 @@ test_expect_success 'checkout specific path while in subdirectory' ' ' -test_expect_success \ - 'checkout w/--track sets up tracking' ' +test_expect_success 'checkout w/--track sets up tracking' ' git config branch.autosetupmerge false && git checkout master && git checkout --track -b track1 && test "$(git config branch.track1.remote)" && - test "$(git config branch.track1.merge)"' + test "$(git config branch.track1.merge)" +' -test_expect_success \ - 'checkout w/autosetupmerge=always sets up tracking' ' +test_expect_success 'checkout w/autosetupmerge=always sets up tracking' ' test_when_finished git config branch.autosetupmerge false && git config branch.autosetupmerge always && git checkout master && git checkout -b track2 && test "$(git config branch.track2.remote)" && - test "$(git config branch.track2.merge)"' + test "$(git config branch.track2.merge)" +' test_expect_success 'checkout w/--track from non-branch HEAD fails' ' git checkout master^0 &&
@@ -435,8 +435,7 @@ test_expect_success 'detach a symbolic link HEAD' ' test "z$(git rev-parse --verify refs/heads/master)" = "z$here" ' -test_expect_success \ - 'checkout with --track fakes a sensible -b <name>' ' +test_expect_success 'checkout with --track fakes a sensible -b <name>' ' git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" && git update-ref refs/remotes/origin/koala/bear renamer &&
@@ -457,9 +456,9 @@ test_expect_success \ test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" ' -test_expect_success \ - 'checkout with --track, but without -b, fails with too short tracked name' ' - test_must_fail git checkout --track renamer' +test_expect_success 'checkout with --track, but without -b, fails with too short tracked name' ' + test_must_fail git checkout --track renamer +' setup_conflicting_index () { rm -f .git/index &&
Signature · 1 line
2.29.0.rc1
PATCH 2/5 t7102,t7201: remove unnecessary blank spaces in test body
In reply to charvi-077Some tests use a deprecated style in which there are unnecessary blank lines after the opening quote of the test body and before the closing quote. So we should removed these unnecessary blank lines.
--- t/t7102-reset.sh | 9 --------- t/t7201-co.sh | 25 ------------------------- 2 files changed, 34 deletions(-)
t/t7102-reset.sh +0 -9
@@ -439,7 +439,6 @@ test_expect_success 'test --mixed <paths>' ' ' test_expect_success 'test resetting the index at give paths' ' - mkdir sub && >sub/file1 && >sub/file2 &&
@@ -452,7 +451,6 @@ test_expect_success 'test resetting the index at give paths' ' echo "$U" && test_must_fail git diff-index --cached --exit-code "$T" && test "$T" != "$U" - ' test_expect_success 'resetting an unmodified path is a no-op' '
@@ -490,7 +488,6 @@ test_expect_success 'resetting specific path that is unmerged' ' ' test_expect_success 'disambiguation (1)' ' - git reset --hard && >secondfile && git add secondfile &&
@@ -499,11 +496,9 @@ test_expect_success 'disambiguation (1)' ' test -z "$(git diff --cached --name-only)" && test -f secondfile && test_must_be_empty secondfile - ' test_expect_success 'disambiguation (2)' ' - git reset --hard && >secondfile && git add secondfile &&
@@ -511,11 +506,9 @@ test_expect_success 'disambiguation (2)' ' test_must_fail git reset secondfile && test -n "$(git diff --cached --name-only -- secondfile)" && test ! -f secondfile - ' test_expect_success 'disambiguation (3)' ' - git reset --hard && >secondfile && git add secondfile &&
@@ -524,11 +517,9 @@ test_expect_success 'disambiguation (3)' ' test_must_fail git diff --quiet && test -z "$(git diff --cached --name-only)" && test ! -f secondfile - ' test_expect_success 'disambiguation (4)' ' - git reset --hard && >secondfile && git add secondfile &&
t/t7201-co.sh +0 -25
@@ -33,7 +33,6 @@ fill () { test_expect_success setup ' - fill x y z > same && fill 1 2 3 4 5 6 7 8 >one && fill a b c d e >two &&
@@ -63,7 +62,6 @@ test_expect_success setup ' ' test_expect_success 'checkout from non-existing branch' ' - git checkout -b delete-me master && git update-ref -d --no-deref refs/heads/delete-me && test refs/heads/delete-me = "$(git symbolic-ref HEAD)" &&
@@ -72,7 +70,6 @@ test_expect_success 'checkout from non-existing branch' ' ' test_expect_success 'checkout with dirty tree without -m' ' - fill 0 1 2 3 4 5 6 7 8 >one && if git checkout side then
@@ -81,11 +78,9 @@ test_expect_success 'checkout with dirty tree without -m' ' else echo "happy - failed correctly" fi - ' test_expect_success 'checkout with unrelated dirty tree without -m' ' - git checkout -f master && fill 0 1 2 3 4 5 6 7 8 >same && cp same kept &&
@@ -96,7 +91,6 @@ test_expect_success 'checkout with unrelated dirty tree without -m' ' ' test_expect_success 'checkout -m with dirty tree' ' - git checkout -f master && git clean -f &&
@@ -121,7 +115,6 @@ test_expect_success 'checkout -m with dirty tree' ' ' test_expect_success 'checkout -m with dirty tree, renamed' ' - git checkout -f master && git clean -f && fill 1 2 3 4 5 7 8 >one &&
@@ -139,11 +132,9 @@ test_expect_success 'checkout -m with dirty tree, renamed' ' ! test -f one && git diff --cached >current && test_must_be_empty current - ' test_expect_success 'checkout -m with merge conflict' ' - git checkout -f master && git clean -f && fill 1 T 3 4 5 6 S 8 >one &&
@@ -166,7 +157,6 @@ test_expect_success 'checkout -m with merge conflict' ' ' test_expect_success 'format of merge conflict from checkout -m' ' - git checkout -f master && git clean -f && fill b d > two &&
@@ -190,7 +180,6 @@ test_expect_success 'format of merge conflict from checkout -m' ' ' test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' - git checkout -f master && git reset --hard && git clean -f && fill b d > two &&
@@ -216,7 +205,6 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' ' test_expect_success 'switch to another branch while carrying a deletion' ' - git checkout -f master && git reset --hard && git clean -f && git rm two &&
@@ -228,7 +216,6 @@ test_expect_success 'switch to another branch while carrying a deletion' ' ' test_expect_success 'checkout to detach HEAD (with advice declined)' ' - git config advice.detachedHead false && rev=$(git rev-parse --short renamer^) && git checkout -f renamer && git clean -f &&
@@ -267,7 +254,6 @@ test_expect_success 'checkout to detach HEAD' ' ' test_expect_success 'checkout to detach HEAD with branchname^' ' - git checkout -f master && git clean -f && git checkout renamer^ && H=$(git rev-parse --verify HEAD) &&
@@ -283,7 +269,6 @@ test_expect_success 'checkout to detach HEAD with branchname^' ' ' test_expect_success 'checkout to detach HEAD with :/message' ' - git checkout -f master && git clean -f && git checkout ":/Initial" && H=$(git rev-parse --verify HEAD) &&
@@ -299,7 +284,6 @@ test_expect_success 'checkout to detach HEAD with :/message' ' ' test_expect_success 'checkout to detach HEAD with HEAD^0' ' - git checkout -f master && git clean -f && git checkout HEAD^0 && H=$(git rev-parse --verify HEAD) &&
@@ -315,7 +299,6 @@ test_expect_success 'checkout to detach HEAD with HEAD^0' ' ' test_expect_success 'checkout with ambiguous tag/branch names' ' - git tag both side && git branch both master && git reset --hard &&
@@ -327,11 +310,9 @@ test_expect_success 'checkout with ambiguous tag/branch names' ' test "z$H" = "z$M" && name=$(git symbolic-ref HEAD 2>/dev/null) && test "z$name" = zrefs/heads/both - ' test_expect_success 'checkout with ambiguous tag/branch names' ' - git reset --hard && git checkout master &&
@@ -351,11 +332,9 @@ test_expect_success 'checkout with ambiguous tag/branch names' ' else : happy fi - ' test_expect_success 'switch branches while in subdirectory' ' - git reset --hard && git checkout master &&
@@ -366,11 +345,9 @@ test_expect_success 'switch branches while in subdirectory' ' ) && ! test -f subs/one && rm -fr subs - ' test_expect_success 'checkout specific path while in subdirectory' ' - git reset --hard && git checkout side && mkdir subs &&
@@ -385,7 +362,6 @@ test_expect_success 'checkout specific path while in subdirectory' ' git checkout side -- bero ) && test -f subs/bero - ' test_expect_success 'checkout w/--track sets up tracking' '
@@ -608,7 +584,6 @@ test_expect_success 'failing checkout -b should not break working tree' ' test $(git symbolic-ref HEAD) = refs/heads/master && git diff --exit-code && git diff --cached --exit-code - ' test_expect_success 'switch out of non-branch' '
Signature · 1 line
2.29.0.rc1
PATCH 3/5 t7102,t7201: remove whitespace after redirect operator
In reply to charvi-077According to Documentation/CodingGuidelines, there should be no whitespace after redirect operators. So, we should remove these whitespaces after redirect operators.
--- t/t7102-reset.sh | 30 +++++++++++++++--------------- t/t7201-co.sh | 10 +++++----- 2 files changed, 20 insertions(+), 20 deletions(-)
t/t7102-reset.sh +15 -15
@@ -70,15 +70,15 @@ check_changes () { test_expect_success 'reset --hard message' ' hex=$(git log -1 --format="%h") && - git reset --hard > .actual && - echo HEAD is now at $hex $(commit_msg) > .expected && + git reset --hard >.actual && + echo HEAD is now at $hex $(commit_msg) >.expected && test_i18ncmp .expected .actual ' test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' ' hex=$(git log -1 --format="%h") && - git -c "i18n.logOutputEncoding=$test_encoding" reset --hard > .actual && - echo HEAD is now at $hex $(commit_msg $test_encoding) > .expected && + git -c "i18n.logOutputEncoding=$test_encoding" reset --hard >.actual && + echo HEAD is now at $hex $(commit_msg $test_encoding) >.expected && test_i18ncmp .expected .actual '
@@ -387,25 +387,25 @@ test_expect_success '--hard reset to ORIG_HEAD should clear a fast-forward merge ' test_expect_success 'test --mixed <paths>' ' - echo 1 > file1 && - echo 2 > file2 && + echo 1 >file1 && + echo 2 >file2 && git add file1 file2 && test_tick && git commit -m files && before1=$(git rev-parse --short HEAD:file1) && before2=$(git rev-parse --short HEAD:file2) && git rm file2 && - echo 3 > file3 && - echo 4 > file4 && - echo 5 > file1 && + echo 3 >file3 && + echo 4 >file4 && + echo 5 >file1 && after1=$(git rev-parse --short $(git hash-object file1)) && after4=$(git rev-parse --short $(git hash-object file4)) && git add file1 file3 file4 && git reset HEAD -- file1 file2 file3 && test_must_fail git diff --quiet && - git diff > output && + git diff >output && - cat > expect <<-EOF && + cat >expect <<-EOF && diff --git a/file1 b/file1 index $before1..$after1 100644 --- a/file1
@@ -423,9 +423,9 @@ test_expect_success 'test --mixed <paths>' ' EOF test_cmp expect output && - git diff --cached > output && + git diff --cached >output && - cat > cached_expect <<-EOF && + cat >cached_expect <<-EOF && diff --git a/file4 b/file4 new file mode 100644 index 0000000..$after4
@@ -460,14 +460,14 @@ test_expect_success 'resetting an unmodified path is a no-op' ' git diff-index --cached --exit-code HEAD ' -cat > expect << EOF +cat >expect << EOF Unstaged changes after reset: M file2 EOF test_expect_success '--mixed refreshes the index' ' echo 123 >> file2 && - git reset --mixed HEAD > output && + git reset --mixed HEAD >output && test_i18ncmp expect output '
t/t7201-co.sh +5 -5
@@ -33,7 +33,7 @@ fill () { test_expect_success setup ' - fill x y z > same && + fill x y z >same && fill 1 2 3 4 5 6 7 8 >one && fill a b c d e >two && git add same one two &&
@@ -55,7 +55,7 @@ test_expect_success setup ' git checkout -b simple master && rm -f one && - fill a c e > two && + fill a c e >two && git commit -a -m "Simple D one, M two" && git checkout master
@@ -95,7 +95,7 @@ test_expect_success 'checkout -m with dirty tree' ' git clean -f && fill 0 1 2 3 4 5 6 7 8 >one && - git checkout -m side > messages && + git checkout -m side >messages && test "$(git symbolic-ref HEAD)" = "refs/heads/side" &&
@@ -159,7 +159,7 @@ test_expect_success 'checkout -m with merge conflict' ' test_expect_success 'format of merge conflict from checkout -m' ' git checkout -f master && git clean -f && - fill b d > two && + fill b d >two && git checkout -m simple && git ls-files >current &&
@@ -182,7 +182,7 @@ test_expect_success 'format of merge conflict from checkout -m' ' test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' git checkout -f master && git reset --hard && git clean -f && - fill b d > two && + fill b d >two && git checkout --merge --conflict=diff3 simple && cat <<-EOF >expect &&
Signature · 1 line
2.29.0.rc1
PATCH 4/5 t7201: avoid using cd outside of subshells
In reply to charvi-077Avoid using cd outside of subshells since, if the test fails, there is no guarantee that the current working directory is the expected one, which may cause subsequent tests to run in the wrong directory.
--- t/t7201-co.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
t/t7201-co.sh +2 -8
@@ -339,10 +339,7 @@ test_expect_success 'switch branches while in subdirectory' ' git checkout master && mkdir subs && - ( - cd subs && - git checkout side - ) && + git -C subs checkout side && ! test -f subs/one && rm -fr subs '
@@ -357,10 +354,7 @@ test_expect_success 'checkout specific path while in subdirectory' ' git checkout master && mkdir -p subs && - ( - cd subs && - git checkout side -- bero - ) && + git -C subs checkout side -- bero && test -f subs/bero '
Signature · 1 line
2.29.0.rc1
PATCH 5/5 t7201: place each command in its own line
In reply to charvi-077Multiple commands on one line should be split across multiple lines.
--- t/t7201-co.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
t/t7201-co.sh +18 -8
@@ -157,7 +157,8 @@ test_expect_success 'checkout -m with merge conflict' ' ' test_expect_success 'format of merge conflict from checkout -m' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && fill b d >two && git checkout -m simple &&
@@ -180,7 +181,9 @@ test_expect_success 'format of merge conflict from checkout -m' ' ' test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' - git checkout -f master && git reset --hard && git clean -f && + git checkout -f master && + git reset --hard && + git clean -f && fill b d >two && git checkout --merge --conflict=diff3 simple &&
@@ -205,7 +208,9 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' ' test_expect_success 'switch to another branch while carrying a deletion' ' - git checkout -f master && git reset --hard && git clean -f && + git checkout -f master && + git reset --hard && + git clean -f && git rm two && test_must_fail git checkout simple 2>errs &&
@@ -218,7 +223,8 @@ test_expect_success 'switch to another branch while carrying a deletion' ' test_expect_success 'checkout to detach HEAD (with advice declined)' ' git config advice.detachedHead false && rev=$(git rev-parse --short renamer^) && - git checkout -f renamer && git clean -f && + git checkout -f renamer && + git clean -f && git checkout renamer^ 2>messages && test_i18ngrep "HEAD is now at $rev" messages && test_line_count = 1 messages &&
@@ -237,7 +243,8 @@ test_expect_success 'checkout to detach HEAD (with advice declined)' ' test_expect_success 'checkout to detach HEAD' ' git config advice.detachedHead true && rev=$(git rev-parse --short renamer^) && - git checkout -f renamer && git clean -f && + git checkout -f renamer && + git clean -f && GIT_TEST_GETTEXT_POISON=false git checkout renamer^ 2>messages && grep "HEAD is now at $rev" messages && test_line_count -gt 1 messages &&
@@ -254,7 +261,8 @@ test_expect_success 'checkout to detach HEAD' ' ' test_expect_success 'checkout to detach HEAD with branchname^' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout renamer^ && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&
@@ -269,7 +277,8 @@ test_expect_success 'checkout to detach HEAD with branchname^' ' ' test_expect_success 'checkout to detach HEAD with :/message' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout ":/Initial" && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&
@@ -284,7 +293,8 @@ test_expect_success 'checkout to detach HEAD with :/message' ' ' test_expect_success 'checkout to detach HEAD with HEAD^0' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout HEAD^0 && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&
Signature · 1 line
2.29.0.rc1
Quoted 3 lines · On Thu, Oct 15, 2020 at 7:57 PM charvi-077 <[email protected]> wrote:
This is my first patch series to the GIT mailing list. I followed the link[1] and t7001 patches to modernize and clean up the test scripts.
Thanks for getting started contributing!
Quoted 2 lines
This patch series :
-modernize the three test scripts : t7101, t7201 and t102.
s/t102/t7102/
On https://git.github.io/Outreachy-21-Microprojects/ we say:
"Find one test script that needs some of the same changes and make them."
So working only one test script, for example only t7101, would have been better than working on 3 test scripts. Now that you started working on 3 test scripts, it's ok to finish modernizing all these 3 test scripts though.
Quoted 2 lines
- cleans up with 5 types of changes in all the three scripts.
1. Converting the old old style test format to new one
s/old old/old/
Quoted 3 lines
2. Removing blankspaces in test bodies
3. Removing whitespaces after the redirect operator, according to Codingguidelines .
s/Codingguidelines/CodingGuidelines/
Quoted 2 lines
4. Using git -C instead of cd
5. Placing all commands in seperate lines.
s/seperate/separate/
Quoted 1 line
Also, I have tested the scripts and set up travis CI[2].
Nice!
Thanks,
Christian.
Re: [PATCH 1/5][Outreachy] t7101,t7102,t7201: modernize test formatting
In reply to charvi-077Quoted 2 lines · On Thu, Oct 15, 2020 at 7:58 PM charvi-077 <[email protected]> wrote:
Some tests in this script are formatted using a very old style:
s/this script/these scripts/
as this patch is modifying more than one test script.
Quoted 11 lines
test_expect_success \ 'title' \ 'body line 1 && body line 2'Updating the formatting to the modern style:
test_expect_success'title' '
body line 1 &&
body line 2
'Signed-off-by charvi-077 <[email protected]>
As Junio already mentioned we request that contributors use their full real name as the author name (which is by default the sender of the email) and in the "Signed-off-by: "
v2 cover modernizing the test scripts
In reply to charvi-077Thanks to Junio and Christian for corrections required in previous patch series, I have updated them in this patch series. I have updated the author name and sign-offs on all the patches, and also corrected the mistakes in cover letter and commit message of patch.
This patch series :
-modernize the three test scripts : t7101, t7201 and t7102.
- cleans up with 5 types of changes in all the three scripts.
1. Converting the old style test format to new one
2. Removing blankspaces in test bodies
3. Removing whitespaces after the redirect operator, according to CodingGuidelines
4. Using git -C instead of cd
5. Placing all commands in separate lines
Charvi Mendiratta (5):
t7101,t7102,t7201: modernize test formatting t7102,t7201: remove unnecessary blank spaces in test body t7102,t7201: remove whitespace after redirect operator
t7201: avoid using cd outside of subshells
t7201: place each command in its own line
t/t7101-reset-empty-subdirs.sh | 66 ++++++++++----------- t/t7102-reset.sh | 63 ++++++++------------ t/t7201-co.sh | 102 +++++++++++++-------------------- 3 files changed, 96 insertions(+), 135 deletions(-)
Signature · 1 line
2.29.0.rc1
PATCH v2 1/5 t7101,t7102,t7201: modernize test formatting
Some tests in these scripts are formatted using a very old style:
test_expect_success \
'title' \
'body line 1 &&
body line 2'Updating the formatting to the modern style:
test_expect_success 'title' '
body line 1 &&
body line 2
'
--- t/t7101-reset-empty-subdirs.sh | 66 +++++++++++++++++----------------- t/t7102-reset.sh | 24 +++++-------- t/t7201-co.sh | 31 ++++++++-------- 3 files changed, 56 insertions(+), 65 deletions(-)
t/t7101-reset-empty-subdirs.sh +33 -33
@@ -6,16 +6,15 @@ test_description='git reset should cull empty subdirs' . ./test-lib.sh -test_expect_success \ - 'creating initial files' \ - 'mkdir path0 && +test_expect_success 'creating initial files' ' + mkdir path0 && cp "$TEST_DIRECTORY"/../COPYING path0/COPYING && git add path0/COPYING && - git commit -m add -a' + git commit -m add -a +' -test_expect_success \ - 'creating second files' \ - 'mkdir path1 && +test_expect_success 'creating second files' ' + mkdir path1 && mkdir path1/path2 && cp "$TEST_DIRECTORY"/../COPYING path1/path2/COPYING && cp "$TEST_DIRECTORY"/../COPYING path1/COPYING &&
@@ -25,39 +24,40 @@ test_expect_success \ git add path1/COPYING && git add COPYING && git add path0/COPYING-TOO && - git commit -m change -a' + git commit -m change -a +' -test_expect_success \ - 'resetting tree HEAD^' \ - 'git reset --hard HEAD^' +test_expect_success 'resetting tree HEAD^' ' + git reset --hard HEAD^ +' -test_expect_success \ - 'checking initial files exist after rewind' \ - 'test -d path0 && - test -f path0/COPYING' +test_expect_success 'checking initial files exist after rewind' ' + test -d path0 && + test -f path0/COPYING +' -test_expect_success \ - 'checking lack of path1/path2/COPYING' \ - '! test -f path1/path2/COPYING' +test_expect_success 'checking lack of path1/path2/COPYING' ' + ! test -f path1/path2/COPYING +' -test_expect_success \ - 'checking lack of path1/COPYING' \ - '! test -f path1/COPYING' +test_expect_success 'checking lack of path1/COPYING' ' + ! test -f path1/COPYING +' -test_expect_success \ - 'checking lack of COPYING' \ - '! test -f COPYING' +test_expect_success 'checking lack of COPYING' ' + ! test -f COPYING +' -test_expect_success \ - 'checking checking lack of path1/COPYING-TOO' \ - '! test -f path0/COPYING-TOO' +test_expect_success 'checking checking lack of path1/COPYING-TOO' ' + ! test -f path0/COPYING-TOO +' -test_expect_success \ - 'checking lack of path1/path2' \ - '! test -d path1/path2' +test_expect_success 'checking lack of path1/path2' ' + ! test -d path1/path2 +' -test_expect_success \ - 'checking lack of path1' \ - '! test -d path1' +test_expect_success 'checking lack of path1' ' + ! test -d path1 +' test_done
t/t7102-reset.sh +8 -16
@@ -107,8 +107,7 @@ test_expect_success 'reset --soft with unmerged index should fail' ' git rm --cached -- un ' -test_expect_success \ - 'giving paths with options different than --mixed should fail' ' +test_expect_success 'giving paths with options different than --mixed should fail' ' test_must_fail git reset --soft -- first && test_must_fail git reset --hard -- first && test_must_fail git reset --soft HEAD^ -- first &&
@@ -128,8 +127,7 @@ test_expect_success 'giving unrecognized options should fail' ' check_changes $head5 ' -test_expect_success \ - 'trying to do reset --soft with pending merge should fail' ' +test_expect_success 'trying to do reset --soft with pending merge should fail' ' git branch branch1 && git branch branch2 &&
@@ -152,8 +150,7 @@ test_expect_success \ check_changes $head5 ' -test_expect_success \ - 'trying to do reset --soft with pending checkout merge should fail' ' +test_expect_success 'trying to do reset --soft with pending checkout merge should fail' ' git branch branch3 && git branch branch4 &&
@@ -175,8 +172,7 @@ test_expect_success \ check_changes $head5 ' -test_expect_success \ - 'resetting to HEAD with no changes should succeed and do nothing' ' +test_expect_success 'resetting to HEAD with no changes should succeed and do nothing' ' git reset --hard && check_changes $head5 && git reset --hard HEAD &&
@@ -226,8 +222,7 @@ secondfile: 2nd line 2nd file 3rd line 2nd file EOF -test_expect_success \ - 'changing files and redo the last commit should succeed' ' +test_expect_success 'changing files and redo the last commit should succeed' ' echo "3rd line 2nd file" >>secondfile && git commit -a -C ORIG_HEAD && head4=$(git rev-parse --verify HEAD) &&
@@ -245,8 +240,7 @@ first: second: 2nd file EOF -test_expect_success \ - '--hard reset should change the files and undo commits permanently' ' +test_expect_success '--hard reset should change the files and undo commits permanently' ' git reset --hard HEAD~2 && check_changes $head5p2 && test "$(git rev-parse ORIG_HEAD)" = \
@@ -284,8 +278,7 @@ secondfile: 1st line 2nd file 2nd line 2nd file EOF -test_expect_success \ - 'redoing changes adding them without commit them should succeed' ' +test_expect_success 'redoing changes adding them without commit them should succeed' ' git rm first && git mv second secondfile &&
@@ -380,8 +373,7 @@ secondfile: 1st line 2nd file 2nd line 2nd file EOF -test_expect_success \ - '--hard reset to ORIG_HEAD should clear a fast-forward merge' ' +test_expect_success '--hard reset to ORIG_HEAD should clear a fast-forward merge' ' git reset --hard HEAD^ && check_changes $head5 &&
t/t7201-co.sh +15 -16
@@ -62,7 +62,7 @@ test_expect_success setup ' git checkout master ' -test_expect_success "checkout from non-existing branch" ' +test_expect_success 'checkout from non-existing branch' ' git checkout -b delete-me master && git update-ref -d --no-deref refs/heads/delete-me &&
@@ -71,7 +71,7 @@ test_expect_success "checkout from non-existing branch" ' test refs/heads/master = "$(git symbolic-ref HEAD)" ' -test_expect_success "checkout with dirty tree without -m" ' +test_expect_success 'checkout with dirty tree without -m' ' fill 0 1 2 3 4 5 6 7 8 >one && if git checkout side
@@ -84,7 +84,7 @@ test_expect_success "checkout with dirty tree without -m" ' ' -test_expect_success "checkout with unrelated dirty tree without -m" ' +test_expect_success 'checkout with unrelated dirty tree without -m' ' git checkout -f master && fill 0 1 2 3 4 5 6 7 8 >same &&
@@ -95,7 +95,7 @@ test_expect_success "checkout with unrelated dirty tree without -m" ' test_cmp messages.expect messages ' -test_expect_success "checkout -m with dirty tree" ' +test_expect_success 'checkout -m with dirty tree' ' git checkout -f master && git clean -f &&
@@ -120,7 +120,7 @@ test_expect_success "checkout -m with dirty tree" ' test_must_be_empty current.index ' -test_expect_success "checkout -m with dirty tree, renamed" ' +test_expect_success 'checkout -m with dirty tree, renamed' ' git checkout -f master && git clean -f &&
@@ -388,22 +388,22 @@ test_expect_success 'checkout specific path while in subdirectory' ' ' -test_expect_success \ - 'checkout w/--track sets up tracking' ' +test_expect_success 'checkout w/--track sets up tracking' ' git config branch.autosetupmerge false && git checkout master && git checkout --track -b track1 && test "$(git config branch.track1.remote)" && - test "$(git config branch.track1.merge)"' + test "$(git config branch.track1.merge)" +' -test_expect_success \ - 'checkout w/autosetupmerge=always sets up tracking' ' +test_expect_success 'checkout w/autosetupmerge=always sets up tracking' ' test_when_finished git config branch.autosetupmerge false && git config branch.autosetupmerge always && git checkout master && git checkout -b track2 && test "$(git config branch.track2.remote)" && - test "$(git config branch.track2.merge)"' + test "$(git config branch.track2.merge)" +' test_expect_success 'checkout w/--track from non-branch HEAD fails' ' git checkout master^0 &&
@@ -435,8 +435,7 @@ test_expect_success 'detach a symbolic link HEAD' ' test "z$(git rev-parse --verify refs/heads/master)" = "z$here" ' -test_expect_success \ - 'checkout with --track fakes a sensible -b <name>' ' +test_expect_success 'checkout with --track fakes a sensible -b <name>' ' git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" && git update-ref refs/remotes/origin/koala/bear renamer &&
@@ -457,9 +456,9 @@ test_expect_success \ test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" ' -test_expect_success \ - 'checkout with --track, but without -b, fails with too short tracked name' ' - test_must_fail git checkout --track renamer' +test_expect_success 'checkout with --track, but without -b, fails with too short tracked name' ' + test_must_fail git checkout --track renamer +' setup_conflicting_index () { rm -f .git/index &&
Signature · 1 line
2.29.0.rc1
PATCH v2 2/5 t7102,t7201: remove unnecessary blank spaces in test body
In reply to Charvi MendirattaSome tests use a deprecated style in which there are unnecessary blank lines after the opening quote of the test body and before the closing quote. So we should remove these unnecessary blank lines.
--- t/t7102-reset.sh | 9 --------- t/t7201-co.sh | 25 ------------------------- 2 files changed, 34 deletions(-)
t/t7102-reset.sh +0 -9
@@ -439,7 +439,6 @@ test_expect_success 'test --mixed <paths>' ' ' test_expect_success 'test resetting the index at give paths' ' - mkdir sub && >sub/file1 && >sub/file2 &&
@@ -452,7 +451,6 @@ test_expect_success 'test resetting the index at give paths' ' echo "$U" && test_must_fail git diff-index --cached --exit-code "$T" && test "$T" != "$U" - ' test_expect_success 'resetting an unmodified path is a no-op' '
@@ -490,7 +488,6 @@ test_expect_success 'resetting specific path that is unmerged' ' ' test_expect_success 'disambiguation (1)' ' - git reset --hard && >secondfile && git add secondfile &&
@@ -499,11 +496,9 @@ test_expect_success 'disambiguation (1)' ' test -z "$(git diff --cached --name-only)" && test -f secondfile && test_must_be_empty secondfile - ' test_expect_success 'disambiguation (2)' ' - git reset --hard && >secondfile && git add secondfile &&
@@ -511,11 +506,9 @@ test_expect_success 'disambiguation (2)' ' test_must_fail git reset secondfile && test -n "$(git diff --cached --name-only -- secondfile)" && test ! -f secondfile - ' test_expect_success 'disambiguation (3)' ' - git reset --hard && >secondfile && git add secondfile &&
@@ -524,11 +517,9 @@ test_expect_success 'disambiguation (3)' ' test_must_fail git diff --quiet && test -z "$(git diff --cached --name-only)" && test ! -f secondfile - ' test_expect_success 'disambiguation (4)' ' - git reset --hard && >secondfile && git add secondfile &&
t/t7201-co.sh +0 -25
@@ -33,7 +33,6 @@ fill () { test_expect_success setup ' - fill x y z > same && fill 1 2 3 4 5 6 7 8 >one && fill a b c d e >two &&
@@ -63,7 +62,6 @@ test_expect_success setup ' ' test_expect_success 'checkout from non-existing branch' ' - git checkout -b delete-me master && git update-ref -d --no-deref refs/heads/delete-me && test refs/heads/delete-me = "$(git symbolic-ref HEAD)" &&
@@ -72,7 +70,6 @@ test_expect_success 'checkout from non-existing branch' ' ' test_expect_success 'checkout with dirty tree without -m' ' - fill 0 1 2 3 4 5 6 7 8 >one && if git checkout side then
@@ -81,11 +78,9 @@ test_expect_success 'checkout with dirty tree without -m' ' else echo "happy - failed correctly" fi - ' test_expect_success 'checkout with unrelated dirty tree without -m' ' - git checkout -f master && fill 0 1 2 3 4 5 6 7 8 >same && cp same kept &&
@@ -96,7 +91,6 @@ test_expect_success 'checkout with unrelated dirty tree without -m' ' ' test_expect_success 'checkout -m with dirty tree' ' - git checkout -f master && git clean -f &&
@@ -121,7 +115,6 @@ test_expect_success 'checkout -m with dirty tree' ' ' test_expect_success 'checkout -m with dirty tree, renamed' ' - git checkout -f master && git clean -f && fill 1 2 3 4 5 7 8 >one &&
@@ -139,11 +132,9 @@ test_expect_success 'checkout -m with dirty tree, renamed' ' ! test -f one && git diff --cached >current && test_must_be_empty current - ' test_expect_success 'checkout -m with merge conflict' ' - git checkout -f master && git clean -f && fill 1 T 3 4 5 6 S 8 >one &&
@@ -166,7 +157,6 @@ test_expect_success 'checkout -m with merge conflict' ' ' test_expect_success 'format of merge conflict from checkout -m' ' - git checkout -f master && git clean -f && fill b d > two &&
@@ -190,7 +180,6 @@ test_expect_success 'format of merge conflict from checkout -m' ' ' test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' - git checkout -f master && git reset --hard && git clean -f && fill b d > two &&
@@ -216,7 +205,6 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' ' test_expect_success 'switch to another branch while carrying a deletion' ' - git checkout -f master && git reset --hard && git clean -f && git rm two &&
@@ -228,7 +216,6 @@ test_expect_success 'switch to another branch while carrying a deletion' ' ' test_expect_success 'checkout to detach HEAD (with advice declined)' ' - git config advice.detachedHead false && rev=$(git rev-parse --short renamer^) && git checkout -f renamer && git clean -f &&
@@ -267,7 +254,6 @@ test_expect_success 'checkout to detach HEAD' ' ' test_expect_success 'checkout to detach HEAD with branchname^' ' - git checkout -f master && git clean -f && git checkout renamer^ && H=$(git rev-parse --verify HEAD) &&
@@ -283,7 +269,6 @@ test_expect_success 'checkout to detach HEAD with branchname^' ' ' test_expect_success 'checkout to detach HEAD with :/message' ' - git checkout -f master && git clean -f && git checkout ":/Initial" && H=$(git rev-parse --verify HEAD) &&
@@ -299,7 +284,6 @@ test_expect_success 'checkout to detach HEAD with :/message' ' ' test_expect_success 'checkout to detach HEAD with HEAD^0' ' - git checkout -f master && git clean -f && git checkout HEAD^0 && H=$(git rev-parse --verify HEAD) &&
@@ -315,7 +299,6 @@ test_expect_success 'checkout to detach HEAD with HEAD^0' ' ' test_expect_success 'checkout with ambiguous tag/branch names' ' - git tag both side && git branch both master && git reset --hard &&
@@ -327,11 +310,9 @@ test_expect_success 'checkout with ambiguous tag/branch names' ' test "z$H" = "z$M" && name=$(git symbolic-ref HEAD 2>/dev/null) && test "z$name" = zrefs/heads/both - ' test_expect_success 'checkout with ambiguous tag/branch names' ' - git reset --hard && git checkout master &&
@@ -351,11 +332,9 @@ test_expect_success 'checkout with ambiguous tag/branch names' ' else : happy fi - ' test_expect_success 'switch branches while in subdirectory' ' - git reset --hard && git checkout master &&
@@ -366,11 +345,9 @@ test_expect_success 'switch branches while in subdirectory' ' ) && ! test -f subs/one && rm -fr subs - ' test_expect_success 'checkout specific path while in subdirectory' ' - git reset --hard && git checkout side && mkdir subs &&
@@ -385,7 +362,6 @@ test_expect_success 'checkout specific path while in subdirectory' ' git checkout side -- bero ) && test -f subs/bero - ' test_expect_success 'checkout w/--track sets up tracking' '
@@ -608,7 +584,6 @@ test_expect_success 'failing checkout -b should not break working tree' ' test $(git symbolic-ref HEAD) = refs/heads/master && git diff --exit-code && git diff --cached --exit-code - ' test_expect_success 'switch out of non-branch' '
Signature · 1 line
2.29.0.rc1
PATCH v2 3/5 t7102,t7201: remove whitespace after redirect operator
In reply to Charvi MendirattaAccording to Documentation/CodingGuidelines, there should be no whitespace after redirect operators. So, we should remove these whitespaces after redirect operators.
--- t/t7102-reset.sh | 30 +++++++++++++++--------------- t/t7201-co.sh | 10 +++++----- 2 files changed, 20 insertions(+), 20 deletions(-)
t/t7102-reset.sh +15 -15
@@ -70,15 +70,15 @@ check_changes () { test_expect_success 'reset --hard message' ' hex=$(git log -1 --format="%h") && - git reset --hard > .actual && - echo HEAD is now at $hex $(commit_msg) > .expected && + git reset --hard >.actual && + echo HEAD is now at $hex $(commit_msg) >.expected && test_i18ncmp .expected .actual ' test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' ' hex=$(git log -1 --format="%h") && - git -c "i18n.logOutputEncoding=$test_encoding" reset --hard > .actual && - echo HEAD is now at $hex $(commit_msg $test_encoding) > .expected && + git -c "i18n.logOutputEncoding=$test_encoding" reset --hard >.actual && + echo HEAD is now at $hex $(commit_msg $test_encoding) >.expected && test_i18ncmp .expected .actual '
@@ -387,25 +387,25 @@ test_expect_success '--hard reset to ORIG_HEAD should clear a fast-forward merge ' test_expect_success 'test --mixed <paths>' ' - echo 1 > file1 && - echo 2 > file2 && + echo 1 >file1 && + echo 2 >file2 && git add file1 file2 && test_tick && git commit -m files && before1=$(git rev-parse --short HEAD:file1) && before2=$(git rev-parse --short HEAD:file2) && git rm file2 && - echo 3 > file3 && - echo 4 > file4 && - echo 5 > file1 && + echo 3 >file3 && + echo 4 >file4 && + echo 5 >file1 && after1=$(git rev-parse --short $(git hash-object file1)) && after4=$(git rev-parse --short $(git hash-object file4)) && git add file1 file3 file4 && git reset HEAD -- file1 file2 file3 && test_must_fail git diff --quiet && - git diff > output && + git diff >output && - cat > expect <<-EOF && + cat >expect <<-EOF && diff --git a/file1 b/file1 index $before1..$after1 100644 --- a/file1
@@ -423,9 +423,9 @@ test_expect_success 'test --mixed <paths>' ' EOF test_cmp expect output && - git diff --cached > output && + git diff --cached >output && - cat > cached_expect <<-EOF && + cat >cached_expect <<-EOF && diff --git a/file4 b/file4 new file mode 100644 index 0000000..$after4
@@ -460,14 +460,14 @@ test_expect_success 'resetting an unmodified path is a no-op' ' git diff-index --cached --exit-code HEAD ' -cat > expect << EOF +cat >expect << EOF Unstaged changes after reset: M file2 EOF test_expect_success '--mixed refreshes the index' ' echo 123 >> file2 && - git reset --mixed HEAD > output && + git reset --mixed HEAD >output && test_i18ncmp expect output '
t/t7201-co.sh +5 -5
@@ -33,7 +33,7 @@ fill () { test_expect_success setup ' - fill x y z > same && + fill x y z >same && fill 1 2 3 4 5 6 7 8 >one && fill a b c d e >two && git add same one two &&
@@ -55,7 +55,7 @@ test_expect_success setup ' git checkout -b simple master && rm -f one && - fill a c e > two && + fill a c e >two && git commit -a -m "Simple D one, M two" && git checkout master
@@ -95,7 +95,7 @@ test_expect_success 'checkout -m with dirty tree' ' git clean -f && fill 0 1 2 3 4 5 6 7 8 >one && - git checkout -m side > messages && + git checkout -m side >messages && test "$(git symbolic-ref HEAD)" = "refs/heads/side" &&
@@ -159,7 +159,7 @@ test_expect_success 'checkout -m with merge conflict' ' test_expect_success 'format of merge conflict from checkout -m' ' git checkout -f master && git clean -f && - fill b d > two && + fill b d >two && git checkout -m simple && git ls-files >current &&
@@ -182,7 +182,7 @@ test_expect_success 'format of merge conflict from checkout -m' ' test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' git checkout -f master && git reset --hard && git clean -f && - fill b d > two && + fill b d >two && git checkout --merge --conflict=diff3 simple && cat <<-EOF >expect &&
Signature · 1 line
2.29.0.rc1
PATCH v2 4/5 t7201: avoid using cd outside of subshells
In reply to Charvi MendirattaAvoid using cd outside of subshells since, if the test fails, there is no guarantee that the current working directory is the expected one, which may cause subsequent tests to run in the wrong directory.
--- t/t7201-co.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
t/t7201-co.sh +2 -8
@@ -339,10 +339,7 @@ test_expect_success 'switch branches while in subdirectory' ' git checkout master && mkdir subs && - ( - cd subs && - git checkout side - ) && + git -C subs checkout side && ! test -f subs/one && rm -fr subs '
@@ -357,10 +354,7 @@ test_expect_success 'checkout specific path while in subdirectory' ' git checkout master && mkdir -p subs && - ( - cd subs && - git checkout side -- bero - ) && + git -C subs checkout side -- bero && test -f subs/bero '
Signature · 1 line
2.29.0.rc1
PATCH v2 5/5 t7201: place each command in its own line
In reply to Charvi MendirattaMultiple commands on one line should be split across multiple lines.
--- t/t7201-co.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
t/t7201-co.sh +18 -8
@@ -157,7 +157,8 @@ test_expect_success 'checkout -m with merge conflict' ' ' test_expect_success 'format of merge conflict from checkout -m' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && fill b d >two && git checkout -m simple &&
@@ -180,7 +181,9 @@ test_expect_success 'format of merge conflict from checkout -m' ' ' test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' - git checkout -f master && git reset --hard && git clean -f && + git checkout -f master && + git reset --hard && + git clean -f && fill b d >two && git checkout --merge --conflict=diff3 simple &&
@@ -205,7 +208,9 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' ' test_expect_success 'switch to another branch while carrying a deletion' ' - git checkout -f master && git reset --hard && git clean -f && + git checkout -f master && + git reset --hard && + git clean -f && git rm two && test_must_fail git checkout simple 2>errs &&
@@ -218,7 +223,8 @@ test_expect_success 'switch to another branch while carrying a deletion' ' test_expect_success 'checkout to detach HEAD (with advice declined)' ' git config advice.detachedHead false && rev=$(git rev-parse --short renamer^) && - git checkout -f renamer && git clean -f && + git checkout -f renamer && + git clean -f && git checkout renamer^ 2>messages && test_i18ngrep "HEAD is now at $rev" messages && test_line_count = 1 messages &&
@@ -237,7 +243,8 @@ test_expect_success 'checkout to detach HEAD (with advice declined)' ' test_expect_success 'checkout to detach HEAD' ' git config advice.detachedHead true && rev=$(git rev-parse --short renamer^) && - git checkout -f renamer && git clean -f && + git checkout -f renamer && + git clean -f && GIT_TEST_GETTEXT_POISON=false git checkout renamer^ 2>messages && grep "HEAD is now at $rev" messages && test_line_count -gt 1 messages &&
@@ -254,7 +261,8 @@ test_expect_success 'checkout to detach HEAD' ' ' test_expect_success 'checkout to detach HEAD with branchname^' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout renamer^ && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&
@@ -269,7 +277,8 @@ test_expect_success 'checkout to detach HEAD with branchname^' ' ' test_expect_success 'checkout to detach HEAD with :/message' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout ":/Initial" && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&
@@ -284,7 +293,8 @@ test_expect_success 'checkout to detach HEAD with :/message' ' ' test_expect_success 'checkout to detach HEAD with HEAD^0' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout HEAD^0 && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&
Signature · 1 line
2.29.0.rc1
On Fri, 16 Oct 2020 at 18:24, Christian Couder
<[email protected]> wrote:
Thank you Christian, I have sent the new updated patch series .
Quoted 13 lines · On Thu, Oct 15, 2020 at 7:57 PM charvi-077 <[email protected]> wrote:
Quoted 3 lines
This is my first patch series to the GIT mailing list. I followed the link[1] and t7001 patches to modernize and clean up the test scripts.
Thanks for getting started contributing!
Quoted 2 lines
This patch series :
-modernize the three test scripts : t7101, t7201 and t102.s/t102/t7102/
Quoted 9 lines
On https://git.github.io/Outreachy-21-Microprojects/ we say:
"Find one test script that needs some of the same changes and make them."
So working only one test script, for example only t7101, would have been better than working on 3 test scripts. Now that you started working on 3 test scripts, it's ok to finish modernizing all these 3 test scripts though.
Yes, I agree this but t7101 has very minor changes required that I have completed so I switched to another one simultaneously . But in future I will make sure to follow this practise . Also, till now I have done majority of the changes as mentioned in the link in all the three scripts and will try to do more and complete it .
Quoted 14 lines
Quoted 2 lines
- cleans up with 5 types of changes in all the three scripts.
1. Converting the old old style test format to new ones/old old/old/
Quoted 3 lines
2. Removing blankspaces in test bodies
3. Removing whitespaces after the redirect operator, according to Codingguidelines .s/Codingguidelines/CodingGuidelines/
Quoted 2 lines
4. Using git -C instead of cd
5. Placing all commands in seperate lines.
Quoted 8 lines
s/seperate/separate/
Quoted 1 line
Also, I have tested the scripts and set up travis CI[2].
Nice!
Thanks,
Christian.
Thanks and Regards,
Charvi
Re: [PATCH v2 2/5][Outreachy] t7102,t7201: remove unnecessary blank spaces in test body
In reply to Charvi MendirattaOn 2020-10-17 13:24:52+0530, Charvi Mendiratta <[email protected]> wrote:
Welcome to the list.
Quoted 1 line
Some tests use a deprecated style in which there are unnecessary blank lines after the opening quote of the test body and before the closing quote. So we should remove these unnecessary blank lines.
In Git project, we wrap the commit message's body to 72 columns per line (for more information, please take a look at Documentation/MyFirstContribution.txt).
And we rarely say "we should", if the change shouldn't be applied, it won't be applied.
Instead, we ask the code base to fix itself. Perhaps:
t7102 and t7201 still follow the old style of having blank lines around test body, which is not consistence with our current practice.
Let's remove those unnecessary blank lines.
Thanks,
Signature · 1 line
Danh
Re: [PATCH v2 2/5][Outreachy] t7102,t7201: remove unnecessary blank spaces in test body
Quoted 11 lines · Đoàn Trần Công Danh
On 2020-10-17 13:24:52+0530, Charvi Mendiratta <[email protected]> wrote:
Welcome to the list.
Quoted 1 line
Some tests use a deprecated style in which there are unnecessary blank lines after the opening quote of the test body and before the closing quote. So we should remove these unnecessary blank lines.
In Git project, we wrap the commit message's body to 72 columns per line (for more information, please take a look at
Documentation/MyFirstContribution.txt).
Thanks a lot Danh, I will fix it in my editor's settings and will update in the next patch series .
Quoted 10 lines
And we rarely say "we should", if the change shouldn't be applied, it won't be applied.
Instead, we ask the code base to fix itself. Perhaps:t7102 and t7201 still follow the old style of having blank lines around test body, which is not consistence with our current practice.
Let's remove those unnecessary blank lines.
Noted, will update this as well.
Quoted 3 lines
Thanks,
--
Danh
Thanks and Regards,
Charvi
Re: [PATCH v2 4/5][Outreachy] t7201: avoid using cd outside of subshells
In reply to Charvi MendirattaHi Charvi
Congratulations on posting your first patch series.
Quoted 1 line · Charvi Mendiratta
Avoid using
cdoutside of subshells since, if the test fails, there is no guarantee that the current working directory is the expected one, which may cause subsequent tests to run in the wrong directory.
That is an accurate description of why we want to avoid using cd outside of subshells. However this conversion is converting cd inside a subshell to use git -C. I think that is worthwhile as it avoids having to use a subshell but the description should say explain that the conversion is desirable to avoid the cost of starting a subshell as the original test does not suffer from the problem described in your commit message.
Best Wishes
Phillip
Quoted 35 lines
Signed-off-by Charvi Mendiratta <[email protected]>--- t/t7201-co.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)t/t7201-co.sh +2
-8@@ -339,10 +339,7 @@ test_expect_success 'switch branches while in subdirectory' ' git checkout master && mkdir subs && - ( - cd subs && - git checkout side - ) && + git -C subs checkout side && ! test -f subs/one && rm -fr subs '@@ -357,10 +354,7 @@ test_expect_success 'checkout specific path while in subdirectory' ' git checkout master && mkdir -p subs && - ( - cd subs && - git checkout side -- bero - ) && + git -C subs checkout side -- bero && test -f subs/bero '
Re: [PATCH v2 4/5][Outreachy] t7201: avoid using cd outside of subshells
Quoted 8 lines · Phillip Wood
Hi Charvi
Congratulations on posting your first patch series.
Quoted 1 line · Charvi Mendiratta
Avoid using
cdoutside of subshells since, if the test fails, there is no guarantee that the current working directory is the expected one, which may cause subsequent tests to run in the wrong directory.
Quoted 8 lines
That is an accurate description of why we want to avoid using
cdoutside of subshells. However this conversion is convertingcdinside a subshell to usegit -C. I think that is worthwhile as it avoids having to use a subshell but the description should say explain that the conversion is desirable to avoid the cost of starting a subshell as the original test does not suffer from the problem described in your commit message.
Thank you Philip, for corrections . I somewhat able to understand that commit message
should be " avoid using cd inside the subshells " because running a shell script itselfs starts
a new subshell, please correct me if I am wrong . But still I am unable to get that why you
mentioned the description as "cost of starting a new subshell " . Will this not be the same subshell ?
Quoted 17 lines
Best Wishes
Phillip
Quoted 13 lines
Signed-off-by Charvi Mendiratta <[email protected]>--- t/t7201-co.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)t/t7201-co.sh +0
-0@@ -339,10 +339,7 @@ test_expect_success 'switch branches while in subdirectory' ' git checkout master &&
Quoted 5 lines
t/t7201-co.sh test_expect_success 'switch branches while in subdirectory' ' · line 345
Quoted 5 lines
t/t7201-co.sh +0
-4mkdir subs && - ( - cd subs && - git checkout side - ) &&
Is there any specific meaning of writing these above two commands in parentheses . Will this not work the same without it ?
Quoted 6 lines
Quoted 6 lines
t/t7201-co.sh +1
-0+ git -C subs checkout side && ! test -f subs/one && rm -fr subs '@@ -357,10 +354,7 @@ test_expect_success 'checkout specific path while in subdirectory' '
Quoted 11 lines
t/t7201-co.sh test_expect_success 'checkout specific path while in subdirectory' ' · line 360
Quoted 11 lines
t/t7201-co.sh +1
-4git checkout master && mkdir -p subs && - ( - cd subs && - git checkout side -- bero - ) && + git -C subs checkout side -- bero && test -f subs/bero '
Thanks and Regards ,
Charvi
Re: [PATCH v2 4/5][Outreachy] t7201: avoid using cd outside of subshells
Hi Charvi
Quoted 18 lines · Charvi Mendiratta
Quoted 8 lines · Phillip Wood
Hi Charvi
Congratulations on posting your first patch series.
Quoted 1 line · Charvi Mendiratta
Avoid using
cdoutside of subshells since, if the test fails, there is no guarantee that the current working directory is the expected one, which may cause subsequent tests to run in the wrong directory.Quoted 8 lines
That is an accurate description of why we want to avoid using
cdoutside of subshells. However this conversion is convertingcdinside a subshell to usegit -C. I think that is worthwhile as it avoids having to use a subshell but the description should say explain that the conversion is desirable to avoid the cost of starting a subshell as the original test does not suffer from the problem described in your commit message.
Quoted 8 lines
Thank you Philip, for corrections . I somewhat able to understand that commit message
should be " avoid using cd inside the subshells " because running a shell script itselfs starts
a new subshell, please correct me if I am wrong . But still I am unable to get that why you
mentioned the description as "cost of starting a new subshell " . Will this not be the same subshell ?
The original test looks something like
(
cd sub && git something
) &&
The commands between the ( and ) are executed in a subshell, any changes made to the current directory or shell variables in the subshell do not affect the rest of the test script. This is because the subshell starts a separate shell process, but creating this separate process has a cost associated with it.
The modified test looks like
git -C sub something
Here we tell git to change directory before it runs the 'something' command, this is more efficient as we don't need to start any extra processes - there are no subshells.
So the purpose of this change is not to "avoid using cd inside a subshell" but to avoid having to use a subshell at all.
I hope that helps explain what a subshell is and why we want to avoid using it if we can, do let me know if you want me to clarify anything.
Best Wishes
Phillip
Quoted 46 lines
Quoted 17 lines
Best Wishes
Phillip
Quoted 13 lines
Signed-off-by Charvi Mendiratta <[email protected]>--- t/t7201-co.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)t/t7201-co.sh +0
-0@@ -339,10 +339,7 @@ test_expect_success 'switch branches while in subdirectory' ' git checkout master &&Quoted 5 lines
t/t7201-co.sh test_expect_success 'switch branches while in subdirectory' ' · line 345
Quoted 5 lines
t/t7201-co.sh +0
-4mkdir subs && - ( - cd subs && - git checkout side - ) &&Is there any specific meaning of writing these above two commands in parentheses . Will this not work the same without it ?
Quoted 6 lines
Quoted 6 lines
t/t7201-co.sh +1
-0+ git -C subs checkout side && ! test -f subs/one && rm -fr subs '@@ -357,10 +354,7 @@ test_expect_success 'checkout specific path while in subdirectory' 'Quoted 11 lines
t/t7201-co.sh test_expect_success 'checkout specific path while in subdirectory' ' · line 360
Quoted 11 lines
t/t7201-co.sh +1
-4git checkout master && mkdir -p subs && - ( - cd subs && - git checkout side -- bero - ) && + git -C subs checkout side -- bero && test -f subs/bero 'Thanks and Regards ,
Charvi
Re: [PATCH v2 4/5][Outreachy] t7201: avoid using cd outside of subshells
Quoted 50 lines · Phillip Wood
Hi Charvi
Quoted 18 lines · Charvi Mendiratta
Quoted 8 lines · Phillip Wood
Hi Charvi
Congratulations on posting your first patch series.
Quoted 1 line · Charvi Mendiratta
Avoid using
cdoutside of subshells since, if the test fails, there is no guarantee that the current working directory is the expected one, which may cause subsequent tests to run in the wrong directory.Quoted 8 lines
That is an accurate description of why we want to avoid using
cdoutside of subshells. However this conversion is convertingcdinside a subshell to usegit -C. I think that is worthwhile as it avoids having to use a subshell but the description should say explain that the conversion is desirable to avoid the cost of starting a subshell as the original test does not suffer from the problem described in your commit message.Quoted 8 lines
Thank you Philip, for corrections . I somewhat able to understand that commit message
should be " avoid using cd inside the subshells " because running a shell script itselfs starts
a new subshell, please correct me if I am wrong . But still I am unable to get that why you
mentioned the description as "cost of starting a new subshell " . Will this not be the same subshell ?The original test looks something like
(cd sub && git something) &&
The commands between the ( and ) are executed in a subshell, any changes made to the current directory or shell variables in the subshell do not affect the rest of the test script. This is because the subshell starts a separate shell process, but creating this separate process has a cost associated with it.
The modified test looks like
git -C sub somethingHere we tell git to change directory before it runs the 'something' command, this is more efficient as we don't need to start any extra processes - there are no subshells.
Quoted 6 lines
So the purpose of this change is not to "avoid using cd inside a subshell" but to avoid having to use a subshell at all.
I hope that helps explain what a subshell is and why we want to avoid using it if we can, do let me know if you want me to clarify anything.
Yes, thanks a lot Philip I understood the reason. I will do the corrections in commit message and commit body as below :
t7201: using 'git -C' to avoid subshell
Using 'git-C' instead of 'cd' inside of subshell, to avoid the extra process of starting a new subshell
Please confirm, if any other changes are required .
Quoted 4 lines
Best Wishes
Phillip
Thanks and Regards,
Charvi
Quoted 47 lines
Quoted 47 lines
Quoted 18 lines
Best Wishes
Phillip
Quoted 13 lines
Signed-off-by Charvi Mendiratta <[email protected]>--- t/t7201-co.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)t/t7201-co.sh +0
-0@@ -339,10 +339,7 @@ test_expect_success 'switch branches while in subdirectory' ' git checkout master &&Quoted 5 lines
t/t7201-co.sh test_expect_success 'switch branches while in subdirectory' ' · line 345
Quoted 5 lines
t/t7201-co.sh +0
-4mkdir subs && - ( - cd subs && - git checkout side - ) &&Is there any specific meaning of writing these above two commands in parentheses . Will this not work the same without it ?
Quoted 6 lines
Quoted 6 lines
t/t7201-co.sh +1
-0+ git -C subs checkout side && ! test -f subs/one && rm -fr subs '@@ -357,10 +354,7 @@ test_expect_success 'checkout specific path while in subdirectory' 'Quoted 11 lines
t/t7201-co.sh test_expect_success 'checkout specific path while in subdirectory' ' · line 360
Quoted 11 lines
t/t7201-co.sh +1
-4git checkout master && mkdir -p subs && - ( - cd subs && - git checkout side -- bero - ) && + git -C subs checkout side -- bero && test -f subs/bero 'Thanks and Regards ,
Charvi
Re: [PATCH v2 4/5][Outreachy] t7201: avoid using cd outside of subshells
Hi Charvi,
Quoted 8 lines · Charvi Mendiratta
Yes, thanks a lot Philip I understood the reason. I will do the corrections in commit message and commit body as below :
t7201: using 'git -C' to avoid subshellUsing 'git-C' instead of 'cd' inside of subshell, to avoid the extra process of starting a new subshell
Please confirm, if any other changes are required .
Usually it never hurts to just send the patch, since any feedback that a reviewer has now is equally good even after you have sent a patch. Plus, it's easier to review the concrete patch you want applied, instead of a hypothetical of what you might send.
That said, a couple of notes:
- Your subject message is good. It is concise, to-the-point, and accurately describes the change. Good.
- The body is similarly short, but could be rewritten to use the imperative mood. But, it is redundant with the subject. The subject says "we are using 'git -C' to avoid creating a subshell", and the patch says exactly the same.
...So, you can do one of two things. Either you can abbreviate the subject, adding the additional detail in the patch message, or you could leave the subject as-is and delete the patch message entirely.
Either would be fine with me, but certainly Phillip or others could chime in, too.
Thanks,
Taylor
Re: [PATCH v2 4/5][Outreachy] t7201: avoid using cd outside of subshells
Quoted 11 lines · Taylor Blau
Hi Charvi,
Quoted 7 lines · Charvi Mendiratta
Yes, thanks a lot Philip I understood the reason. I will do the corrections in commit message and commit body as below :
t7201: using 'git -C' to avoid subshellUsing 'git-C' instead of 'cd' inside of subshell, to avoid the extra process of starting a new subshell
Quoted 7 lines
Quoted 1 line
Please confirm, if any other changes are required .
Usually it never hurts to just send the patch, since any feedback that a reviewer has now is equally good even after you have sent a patch. Plus, it's easier to review the concrete patch you want applied, instead of a hypothetical of what you might send.
Yes, I completely agree with you . Its my fault, I will send it in the patch and will
take care of not repeating this again .
Quoted 5 lines
That said, a couple of notes:
- Your subject message is good. It is concise, to-the-point, and accurately describes the change. Good.
Quoted 9 lines
- The body is similarly short, but could be rewritten to use the imperative mood. But, it is redundant with the subject. The subject says "we are using 'git -C' to avoid creating a subshell", and the patch says exactly the same.
...So, you can do one of two things. Either you can abbreviate the subject, adding the additional detail in the patch message, or you could leave the subject as-is and delete the patch message entirely.
Thanks Taylor, I will do the changes as you mentioned and send it in the next patch .
Quoted 5 lines
Either would be fine with me, but certainly Phillip or others could chime in, too.
Thanks,
Taylor
Thanks and Regards,
Charvi
Re: [PATCH v2 4/5][Outreachy] t7201: avoid using cd outside of subshells
In reply to Taylor BlauHi Charvi
Quoted 22 lines · Taylor Blau
Hi Charvi,
Quoted 8 lines · Charvi Mendiratta
Yes, thanks a lot Philip I understood the reason. I will do the corrections in commit message and commit body as below :
t7201: using 'git -C' to avoid subshellUsing 'git-C' instead of 'cd' inside of subshell, to avoid the extra process of starting a new subshell
[...]
That said, a couple of notes:
- Your subject message is good. It is concise, to-the-point, and accurately describes the change. Good.
- The body is similarly short, but could be rewritten to use the imperative mood. But, it is redundant with the subject. The subject says "we are using 'git -C' to avoid creating a subshell", and the patch says exactly the same.
Quoted 6 lines
...So, you can do one of two things. Either you can abbreviate the subject, adding the additional detail in the patch message, or you could leave the subject as-is and delete the patch message entirely.
Either would be fine with me, but certainly Phillip or others could chime in, too.
I'm happy with either, but I would suggest changing the subject so the description starts with 'use' rather than 'using'
Best Wishes
Phillip
Quoted 3 lines
Thanks,
Taylor
v3 cover modernize the test scripts
In reply to Charvi MendirattaI thanks to the community for reviewing my patches, in this patch series I have updated my commits messages and body as suggested by the community.
This patch series :
-modernize the three test scripts : t7101, t7201 and t7102.
- cleans up with 5 types of changes in all the three scripts.
1. Converting the old style test format to new one
2. Removing blankspaces in test bodies
3. Removing whitespaces after the redirect operator, according to CodingGuidelines
4. Using 'git -C' to avoid use of another subshell
5. Placing commands in separate lines
Charvi Mendiratta (5):
t7101,t7102,t7201: modernize test formatting t7102,t7201: remove unnecessary blank spaces in test body t7102,t7201: remove whitespace after redirect operator
t7201: use 'git -C' to avoid subshell
t7201: put each command on a seperate line
t/t7101-reset-empty-subdirs.sh | 66 ++++++++++----------- t/t7102-reset.sh | 63 ++++++++------------ t/t7201-co.sh | 102 +++++++++++++-------------------- 3 files changed, 96 insertions(+), 135 deletions(-)
Signature · 1 line
2.29.0.rc1
PATCH v3 1/5 t7101,t7102,t7201: modernize test formatting
Some tests in these scripts are formatted using a very old style:
test_expect_success \
'title' \
'body line 1 &&
body line 2'Updating the formatting to the modern style:
test_expect_success 'title' '
body line 1 &&
body line 2
'
--- t/t7101-reset-empty-subdirs.sh | 66 +++++++++++++++++----------------- t/t7102-reset.sh | 24 +++++-------- t/t7201-co.sh | 31 ++++++++-------- 3 files changed, 56 insertions(+), 65 deletions(-)
t/t7101-reset-empty-subdirs.sh +33 -33
@@ -6,16 +6,15 @@ test_description='git reset should cull empty subdirs' . ./test-lib.sh -test_expect_success \ - 'creating initial files' \ - 'mkdir path0 && +test_expect_success 'creating initial files' ' + mkdir path0 && cp "$TEST_DIRECTORY"/../COPYING path0/COPYING && git add path0/COPYING && - git commit -m add -a' + git commit -m add -a +' -test_expect_success \ - 'creating second files' \ - 'mkdir path1 && +test_expect_success 'creating second files' ' + mkdir path1 && mkdir path1/path2 && cp "$TEST_DIRECTORY"/../COPYING path1/path2/COPYING && cp "$TEST_DIRECTORY"/../COPYING path1/COPYING &&
@@ -25,39 +24,40 @@ test_expect_success \ git add path1/COPYING && git add COPYING && git add path0/COPYING-TOO && - git commit -m change -a' + git commit -m change -a +' -test_expect_success \ - 'resetting tree HEAD^' \ - 'git reset --hard HEAD^' +test_expect_success 'resetting tree HEAD^' ' + git reset --hard HEAD^ +' -test_expect_success \ - 'checking initial files exist after rewind' \ - 'test -d path0 && - test -f path0/COPYING' +test_expect_success 'checking initial files exist after rewind' ' + test -d path0 && + test -f path0/COPYING +' -test_expect_success \ - 'checking lack of path1/path2/COPYING' \ - '! test -f path1/path2/COPYING' +test_expect_success 'checking lack of path1/path2/COPYING' ' + ! test -f path1/path2/COPYING +' -test_expect_success \ - 'checking lack of path1/COPYING' \ - '! test -f path1/COPYING' +test_expect_success 'checking lack of path1/COPYING' ' + ! test -f path1/COPYING +' -test_expect_success \ - 'checking lack of COPYING' \ - '! test -f COPYING' +test_expect_success 'checking lack of COPYING' ' + ! test -f COPYING +' -test_expect_success \ - 'checking checking lack of path1/COPYING-TOO' \ - '! test -f path0/COPYING-TOO' +test_expect_success 'checking checking lack of path1/COPYING-TOO' ' + ! test -f path0/COPYING-TOO +' -test_expect_success \ - 'checking lack of path1/path2' \ - '! test -d path1/path2' +test_expect_success 'checking lack of path1/path2' ' + ! test -d path1/path2 +' -test_expect_success \ - 'checking lack of path1' \ - '! test -d path1' +test_expect_success 'checking lack of path1' ' + ! test -d path1 +' test_done
t/t7102-reset.sh +8 -16
@@ -107,8 +107,7 @@ test_expect_success 'reset --soft with unmerged index should fail' ' git rm --cached -- un ' -test_expect_success \ - 'giving paths with options different than --mixed should fail' ' +test_expect_success 'giving paths with options different than --mixed should fail' ' test_must_fail git reset --soft -- first && test_must_fail git reset --hard -- first && test_must_fail git reset --soft HEAD^ -- first &&
@@ -128,8 +127,7 @@ test_expect_success 'giving unrecognized options should fail' ' check_changes $head5 ' -test_expect_success \ - 'trying to do reset --soft with pending merge should fail' ' +test_expect_success 'trying to do reset --soft with pending merge should fail' ' git branch branch1 && git branch branch2 &&
@@ -152,8 +150,7 @@ test_expect_success \ check_changes $head5 ' -test_expect_success \ - 'trying to do reset --soft with pending checkout merge should fail' ' +test_expect_success 'trying to do reset --soft with pending checkout merge should fail' ' git branch branch3 && git branch branch4 &&
@@ -175,8 +172,7 @@ test_expect_success \ check_changes $head5 ' -test_expect_success \ - 'resetting to HEAD with no changes should succeed and do nothing' ' +test_expect_success 'resetting to HEAD with no changes should succeed and do nothing' ' git reset --hard && check_changes $head5 && git reset --hard HEAD &&
@@ -226,8 +222,7 @@ secondfile: 2nd line 2nd file 3rd line 2nd file EOF -test_expect_success \ - 'changing files and redo the last commit should succeed' ' +test_expect_success 'changing files and redo the last commit should succeed' ' echo "3rd line 2nd file" >>secondfile && git commit -a -C ORIG_HEAD && head4=$(git rev-parse --verify HEAD) &&
@@ -245,8 +240,7 @@ first: second: 2nd file EOF -test_expect_success \ - '--hard reset should change the files and undo commits permanently' ' +test_expect_success '--hard reset should change the files and undo commits permanently' ' git reset --hard HEAD~2 && check_changes $head5p2 && test "$(git rev-parse ORIG_HEAD)" = \
@@ -284,8 +278,7 @@ secondfile: 1st line 2nd file 2nd line 2nd file EOF -test_expect_success \ - 'redoing changes adding them without commit them should succeed' ' +test_expect_success 'redoing changes adding them without commit them should succeed' ' git rm first && git mv second secondfile &&
@@ -380,8 +373,7 @@ secondfile: 1st line 2nd file 2nd line 2nd file EOF -test_expect_success \ - '--hard reset to ORIG_HEAD should clear a fast-forward merge' ' +test_expect_success '--hard reset to ORIG_HEAD should clear a fast-forward merge' ' git reset --hard HEAD^ && check_changes $head5 &&
t/t7201-co.sh +15 -16
@@ -62,7 +62,7 @@ test_expect_success setup ' git checkout master ' -test_expect_success "checkout from non-existing branch" ' +test_expect_success 'checkout from non-existing branch' ' git checkout -b delete-me master && git update-ref -d --no-deref refs/heads/delete-me &&
@@ -71,7 +71,7 @@ test_expect_success "checkout from non-existing branch" ' test refs/heads/master = "$(git symbolic-ref HEAD)" ' -test_expect_success "checkout with dirty tree without -m" ' +test_expect_success 'checkout with dirty tree without -m' ' fill 0 1 2 3 4 5 6 7 8 >one && if git checkout side
@@ -84,7 +84,7 @@ test_expect_success "checkout with dirty tree without -m" ' ' -test_expect_success "checkout with unrelated dirty tree without -m" ' +test_expect_success 'checkout with unrelated dirty tree without -m' ' git checkout -f master && fill 0 1 2 3 4 5 6 7 8 >same &&
@@ -95,7 +95,7 @@ test_expect_success "checkout with unrelated dirty tree without -m" ' test_cmp messages.expect messages ' -test_expect_success "checkout -m with dirty tree" ' +test_expect_success 'checkout -m with dirty tree' ' git checkout -f master && git clean -f &&
@@ -120,7 +120,7 @@ test_expect_success "checkout -m with dirty tree" ' test_must_be_empty current.index ' -test_expect_success "checkout -m with dirty tree, renamed" ' +test_expect_success 'checkout -m with dirty tree, renamed' ' git checkout -f master && git clean -f &&
@@ -388,22 +388,22 @@ test_expect_success 'checkout specific path while in subdirectory' ' ' -test_expect_success \ - 'checkout w/--track sets up tracking' ' +test_expect_success 'checkout w/--track sets up tracking' ' git config branch.autosetupmerge false && git checkout master && git checkout --track -b track1 && test "$(git config branch.track1.remote)" && - test "$(git config branch.track1.merge)"' + test "$(git config branch.track1.merge)" +' -test_expect_success \ - 'checkout w/autosetupmerge=always sets up tracking' ' +test_expect_success 'checkout w/autosetupmerge=always sets up tracking' ' test_when_finished git config branch.autosetupmerge false && git config branch.autosetupmerge always && git checkout master && git checkout -b track2 && test "$(git config branch.track2.remote)" && - test "$(git config branch.track2.merge)"' + test "$(git config branch.track2.merge)" +' test_expect_success 'checkout w/--track from non-branch HEAD fails' ' git checkout master^0 &&
@@ -435,8 +435,7 @@ test_expect_success 'detach a symbolic link HEAD' ' test "z$(git rev-parse --verify refs/heads/master)" = "z$here" ' -test_expect_success \ - 'checkout with --track fakes a sensible -b <name>' ' +test_expect_success 'checkout with --track fakes a sensible -b <name>' ' git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" && git update-ref refs/remotes/origin/koala/bear renamer &&
@@ -457,9 +456,9 @@ test_expect_success \ test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" ' -test_expect_success \ - 'checkout with --track, but without -b, fails with too short tracked name' ' - test_must_fail git checkout --track renamer' +test_expect_success 'checkout with --track, but without -b, fails with too short tracked name' ' + test_must_fail git checkout --track renamer +' setup_conflicting_index () { rm -f .git/index &&
Signature · 1 line
2.29.0.rc1
PATCH v3 2/5 t7102,t7201: remove unnecessary blank spaces in test body
In reply to Charvi Mendirattat7102 and t7201 still follow the old style of having blank lines around test body, which is not consistence with our current practice.
Let's remove those unnecessary blank lines.
--- t/t7102-reset.sh | 9 --------- t/t7201-co.sh | 25 ------------------------- 2 files changed, 34 deletions(-)
t/t7102-reset.sh +0 -9
@@ -439,7 +439,6 @@ test_expect_success 'test --mixed <paths>' ' ' test_expect_success 'test resetting the index at give paths' ' - mkdir sub && >sub/file1 && >sub/file2 &&
@@ -452,7 +451,6 @@ test_expect_success 'test resetting the index at give paths' ' echo "$U" && test_must_fail git diff-index --cached --exit-code "$T" && test "$T" != "$U" - ' test_expect_success 'resetting an unmodified path is a no-op' '
@@ -490,7 +488,6 @@ test_expect_success 'resetting specific path that is unmerged' ' ' test_expect_success 'disambiguation (1)' ' - git reset --hard && >secondfile && git add secondfile &&
@@ -499,11 +496,9 @@ test_expect_success 'disambiguation (1)' ' test -z "$(git diff --cached --name-only)" && test -f secondfile && test_must_be_empty secondfile - ' test_expect_success 'disambiguation (2)' ' - git reset --hard && >secondfile && git add secondfile &&
@@ -511,11 +506,9 @@ test_expect_success 'disambiguation (2)' ' test_must_fail git reset secondfile && test -n "$(git diff --cached --name-only -- secondfile)" && test ! -f secondfile - ' test_expect_success 'disambiguation (3)' ' - git reset --hard && >secondfile && git add secondfile &&
@@ -524,11 +517,9 @@ test_expect_success 'disambiguation (3)' ' test_must_fail git diff --quiet && test -z "$(git diff --cached --name-only)" && test ! -f secondfile - ' test_expect_success 'disambiguation (4)' ' - git reset --hard && >secondfile && git add secondfile &&
t/t7201-co.sh +0 -25
@@ -33,7 +33,6 @@ fill () { test_expect_success setup ' - fill x y z > same && fill 1 2 3 4 5 6 7 8 >one && fill a b c d e >two &&
@@ -63,7 +62,6 @@ test_expect_success setup ' ' test_expect_success 'checkout from non-existing branch' ' - git checkout -b delete-me master && git update-ref -d --no-deref refs/heads/delete-me && test refs/heads/delete-me = "$(git symbolic-ref HEAD)" &&
@@ -72,7 +70,6 @@ test_expect_success 'checkout from non-existing branch' ' ' test_expect_success 'checkout with dirty tree without -m' ' - fill 0 1 2 3 4 5 6 7 8 >one && if git checkout side then
@@ -81,11 +78,9 @@ test_expect_success 'checkout with dirty tree without -m' ' else echo "happy - failed correctly" fi - ' test_expect_success 'checkout with unrelated dirty tree without -m' ' - git checkout -f master && fill 0 1 2 3 4 5 6 7 8 >same && cp same kept &&
@@ -96,7 +91,6 @@ test_expect_success 'checkout with unrelated dirty tree without -m' ' ' test_expect_success 'checkout -m with dirty tree' ' - git checkout -f master && git clean -f &&
@@ -121,7 +115,6 @@ test_expect_success 'checkout -m with dirty tree' ' ' test_expect_success 'checkout -m with dirty tree, renamed' ' - git checkout -f master && git clean -f && fill 1 2 3 4 5 7 8 >one &&
@@ -139,11 +132,9 @@ test_expect_success 'checkout -m with dirty tree, renamed' ' ! test -f one && git diff --cached >current && test_must_be_empty current - ' test_expect_success 'checkout -m with merge conflict' ' - git checkout -f master && git clean -f && fill 1 T 3 4 5 6 S 8 >one &&
@@ -166,7 +157,6 @@ test_expect_success 'checkout -m with merge conflict' ' ' test_expect_success 'format of merge conflict from checkout -m' ' - git checkout -f master && git clean -f && fill b d > two &&
@@ -190,7 +180,6 @@ test_expect_success 'format of merge conflict from checkout -m' ' ' test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' - git checkout -f master && git reset --hard && git clean -f && fill b d > two &&
@@ -216,7 +205,6 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' ' test_expect_success 'switch to another branch while carrying a deletion' ' - git checkout -f master && git reset --hard && git clean -f && git rm two &&
@@ -228,7 +216,6 @@ test_expect_success 'switch to another branch while carrying a deletion' ' ' test_expect_success 'checkout to detach HEAD (with advice declined)' ' - git config advice.detachedHead false && rev=$(git rev-parse --short renamer^) && git checkout -f renamer && git clean -f &&
@@ -267,7 +254,6 @@ test_expect_success 'checkout to detach HEAD' ' ' test_expect_success 'checkout to detach HEAD with branchname^' ' - git checkout -f master && git clean -f && git checkout renamer^ && H=$(git rev-parse --verify HEAD) &&
@@ -283,7 +269,6 @@ test_expect_success 'checkout to detach HEAD with branchname^' ' ' test_expect_success 'checkout to detach HEAD with :/message' ' - git checkout -f master && git clean -f && git checkout ":/Initial" && H=$(git rev-parse --verify HEAD) &&
@@ -299,7 +284,6 @@ test_expect_success 'checkout to detach HEAD with :/message' ' ' test_expect_success 'checkout to detach HEAD with HEAD^0' ' - git checkout -f master && git clean -f && git checkout HEAD^0 && H=$(git rev-parse --verify HEAD) &&
@@ -315,7 +299,6 @@ test_expect_success 'checkout to detach HEAD with HEAD^0' ' ' test_expect_success 'checkout with ambiguous tag/branch names' ' - git tag both side && git branch both master && git reset --hard &&
@@ -327,11 +310,9 @@ test_expect_success 'checkout with ambiguous tag/branch names' ' test "z$H" = "z$M" && name=$(git symbolic-ref HEAD 2>/dev/null) && test "z$name" = zrefs/heads/both - ' test_expect_success 'checkout with ambiguous tag/branch names' ' - git reset --hard && git checkout master &&
@@ -351,11 +332,9 @@ test_expect_success 'checkout with ambiguous tag/branch names' ' else : happy fi - ' test_expect_success 'switch branches while in subdirectory' ' - git reset --hard && git checkout master &&
@@ -366,11 +345,9 @@ test_expect_success 'switch branches while in subdirectory' ' ) && ! test -f subs/one && rm -fr subs - ' test_expect_success 'checkout specific path while in subdirectory' ' - git reset --hard && git checkout side && mkdir subs &&
@@ -385,7 +362,6 @@ test_expect_success 'checkout specific path while in subdirectory' ' git checkout side -- bero ) && test -f subs/bero - ' test_expect_success 'checkout w/--track sets up tracking' '
@@ -608,7 +584,6 @@ test_expect_success 'failing checkout -b should not break working tree' ' test $(git symbolic-ref HEAD) = refs/heads/master && git diff --exit-code && git diff --cached --exit-code - ' test_expect_success 'switch out of non-branch' '
Signature · 1 line
2.29.0.rc1
PATCH v3 3/5 t7102,t7201: remove whitespace after redirect operator
In reply to Charvi MendirattaAccording to Documentation/CodingGuidelines, redirect operator is written with space before, but no space after them.
Let's remove these whitespaces after redirect operators.
--- t/t7102-reset.sh | 30 +++++++++++++++--------------- t/t7201-co.sh | 10 +++++----- 2 files changed, 20 insertions(+), 20 deletions(-)
t/t7102-reset.sh +15 -15
@@ -70,15 +70,15 @@ check_changes () { test_expect_success 'reset --hard message' ' hex=$(git log -1 --format="%h") && - git reset --hard > .actual && - echo HEAD is now at $hex $(commit_msg) > .expected && + git reset --hard >.actual && + echo HEAD is now at $hex $(commit_msg) >.expected && test_i18ncmp .expected .actual ' test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' ' hex=$(git log -1 --format="%h") && - git -c "i18n.logOutputEncoding=$test_encoding" reset --hard > .actual && - echo HEAD is now at $hex $(commit_msg $test_encoding) > .expected && + git -c "i18n.logOutputEncoding=$test_encoding" reset --hard >.actual && + echo HEAD is now at $hex $(commit_msg $test_encoding) >.expected && test_i18ncmp .expected .actual '
@@ -387,25 +387,25 @@ test_expect_success '--hard reset to ORIG_HEAD should clear a fast-forward merge ' test_expect_success 'test --mixed <paths>' ' - echo 1 > file1 && - echo 2 > file2 && + echo 1 >file1 && + echo 2 >file2 && git add file1 file2 && test_tick && git commit -m files && before1=$(git rev-parse --short HEAD:file1) && before2=$(git rev-parse --short HEAD:file2) && git rm file2 && - echo 3 > file3 && - echo 4 > file4 && - echo 5 > file1 && + echo 3 >file3 && + echo 4 >file4 && + echo 5 >file1 && after1=$(git rev-parse --short $(git hash-object file1)) && after4=$(git rev-parse --short $(git hash-object file4)) && git add file1 file3 file4 && git reset HEAD -- file1 file2 file3 && test_must_fail git diff --quiet && - git diff > output && + git diff >output && - cat > expect <<-EOF && + cat >expect <<-EOF && diff --git a/file1 b/file1 index $before1..$after1 100644 --- a/file1
@@ -423,9 +423,9 @@ test_expect_success 'test --mixed <paths>' ' EOF test_cmp expect output && - git diff --cached > output && + git diff --cached >output && - cat > cached_expect <<-EOF && + cat >cached_expect <<-EOF && diff --git a/file4 b/file4 new file mode 100644 index 0000000..$after4
@@ -460,14 +460,14 @@ test_expect_success 'resetting an unmodified path is a no-op' ' git diff-index --cached --exit-code HEAD ' -cat > expect << EOF +cat >expect << EOF Unstaged changes after reset: M file2 EOF test_expect_success '--mixed refreshes the index' ' echo 123 >> file2 && - git reset --mixed HEAD > output && + git reset --mixed HEAD >output && test_i18ncmp expect output '
t/t7201-co.sh +5 -5
@@ -33,7 +33,7 @@ fill () { test_expect_success setup ' - fill x y z > same && + fill x y z >same && fill 1 2 3 4 5 6 7 8 >one && fill a b c d e >two && git add same one two &&
@@ -55,7 +55,7 @@ test_expect_success setup ' git checkout -b simple master && rm -f one && - fill a c e > two && + fill a c e >two && git commit -a -m "Simple D one, M two" && git checkout master
@@ -95,7 +95,7 @@ test_expect_success 'checkout -m with dirty tree' ' git clean -f && fill 0 1 2 3 4 5 6 7 8 >one && - git checkout -m side > messages && + git checkout -m side >messages && test "$(git symbolic-ref HEAD)" = "refs/heads/side" &&
@@ -159,7 +159,7 @@ test_expect_success 'checkout -m with merge conflict' ' test_expect_success 'format of merge conflict from checkout -m' ' git checkout -f master && git clean -f && - fill b d > two && + fill b d >two && git checkout -m simple && git ls-files >current &&
@@ -182,7 +182,7 @@ test_expect_success 'format of merge conflict from checkout -m' ' test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' git checkout -f master && git reset --hard && git clean -f && - fill b d > two && + fill b d >two && git checkout --merge --conflict=diff3 simple && cat <<-EOF >expect &&
Signature · 1 line
2.29.0.rc1
PATCH v3 4/5 t7201: use 'git -C' to avoid subshell
In reply to Charvi Mendiratta--- t/t7201-co.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
t/t7201-co.sh +2 -8
@@ -339,10 +339,7 @@ test_expect_success 'switch branches while in subdirectory' ' git checkout master && mkdir subs && - ( - cd subs && - git checkout side - ) && + git -C subs checkout side && ! test -f subs/one && rm -fr subs '
@@ -357,10 +354,7 @@ test_expect_success 'checkout specific path while in subdirectory' ' git checkout master && mkdir -p subs && - ( - cd subs && - git checkout side -- bero - ) && + git -C subs checkout side -- bero && test -f subs/bero '
Signature · 1 line
2.29.0.rc1
PATCH v3 5/5 t7201: put each command on a seperate line
In reply to Charvi MendirattaModern practice is to avoid multiple commands per line, and instead place each command on its own line.
--- t/t7201-co.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
t/t7201-co.sh +18 -8
@@ -157,7 +157,8 @@ test_expect_success 'checkout -m with merge conflict' ' ' test_expect_success 'format of merge conflict from checkout -m' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && fill b d >two && git checkout -m simple &&
@@ -180,7 +181,9 @@ test_expect_success 'format of merge conflict from checkout -m' ' ' test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' - git checkout -f master && git reset --hard && git clean -f && + git checkout -f master && + git reset --hard && + git clean -f && fill b d >two && git checkout --merge --conflict=diff3 simple &&
@@ -205,7 +208,9 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' ' test_expect_success 'switch to another branch while carrying a deletion' ' - git checkout -f master && git reset --hard && git clean -f && + git checkout -f master && + git reset --hard && + git clean -f && git rm two && test_must_fail git checkout simple 2>errs &&
@@ -218,7 +223,8 @@ test_expect_success 'switch to another branch while carrying a deletion' ' test_expect_success 'checkout to detach HEAD (with advice declined)' ' git config advice.detachedHead false && rev=$(git rev-parse --short renamer^) && - git checkout -f renamer && git clean -f && + git checkout -f renamer && + git clean -f && git checkout renamer^ 2>messages && test_i18ngrep "HEAD is now at $rev" messages && test_line_count = 1 messages &&
@@ -237,7 +243,8 @@ test_expect_success 'checkout to detach HEAD (with advice declined)' ' test_expect_success 'checkout to detach HEAD' ' git config advice.detachedHead true && rev=$(git rev-parse --short renamer^) && - git checkout -f renamer && git clean -f && + git checkout -f renamer && + git clean -f && GIT_TEST_GETTEXT_POISON=false git checkout renamer^ 2>messages && grep "HEAD is now at $rev" messages && test_line_count -gt 1 messages &&
@@ -254,7 +261,8 @@ test_expect_success 'checkout to detach HEAD' ' ' test_expect_success 'checkout to detach HEAD with branchname^' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout renamer^ && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&
@@ -269,7 +277,8 @@ test_expect_success 'checkout to detach HEAD with branchname^' ' ' test_expect_success 'checkout to detach HEAD with :/message' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout ":/Initial" && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&
@@ -284,7 +293,8 @@ test_expect_success 'checkout to detach HEAD with :/message' ' ' test_expect_success 'checkout to detach HEAD with HEAD^0' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout HEAD^0 && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&
Signature · 1 line
2.29.0.rc1
Re: [PATCH v2 4/5][Outreachy] t7201: avoid using cd outside of subshells
In reply to Phillip WoodQuoted 30 lines · Phillip Wood
Hi Charvi
Quoted 26 lines · Taylor Blau
Hi Charvi,
Quoted 8 lines · Charvi Mendiratta
Yes, thanks a lot Philip I understood the reason. I will do the corrections in commit message and commit body as below :
t7201: using 'git -C' to avoid subshellUsing 'git-C' instead of 'cd' inside of subshell, to avoid the extra process of starting a new subshell
[...]
That said, a couple of notes:
- Your subject message is good. It is concise, to-the-point, and accurately describes the change. Good.
- The body is similarly short, but could be rewritten to use the imperative mood. But, it is redundant with the subject. The subject says "we are using 'git -C' to avoid creating a subshell", and the patch says exactly the same.
...So, you can do one of two things. Either you can abbreviate the subject, adding the additional detail in the patch message, or you could leave the subject as-is and delete the patch message entirely.
Quoted 6 lines
Quoted 2 lines
Either would be fine with me, but certainly Phillip or others could chime in, too.
I'm happy with either, but I would suggest changing the subject so the description starts with 'use' rather than 'using'
Thank you Phillip, I have updated the changes in the next patch .
Quoted 7 lines
Best Wishes
Phillip
Quoted 3 lines
Thanks,
Taylor
Thanks and Regards,
Charvi
PATCH v4 1/1 t7201: put each command on a separate line
In reply to Charvi MendirattaModern practice is to avoid multiple commands per line, and instead place each command on its own line.
--- t/t7201-co.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
t/t7201-co.sh +18 -8
@@ -157,7 +157,8 @@ test_expect_success 'checkout -m with merge conflict' ' ' test_expect_success 'format of merge conflict from checkout -m' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && fill b d >two && git checkout -m simple &&
@@ -180,7 +181,9 @@ test_expect_success 'format of merge conflict from checkout -m' ' ' test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' - git checkout -f master && git reset --hard && git clean -f && + git checkout -f master && + git reset --hard && + git clean -f && fill b d >two && git checkout --merge --conflict=diff3 simple &&
@@ -205,7 +208,9 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' ' test_expect_success 'switch to another branch while carrying a deletion' ' - git checkout -f master && git reset --hard && git clean -f && + git checkout -f master && + git reset --hard && + git clean -f && git rm two && test_must_fail git checkout simple 2>errs &&
@@ -218,7 +223,8 @@ test_expect_success 'switch to another branch while carrying a deletion' ' test_expect_success 'checkout to detach HEAD (with advice declined)' ' git config advice.detachedHead false && rev=$(git rev-parse --short renamer^) && - git checkout -f renamer && git clean -f && + git checkout -f renamer && + git clean -f && git checkout renamer^ 2>messages && test_i18ngrep "HEAD is now at $rev" messages && test_line_count = 1 messages &&
@@ -237,7 +243,8 @@ test_expect_success 'checkout to detach HEAD (with advice declined)' ' test_expect_success 'checkout to detach HEAD' ' git config advice.detachedHead true && rev=$(git rev-parse --short renamer^) && - git checkout -f renamer && git clean -f && + git checkout -f renamer && + git clean -f && GIT_TEST_GETTEXT_POISON=false git checkout renamer^ 2>messages && grep "HEAD is now at $rev" messages && test_line_count -gt 1 messages &&
@@ -254,7 +261,8 @@ test_expect_success 'checkout to detach HEAD' ' ' test_expect_success 'checkout to detach HEAD with branchname^' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout renamer^ && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&
@@ -269,7 +277,8 @@ test_expect_success 'checkout to detach HEAD with branchname^' ' ' test_expect_success 'checkout to detach HEAD with :/message' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout ":/Initial" && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&
@@ -284,7 +293,8 @@ test_expect_success 'checkout to detach HEAD with :/message' ' ' test_expect_success 'checkout to detach HEAD with HEAD^0' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout HEAD^0 && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&
Signature · 1 line
2.29.0.rc1
Re: [PATCH v2 4/5][Outreachy] t7201: avoid using cd outside of subshells
In reply to Charvi MendirattaHi Charvi,
Quoted 8 lines · Charvi Mendiratta
Quoted 4 lines
Usually it never hurts to just send the patch, since any feedback that a reviewer has now is equally good even after you have sent a patch. Plus, it's easier to review the concrete patch you want applied, instead of a hypothetical of what you might send.
Yes, I completely agree with you . Its my fault, I will send it in the patch and will
take care of not repeating this again .
It's not your fault: there's no fault to be assigned when submitting your first few patches to the list. You're doing much better than I did ;-).
Quoted 6 lines
Quoted 4 lines
That said, a couple of notes:
[...]
Thanks Taylor, I will do the changes as you mentioned and send it in the next patch .
Thanks!
Taylor
Re: [PATCH v4] t7201: put each command on a separate line
In reply to Charvi MendirattaQuoted 5 lines · Charvi Mendiratta
Modern practice is to avoid multiple commands per line, and instead place each command on its own line.
Signed-off-by Charvi Mendiratta <[email protected]>---
This looks good, but I am wondering what happened between v3 and v4.
As you've demonstrated through the microproject that you can now comfortably be involved in the review discussion, I am tempted to suggest that we declare victory at this point and move on, but I don't know what the plans are for the other 4 patches (I guess we won't miss them that much---the micros are meant to be practice targets).
Thanks.
Quoted 89 lines
t/t7201-co.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)t/t7201-co.sh +18
-8@@ -157,7 +157,8 @@ test_expect_success 'checkout -m with merge conflict' ' ' test_expect_success 'format of merge conflict from checkout -m' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && fill b d >two && git checkout -m simple &&@@ -180,7 +181,9 @@ test_expect_success 'format of merge conflict from checkout -m' ' ' test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' - git checkout -f master && git reset --hard && git clean -f && + git checkout -f master && + git reset --hard && + git clean -f && fill b d >two && git checkout --merge --conflict=diff3 simple &&@@ -205,7 +208,9 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' ' test_expect_success 'switch to another branch while carrying a deletion' ' - git checkout -f master && git reset --hard && git clean -f && + git checkout -f master && + git reset --hard && + git clean -f && git rm two && test_must_fail git checkout simple 2>errs &&@@ -218,7 +223,8 @@ test_expect_success 'switch to another branch while carrying a deletion' ' test_expect_success 'checkout to detach HEAD (with advice declined)' ' git config advice.detachedHead false && rev=$(git rev-parse --short renamer^) && - git checkout -f renamer && git clean -f && + git checkout -f renamer && + git clean -f && git checkout renamer^ 2>messages && test_i18ngrep "HEAD is now at $rev" messages && test_line_count = 1 messages &&@@ -237,7 +243,8 @@ test_expect_success 'checkout to detach HEAD (with advice declined)' ' test_expect_success 'checkout to detach HEAD' ' git config advice.detachedHead true && rev=$(git rev-parse --short renamer^) && - git checkout -f renamer && git clean -f && + git checkout -f renamer && + git clean -f && GIT_TEST_GETTEXT_POISON=false git checkout renamer^ 2>messages && grep "HEAD is now at $rev" messages && test_line_count -gt 1 messages &&@@ -254,7 +261,8 @@ test_expect_success 'checkout to detach HEAD' ' ' test_expect_success 'checkout to detach HEAD with branchname^' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout renamer^ && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&@@ -269,7 +277,8 @@ test_expect_success 'checkout to detach HEAD with branchname^' ' ' test_expect_success 'checkout to detach HEAD with :/message' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout ":/Initial" && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&@@ -284,7 +293,8 @@ test_expect_success 'checkout to detach HEAD with :/message' ' ' test_expect_success 'checkout to detach HEAD with HEAD^0' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout HEAD^0 && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&
Re: [PATCH v4] t7201: put each command on a separate line
Quoted 10 lines · Junio C Hamano
Quoted 5 lines · Charvi Mendiratta
Modern practice is to avoid multiple commands per line, and instead place each command on its own line.
Signed-off-by Charvi Mendiratta <[email protected]>---
This looks good, but I am wondering what happened between v3 and v4.
When I applied this locally, I used this patch as a replacement for the last patch of v3 [1]. That kept everything passing after each patch.
Quoted 6 lines
As you've demonstrated through the microproject that you can now comfortably be involved in the review discussion, I am tempted to suggest that we declare victory at this point and move on, but I don't know what the plans are for the other 4 patches (I guess we won't miss them that much---the micros are meant to be practice targets).
Yup, ditto.
Quoted 1 line
Thanks.
Thanks,
Taylor
Re: [PATCH v4] t7201: put each command on a separate line
In reply to Junio C HamanoQuoted 11 lines · Junio C Hamano
Quoted 5 lines · Charvi Mendiratta
Modern practice is to avoid multiple commands per line, and instead place each command on its own line.
Signed-off-by Charvi Mendiratta <[email protected]>---
This looks good, but I am wondering what happened between v3 and v4.
Quoted 6 lines
As you've demonstrated through the microproject that you can now comfortably be involved in the review discussion, I am tempted to suggest that we declare victory at this point and move on, but I don't know what the plans are for the other 4 patches (I guess we won't miss them that much---the micros are meant to be practice targets).
Actually I take it back. This does not look good as a standalone patch at all. It seems to depend on something in the 5-patch series.
Please make sure that patches you send are usable by your recipients.
Re: [PATCH v4] t7201: put each command on a separate line
In reply to Taylor BlauQuoted 6 lines · Taylor Blau
Quoted 5 lines · Junio C Hamano
Quoted 3 lines · Charvi Mendiratta
Modern practice is to avoid multiple commands per line, and instead place each command on its own line.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Signed-off-by Charvi Mendiratta <[email protected]>---
This looks good, but I am wondering what happened between v3 and v4.
When I applied this locally, I used this patch as a replacement for the last patch of v3 [1]. That kept everything passing after each patch.
Oh, so this is a replacement for 5/5 and 1-4/5 of v4 are supposed to be identical to those from v3? The difference between [v3 5/5] and this one is a single typofix on the subject line, it seems, though.
Quoted 8 lines
Quoted 6 lines
As you've demonstrated through the microproject that you can now comfortably be involved in the review discussion, I am tempted to suggest that we declare victory at this point and move on, but I don't know what the plans are for the other 4 patches (I guess we won't miss them that much---the micros are meant to be practice targets).
Yup, ditto.
As [v4] single patch won't apply standalone, we cannot quite declare the victory yet. Are [v3 1-5/5] (or [v3 1-4/5] + [v4]) good to the reviewers of the past rounds?
Re: [PATCH v4] t7201: put each command on a separate line
Quoted 7 lines · Junio C Hamano
Quoted 2 lines · Taylor Blau
When I applied this locally, I used this patch as a replacement for the last patch of v3 [1]. That kept everything passing after each patch.
Oh, so this is a replacement for 5/5 and 1-4/5 of v4 are supposed to be identical to those from v3? The difference between [v3 5/5] and this one is a single typofix on the subject line, it seems, though.
Yes, at least that's what I interpreted it as (and how I applied it when testing). I'd like to hear from the author to make sure.
(As an aside to the author, I often fall into the trap of thinking that it will be easier to send a single replacement patch which will generate less email, but--as you can see--it is often more complicated for reviewers and the maintainer to decipher what's going on. It's often just easier to re-submit the entire series and include in your cover letter "this is unchanged from v(n-1) except for ...").
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
As you've demonstrated through the microproject that you can now comfortably be involved in the review discussion, I am tempted to suggest that we declare victory at this point and move on, but I don't know what the plans are for the other 4 patches (I guess we won't miss them that much---the micros are meant to be practice targets).
Quoted 5 lines
Quoted 1 line
Yup, ditto.
As [v4] single patch won't apply standalone, we cannot quite declare the victory yet. Are [v3 1-5/5] (or [v3 1-4/5] + [v4]) good to the reviewers of the past rounds?
For what it's worth, I'm happy with [v3 1-4/5] + [v4].
Thanks,
Taylor
Re: [PATCH v4] t7201: put each command on a separate line
Quoted 5 lines · Taylor Blau
Quoted 3 lines
As [v4] single patch won't apply standalone, we cannot quite declare the victory yet. Are [v3 1-5/5] (or [v3 1-4/5] + [v4]) good to the reviewers of the past rounds?
For what it's worth, I'm happy with [v3 1-4/5] + [v4].
Yeah, I'm happy with them, but this is an impression only from a quick skimming---I guess I'd just trust you and won't go back to the patches with fine toothed comb myself ;-).
Thanks, all.
Re: [PATCH v4] t7201: put each command on a separate line
In reply to Taylor BlauQuoted 6 lines · Taylor Blau
Quoted 4 lines · Junio C Hamano
Quoted 2 lines · Taylor Blau
When I applied this locally, I used this patch as a replacement for the last patch of v3 [1]. That kept everything passing after each patch.
Quoted 7 lines
Quoted 3 lines
Oh, so this is a replacement for 5/5 and 1-4/5 of v4 are supposed to be identical to those from v3? The difference between [v3 5/5] and this one is a single typofix on the subject line, it seems, though.
Yes, at least that's what I interpreted it as (and how I applied it when testing). I'd like to hear from the author to make sure.
I think I messed up the versions. Its correct that v4 patch was only replacement for 5/5 (5th patch) of v3, since I need to fix the typo error of subject line. Also, other 4 patches (1-4/5) of v3 need to be remain same in v4.
Quoted 7 lines
(As an aside to the author, I often fall into the trap of thinking that it will be easier to send a single replacement patch which will generate less email, but--as you can see--it is often more complicated for reviewers and the maintainer to decipher what's going on. It's often just easier to re-submit the entire series and include in your cover letter "this is unchanged from v(n-1) except for ...").
Yes I realized this, actually earlier I was doubtful about whether to include the previous version's correct patches in the new version or not. I might have confirmed this before sending. But now I will strictly follow this .
Thanks a lot to Junio and Taylor for pointing this out. And in order to correct this, I will send the new patch series having (v3 1-4/5]+[v4]).
Please correct me, if I missed out anything else.
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
As you've demonstrated through the microproject that you can now comfortably be involved in the review discussion, I am tempted to suggest that we declare victory at this point and move on, but I don't know what the plans are for the other 4 patches (I guess we won't miss them that much---the micros are meant to be practice targets).
Yup, ditto.
Quoted 8 lines
Quoted 3 lines
As [v4] single patch won't apply standalone, we cannot quite declare the victory yet. Are [v3 1-5/5] (or [v3 1-4/5] + [v4]) good to the reviewers of the past rounds?
For what it's worth, I'm happy with [v3 1-4/5] + [v4].
Thanks,
Taylor
Thanks and Regards,
Charvi
v5 cover modernize the test scripts
In reply to Charvi MendirattaIn this patch series, I have combined all the correct patches from version 3 and version 4 and this patch series consists of (v3 1-4/5 + v4) patches, else everything remains unchanged. I have also tested by applying it locally, in order to confirm that these patches are usable.
Thanks to Junio and Taylor for the guidance.
This patch series :
-modernize the three test scripts : t7101, t7201 and t7102.
- cleans up with 5 types of changes in all the three scripts.
1. Converting the old style test format to new one
2. Removing blankspaces in test bodies
3. Removing whitespaces after the redirect operator, according to CodingGuidelines
4. Using 'git -C' to avoid use of another subshell
5. Placing commands in separate lines
Charvi Mendiratta (5):
t7101,t7102,t7201: modernize test formatting t7102,t7201: remove unnecessary blank spaces in test body t7102,t7201: remove whitespace after redirect operator
t7201: use 'git -C' to avoid subshell
t7201: put each command on a separate line
t/t7101-reset-empty-subdirs.sh | 66 ++++++++++----------- t/t7102-reset.sh | 63 ++++++++------------ t/t7201-co.sh | 102 +++++++++++++-------------------- 3 files changed, 96 insertions(+), 135 deletions(-)
Signature · 1 line
2.29.0.rc1
PATCH v5 1/5 t7101,t7102,t7201: modernize test formatting
Some tests in these scripts are formatted using a very old style:
test_expect_success \
'title' \
'body line 1 &&
body line 2'Updating the formatting to the modern style:
test_expect_success 'title' '
body line 1 &&
body line 2
'
--- t/t7101-reset-empty-subdirs.sh | 66 +++++++++++++++++----------------- t/t7102-reset.sh | 24 +++++-------- t/t7201-co.sh | 31 ++++++++-------- 3 files changed, 56 insertions(+), 65 deletions(-)
t/t7101-reset-empty-subdirs.sh +33 -33
@@ -6,16 +6,15 @@ test_description='git reset should cull empty subdirs' . ./test-lib.sh -test_expect_success \ - 'creating initial files' \ - 'mkdir path0 && +test_expect_success 'creating initial files' ' + mkdir path0 && cp "$TEST_DIRECTORY"/../COPYING path0/COPYING && git add path0/COPYING && - git commit -m add -a' + git commit -m add -a +' -test_expect_success \ - 'creating second files' \ - 'mkdir path1 && +test_expect_success 'creating second files' ' + mkdir path1 && mkdir path1/path2 && cp "$TEST_DIRECTORY"/../COPYING path1/path2/COPYING && cp "$TEST_DIRECTORY"/../COPYING path1/COPYING &&
@@ -25,39 +24,40 @@ test_expect_success \ git add path1/COPYING && git add COPYING && git add path0/COPYING-TOO && - git commit -m change -a' + git commit -m change -a +' -test_expect_success \ - 'resetting tree HEAD^' \ - 'git reset --hard HEAD^' +test_expect_success 'resetting tree HEAD^' ' + git reset --hard HEAD^ +' -test_expect_success \ - 'checking initial files exist after rewind' \ - 'test -d path0 && - test -f path0/COPYING' +test_expect_success 'checking initial files exist after rewind' ' + test -d path0 && + test -f path0/COPYING +' -test_expect_success \ - 'checking lack of path1/path2/COPYING' \ - '! test -f path1/path2/COPYING' +test_expect_success 'checking lack of path1/path2/COPYING' ' + ! test -f path1/path2/COPYING +' -test_expect_success \ - 'checking lack of path1/COPYING' \ - '! test -f path1/COPYING' +test_expect_success 'checking lack of path1/COPYING' ' + ! test -f path1/COPYING +' -test_expect_success \ - 'checking lack of COPYING' \ - '! test -f COPYING' +test_expect_success 'checking lack of COPYING' ' + ! test -f COPYING +' -test_expect_success \ - 'checking checking lack of path1/COPYING-TOO' \ - '! test -f path0/COPYING-TOO' +test_expect_success 'checking checking lack of path1/COPYING-TOO' ' + ! test -f path0/COPYING-TOO +' -test_expect_success \ - 'checking lack of path1/path2' \ - '! test -d path1/path2' +test_expect_success 'checking lack of path1/path2' ' + ! test -d path1/path2 +' -test_expect_success \ - 'checking lack of path1' \ - '! test -d path1' +test_expect_success 'checking lack of path1' ' + ! test -d path1 +' test_done
t/t7102-reset.sh +8 -16
@@ -107,8 +107,7 @@ test_expect_success 'reset --soft with unmerged index should fail' ' git rm --cached -- un ' -test_expect_success \ - 'giving paths with options different than --mixed should fail' ' +test_expect_success 'giving paths with options different than --mixed should fail' ' test_must_fail git reset --soft -- first && test_must_fail git reset --hard -- first && test_must_fail git reset --soft HEAD^ -- first &&
@@ -128,8 +127,7 @@ test_expect_success 'giving unrecognized options should fail' ' check_changes $head5 ' -test_expect_success \ - 'trying to do reset --soft with pending merge should fail' ' +test_expect_success 'trying to do reset --soft with pending merge should fail' ' git branch branch1 && git branch branch2 &&
@@ -152,8 +150,7 @@ test_expect_success \ check_changes $head5 ' -test_expect_success \ - 'trying to do reset --soft with pending checkout merge should fail' ' +test_expect_success 'trying to do reset --soft with pending checkout merge should fail' ' git branch branch3 && git branch branch4 &&
@@ -175,8 +172,7 @@ test_expect_success \ check_changes $head5 ' -test_expect_success \ - 'resetting to HEAD with no changes should succeed and do nothing' ' +test_expect_success 'resetting to HEAD with no changes should succeed and do nothing' ' git reset --hard && check_changes $head5 && git reset --hard HEAD &&
@@ -226,8 +222,7 @@ secondfile: 2nd line 2nd file 3rd line 2nd file EOF -test_expect_success \ - 'changing files and redo the last commit should succeed' ' +test_expect_success 'changing files and redo the last commit should succeed' ' echo "3rd line 2nd file" >>secondfile && git commit -a -C ORIG_HEAD && head4=$(git rev-parse --verify HEAD) &&
@@ -245,8 +240,7 @@ first: second: 2nd file EOF -test_expect_success \ - '--hard reset should change the files and undo commits permanently' ' +test_expect_success '--hard reset should change the files and undo commits permanently' ' git reset --hard HEAD~2 && check_changes $head5p2 && test "$(git rev-parse ORIG_HEAD)" = \
@@ -284,8 +278,7 @@ secondfile: 1st line 2nd file 2nd line 2nd file EOF -test_expect_success \ - 'redoing changes adding them without commit them should succeed' ' +test_expect_success 'redoing changes adding them without commit them should succeed' ' git rm first && git mv second secondfile &&
@@ -380,8 +373,7 @@ secondfile: 1st line 2nd file 2nd line 2nd file EOF -test_expect_success \ - '--hard reset to ORIG_HEAD should clear a fast-forward merge' ' +test_expect_success '--hard reset to ORIG_HEAD should clear a fast-forward merge' ' git reset --hard HEAD^ && check_changes $head5 &&
t/t7201-co.sh +15 -16
@@ -62,7 +62,7 @@ test_expect_success setup ' git checkout master ' -test_expect_success "checkout from non-existing branch" ' +test_expect_success 'checkout from non-existing branch' ' git checkout -b delete-me master && git update-ref -d --no-deref refs/heads/delete-me &&
@@ -71,7 +71,7 @@ test_expect_success "checkout from non-existing branch" ' test refs/heads/master = "$(git symbolic-ref HEAD)" ' -test_expect_success "checkout with dirty tree without -m" ' +test_expect_success 'checkout with dirty tree without -m' ' fill 0 1 2 3 4 5 6 7 8 >one && if git checkout side
@@ -84,7 +84,7 @@ test_expect_success "checkout with dirty tree without -m" ' ' -test_expect_success "checkout with unrelated dirty tree without -m" ' +test_expect_success 'checkout with unrelated dirty tree without -m' ' git checkout -f master && fill 0 1 2 3 4 5 6 7 8 >same &&
@@ -95,7 +95,7 @@ test_expect_success "checkout with unrelated dirty tree without -m" ' test_cmp messages.expect messages ' -test_expect_success "checkout -m with dirty tree" ' +test_expect_success 'checkout -m with dirty tree' ' git checkout -f master && git clean -f &&
@@ -120,7 +120,7 @@ test_expect_success "checkout -m with dirty tree" ' test_must_be_empty current.index ' -test_expect_success "checkout -m with dirty tree, renamed" ' +test_expect_success 'checkout -m with dirty tree, renamed' ' git checkout -f master && git clean -f &&
@@ -388,22 +388,22 @@ test_expect_success 'checkout specific path while in subdirectory' ' ' -test_expect_success \ - 'checkout w/--track sets up tracking' ' +test_expect_success 'checkout w/--track sets up tracking' ' git config branch.autosetupmerge false && git checkout master && git checkout --track -b track1 && test "$(git config branch.track1.remote)" && - test "$(git config branch.track1.merge)"' + test "$(git config branch.track1.merge)" +' -test_expect_success \ - 'checkout w/autosetupmerge=always sets up tracking' ' +test_expect_success 'checkout w/autosetupmerge=always sets up tracking' ' test_when_finished git config branch.autosetupmerge false && git config branch.autosetupmerge always && git checkout master && git checkout -b track2 && test "$(git config branch.track2.remote)" && - test "$(git config branch.track2.merge)"' + test "$(git config branch.track2.merge)" +' test_expect_success 'checkout w/--track from non-branch HEAD fails' ' git checkout master^0 &&
@@ -435,8 +435,7 @@ test_expect_success 'detach a symbolic link HEAD' ' test "z$(git rev-parse --verify refs/heads/master)" = "z$here" ' -test_expect_success \ - 'checkout with --track fakes a sensible -b <name>' ' +test_expect_success 'checkout with --track fakes a sensible -b <name>' ' git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" && git update-ref refs/remotes/origin/koala/bear renamer &&
@@ -457,9 +456,9 @@ test_expect_success \ test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" ' -test_expect_success \ - 'checkout with --track, but without -b, fails with too short tracked name' ' - test_must_fail git checkout --track renamer' +test_expect_success 'checkout with --track, but without -b, fails with too short tracked name' ' + test_must_fail git checkout --track renamer +' setup_conflicting_index () { rm -f .git/index &&
Signature · 1 line
2.29.0.rc1
PATCH v5 2/5 t7102,t7201: remove unnecessary blank spaces in test body
In reply to Charvi Mendirattat7102 and t7201 still follow the old style of having blank lines around test body, which is not consistence with our current practice.
Let's remove those unnecessary blank lines.
--- t/t7102-reset.sh | 9 --------- t/t7201-co.sh | 25 ------------------------- 2 files changed, 34 deletions(-)
t/t7102-reset.sh +0 -9
@@ -439,7 +439,6 @@ test_expect_success 'test --mixed <paths>' ' ' test_expect_success 'test resetting the index at give paths' ' - mkdir sub && >sub/file1 && >sub/file2 &&
@@ -452,7 +451,6 @@ test_expect_success 'test resetting the index at give paths' ' echo "$U" && test_must_fail git diff-index --cached --exit-code "$T" && test "$T" != "$U" - ' test_expect_success 'resetting an unmodified path is a no-op' '
@@ -490,7 +488,6 @@ test_expect_success 'resetting specific path that is unmerged' ' ' test_expect_success 'disambiguation (1)' ' - git reset --hard && >secondfile && git add secondfile &&
@@ -499,11 +496,9 @@ test_expect_success 'disambiguation (1)' ' test -z "$(git diff --cached --name-only)" && test -f secondfile && test_must_be_empty secondfile - ' test_expect_success 'disambiguation (2)' ' - git reset --hard && >secondfile && git add secondfile &&
@@ -511,11 +506,9 @@ test_expect_success 'disambiguation (2)' ' test_must_fail git reset secondfile && test -n "$(git diff --cached --name-only -- secondfile)" && test ! -f secondfile - ' test_expect_success 'disambiguation (3)' ' - git reset --hard && >secondfile && git add secondfile &&
@@ -524,11 +517,9 @@ test_expect_success 'disambiguation (3)' ' test_must_fail git diff --quiet && test -z "$(git diff --cached --name-only)" && test ! -f secondfile - ' test_expect_success 'disambiguation (4)' ' - git reset --hard && >secondfile && git add secondfile &&
t/t7201-co.sh +0 -25
@@ -33,7 +33,6 @@ fill () { test_expect_success setup ' - fill x y z > same && fill 1 2 3 4 5 6 7 8 >one && fill a b c d e >two &&
@@ -63,7 +62,6 @@ test_expect_success setup ' ' test_expect_success 'checkout from non-existing branch' ' - git checkout -b delete-me master && git update-ref -d --no-deref refs/heads/delete-me && test refs/heads/delete-me = "$(git symbolic-ref HEAD)" &&
@@ -72,7 +70,6 @@ test_expect_success 'checkout from non-existing branch' ' ' test_expect_success 'checkout with dirty tree without -m' ' - fill 0 1 2 3 4 5 6 7 8 >one && if git checkout side then
@@ -81,11 +78,9 @@ test_expect_success 'checkout with dirty tree without -m' ' else echo "happy - failed correctly" fi - ' test_expect_success 'checkout with unrelated dirty tree without -m' ' - git checkout -f master && fill 0 1 2 3 4 5 6 7 8 >same && cp same kept &&
@@ -96,7 +91,6 @@ test_expect_success 'checkout with unrelated dirty tree without -m' ' ' test_expect_success 'checkout -m with dirty tree' ' - git checkout -f master && git clean -f &&
@@ -121,7 +115,6 @@ test_expect_success 'checkout -m with dirty tree' ' ' test_expect_success 'checkout -m with dirty tree, renamed' ' - git checkout -f master && git clean -f && fill 1 2 3 4 5 7 8 >one &&
@@ -139,11 +132,9 @@ test_expect_success 'checkout -m with dirty tree, renamed' ' ! test -f one && git diff --cached >current && test_must_be_empty current - ' test_expect_success 'checkout -m with merge conflict' ' - git checkout -f master && git clean -f && fill 1 T 3 4 5 6 S 8 >one &&
@@ -166,7 +157,6 @@ test_expect_success 'checkout -m with merge conflict' ' ' test_expect_success 'format of merge conflict from checkout -m' ' - git checkout -f master && git clean -f && fill b d > two &&
@@ -190,7 +180,6 @@ test_expect_success 'format of merge conflict from checkout -m' ' ' test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' - git checkout -f master && git reset --hard && git clean -f && fill b d > two &&
@@ -216,7 +205,6 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' ' test_expect_success 'switch to another branch while carrying a deletion' ' - git checkout -f master && git reset --hard && git clean -f && git rm two &&
@@ -228,7 +216,6 @@ test_expect_success 'switch to another branch while carrying a deletion' ' ' test_expect_success 'checkout to detach HEAD (with advice declined)' ' - git config advice.detachedHead false && rev=$(git rev-parse --short renamer^) && git checkout -f renamer && git clean -f &&
@@ -267,7 +254,6 @@ test_expect_success 'checkout to detach HEAD' ' ' test_expect_success 'checkout to detach HEAD with branchname^' ' - git checkout -f master && git clean -f && git checkout renamer^ && H=$(git rev-parse --verify HEAD) &&
@@ -283,7 +269,6 @@ test_expect_success 'checkout to detach HEAD with branchname^' ' ' test_expect_success 'checkout to detach HEAD with :/message' ' - git checkout -f master && git clean -f && git checkout ":/Initial" && H=$(git rev-parse --verify HEAD) &&
@@ -299,7 +284,6 @@ test_expect_success 'checkout to detach HEAD with :/message' ' ' test_expect_success 'checkout to detach HEAD with HEAD^0' ' - git checkout -f master && git clean -f && git checkout HEAD^0 && H=$(git rev-parse --verify HEAD) &&
@@ -315,7 +299,6 @@ test_expect_success 'checkout to detach HEAD with HEAD^0' ' ' test_expect_success 'checkout with ambiguous tag/branch names' ' - git tag both side && git branch both master && git reset --hard &&
@@ -327,11 +310,9 @@ test_expect_success 'checkout with ambiguous tag/branch names' ' test "z$H" = "z$M" && name=$(git symbolic-ref HEAD 2>/dev/null) && test "z$name" = zrefs/heads/both - ' test_expect_success 'checkout with ambiguous tag/branch names' ' - git reset --hard && git checkout master &&
@@ -351,11 +332,9 @@ test_expect_success 'checkout with ambiguous tag/branch names' ' else : happy fi - ' test_expect_success 'switch branches while in subdirectory' ' - git reset --hard && git checkout master &&
@@ -366,11 +345,9 @@ test_expect_success 'switch branches while in subdirectory' ' ) && ! test -f subs/one && rm -fr subs - ' test_expect_success 'checkout specific path while in subdirectory' ' - git reset --hard && git checkout side && mkdir subs &&
@@ -385,7 +362,6 @@ test_expect_success 'checkout specific path while in subdirectory' ' git checkout side -- bero ) && test -f subs/bero - ' test_expect_success 'checkout w/--track sets up tracking' '
@@ -608,7 +584,6 @@ test_expect_success 'failing checkout -b should not break working tree' ' test $(git symbolic-ref HEAD) = refs/heads/master && git diff --exit-code && git diff --cached --exit-code - ' test_expect_success 'switch out of non-branch' '
Signature · 1 line
2.29.0.rc1
PATCH v5 3/5 t7102,t7201: remove whitespace after redirect operator
In reply to Charvi MendirattaAccording to Documentation/CodingGuidelines, redirect operator is written with space before, but no space after them.
Let's remove these whitespaces after redirect operators.
--- t/t7102-reset.sh | 30 +++++++++++++++--------------- t/t7201-co.sh | 10 +++++----- 2 files changed, 20 insertions(+), 20 deletions(-)
t/t7102-reset.sh +15 -15
@@ -70,15 +70,15 @@ check_changes () { test_expect_success 'reset --hard message' ' hex=$(git log -1 --format="%h") && - git reset --hard > .actual && - echo HEAD is now at $hex $(commit_msg) > .expected && + git reset --hard >.actual && + echo HEAD is now at $hex $(commit_msg) >.expected && test_i18ncmp .expected .actual ' test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' ' hex=$(git log -1 --format="%h") && - git -c "i18n.logOutputEncoding=$test_encoding" reset --hard > .actual && - echo HEAD is now at $hex $(commit_msg $test_encoding) > .expected && + git -c "i18n.logOutputEncoding=$test_encoding" reset --hard >.actual && + echo HEAD is now at $hex $(commit_msg $test_encoding) >.expected && test_i18ncmp .expected .actual '
@@ -387,25 +387,25 @@ test_expect_success '--hard reset to ORIG_HEAD should clear a fast-forward merge ' test_expect_success 'test --mixed <paths>' ' - echo 1 > file1 && - echo 2 > file2 && + echo 1 >file1 && + echo 2 >file2 && git add file1 file2 && test_tick && git commit -m files && before1=$(git rev-parse --short HEAD:file1) && before2=$(git rev-parse --short HEAD:file2) && git rm file2 && - echo 3 > file3 && - echo 4 > file4 && - echo 5 > file1 && + echo 3 >file3 && + echo 4 >file4 && + echo 5 >file1 && after1=$(git rev-parse --short $(git hash-object file1)) && after4=$(git rev-parse --short $(git hash-object file4)) && git add file1 file3 file4 && git reset HEAD -- file1 file2 file3 && test_must_fail git diff --quiet && - git diff > output && + git diff >output && - cat > expect <<-EOF && + cat >expect <<-EOF && diff --git a/file1 b/file1 index $before1..$after1 100644 --- a/file1
@@ -423,9 +423,9 @@ test_expect_success 'test --mixed <paths>' ' EOF test_cmp expect output && - git diff --cached > output && + git diff --cached >output && - cat > cached_expect <<-EOF && + cat >cached_expect <<-EOF && diff --git a/file4 b/file4 new file mode 100644 index 0000000..$after4
@@ -460,14 +460,14 @@ test_expect_success 'resetting an unmodified path is a no-op' ' git diff-index --cached --exit-code HEAD ' -cat > expect << EOF +cat >expect << EOF Unstaged changes after reset: M file2 EOF test_expect_success '--mixed refreshes the index' ' echo 123 >> file2 && - git reset --mixed HEAD > output && + git reset --mixed HEAD >output && test_i18ncmp expect output '
t/t7201-co.sh +5 -5
@@ -33,7 +33,7 @@ fill () { test_expect_success setup ' - fill x y z > same && + fill x y z >same && fill 1 2 3 4 5 6 7 8 >one && fill a b c d e >two && git add same one two &&
@@ -55,7 +55,7 @@ test_expect_success setup ' git checkout -b simple master && rm -f one && - fill a c e > two && + fill a c e >two && git commit -a -m "Simple D one, M two" && git checkout master
@@ -95,7 +95,7 @@ test_expect_success 'checkout -m with dirty tree' ' git clean -f && fill 0 1 2 3 4 5 6 7 8 >one && - git checkout -m side > messages && + git checkout -m side >messages && test "$(git symbolic-ref HEAD)" = "refs/heads/side" &&
@@ -159,7 +159,7 @@ test_expect_success 'checkout -m with merge conflict' ' test_expect_success 'format of merge conflict from checkout -m' ' git checkout -f master && git clean -f && - fill b d > two && + fill b d >two && git checkout -m simple && git ls-files >current &&
@@ -182,7 +182,7 @@ test_expect_success 'format of merge conflict from checkout -m' ' test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' git checkout -f master && git reset --hard && git clean -f && - fill b d > two && + fill b d >two && git checkout --merge --conflict=diff3 simple && cat <<-EOF >expect &&
Signature · 1 line
2.29.0.rc1
PATCH v5 4/5 t7201: use 'git -C' to avoid subshell
In reply to Charvi Mendiratta--- t/t7201-co.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
t/t7201-co.sh +2 -8
@@ -339,10 +339,7 @@ test_expect_success 'switch branches while in subdirectory' ' git checkout master && mkdir subs && - ( - cd subs && - git checkout side - ) && + git -C subs checkout side && ! test -f subs/one && rm -fr subs '
@@ -357,10 +354,7 @@ test_expect_success 'checkout specific path while in subdirectory' ' git checkout master && mkdir -p subs && - ( - cd subs && - git checkout side -- bero - ) && + git -C subs checkout side -- bero && test -f subs/bero '
Signature · 1 line
2.29.0.rc1
PATCH v5 5/5 t7201: put each command on a separate line
In reply to Charvi MendirattaModern practice is to avoid multiple commands per line, and instead place each command on its own line.
--- t/t7201-co.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
t/t7201-co.sh +18 -8
@@ -157,7 +157,8 @@ test_expect_success 'checkout -m with merge conflict' ' ' test_expect_success 'format of merge conflict from checkout -m' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && fill b d >two && git checkout -m simple &&
@@ -180,7 +181,9 @@ test_expect_success 'format of merge conflict from checkout -m' ' ' test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' - git checkout -f master && git reset --hard && git clean -f && + git checkout -f master && + git reset --hard && + git clean -f && fill b d >two && git checkout --merge --conflict=diff3 simple &&
@@ -205,7 +208,9 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' ' test_expect_success 'switch to another branch while carrying a deletion' ' - git checkout -f master && git reset --hard && git clean -f && + git checkout -f master && + git reset --hard && + git clean -f && git rm two && test_must_fail git checkout simple 2>errs &&
@@ -218,7 +223,8 @@ test_expect_success 'switch to another branch while carrying a deletion' ' test_expect_success 'checkout to detach HEAD (with advice declined)' ' git config advice.detachedHead false && rev=$(git rev-parse --short renamer^) && - git checkout -f renamer && git clean -f && + git checkout -f renamer && + git clean -f && git checkout renamer^ 2>messages && test_i18ngrep "HEAD is now at $rev" messages && test_line_count = 1 messages &&
@@ -237,7 +243,8 @@ test_expect_success 'checkout to detach HEAD (with advice declined)' ' test_expect_success 'checkout to detach HEAD' ' git config advice.detachedHead true && rev=$(git rev-parse --short renamer^) && - git checkout -f renamer && git clean -f && + git checkout -f renamer && + git clean -f && GIT_TEST_GETTEXT_POISON=false git checkout renamer^ 2>messages && grep "HEAD is now at $rev" messages && test_line_count -gt 1 messages &&
@@ -254,7 +261,8 @@ test_expect_success 'checkout to detach HEAD' ' ' test_expect_success 'checkout to detach HEAD with branchname^' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout renamer^ && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&
@@ -269,7 +277,8 @@ test_expect_success 'checkout to detach HEAD with branchname^' ' ' test_expect_success 'checkout to detach HEAD with :/message' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout ":/Initial" && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&
@@ -284,7 +293,8 @@ test_expect_success 'checkout to detach HEAD with :/message' ' ' test_expect_success 'checkout to detach HEAD with HEAD^0' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout HEAD^0 && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&
Signature · 1 line
2.29.0.rc1
Re: [PATCH v4] t7201: put each command on a separate line
In reply to Junio C HamanoQuoted 21 lines · Junio C Hamano
Quoted 11 lines · Junio C Hamano
Quoted 5 lines · Charvi Mendiratta
Modern practice is to avoid multiple commands per line, and instead place each command on its own line.
Signed-off-by Charvi Mendiratta <[email protected]>---
This looks good, but I am wondering what happened between v3 and v4.
Quoted 6 lines
As you've demonstrated through the microproject that you can now comfortably be involved in the review discussion, I am tempted to suggest that we declare victory at this point and move on, but I don't know what the plans are for the other 4 patches (I guess we won't miss them that much---the micros are meant to be practice targets).
Quoted 4 lines
Actually I take it back. This does not look good as a standalone patch at all. It seems to depend on something in the 5-patch series.
Yes, Thanks a lot Junio. I totally agree after applying it locally and getting stuck in am conflicts without using v3.
Quoted 3 lines
Please make sure that patches you send are usable by your recipients.
I will take this as an important note. I have fixed it and sent the patch series after testing it locally .
Thanks and Regards,
Charvi
Re: [PATCH v5 3/5][Outreachy] t7102,t7201: remove whitespace after redirect operator
In reply to Charvi Mendirattat/t7102-reset.sh test_expect_success 'resetting an unmodified path is a no-op' ' · line 460
Quoted 12 lines · Charvi Mendiratta
According to
Documentation/CodingGuidelines, redirect operator is written with space before, but no space after them.Let's remove these whitespaces after redirect operators.
Signed-off-by Charvi Mendiratta <[email protected]>---
t/t7102-reset.sh +1
-1@@ -460,14 +460,14 @@ test_expect_success 'resetting an unmodified path is a no-op' ' -cat > expect << EOF +cat >expect << EOF
There's still a space after the '<<' operator which should be removed:
cat >expect <<EOF
Re: [PATCH v5 3/5][Outreachy] t7102,t7201: remove whitespace after redirect operator
Quoted 16 lines · Eric Sunshine
t/t7102-reset.sh test_expect_success 'resetting an unmodified path is a no-op' ' · line 460
Quoted 12 lines · Charvi Mendiratta
According to
Documentation/CodingGuidelines, redirect operator is written with space before, but no space after them.Let's remove these whitespaces after redirect operators.
Signed-off-by Charvi Mendiratta <[email protected]>---
t/t7102-reset.sh +1
-1@@ -460,14 +460,14 @@ test_expect_success 'resetting an unmodified path is a no-op' ' -cat > expect << EOF +cat >expect << EOFThere's still a space after the '<<' operator which should be removed:
Quoted 1 line
cat >expect <<EOF
Also, this is outside any test_expect_*, which is unusual in modernized test scripts. There are many other instances of preparing expected output outside test_expect_* in this file, so we may need another patch to clean them up.
For now, within the context of this patch, let's just fix the space after the << here-doc redirection operator, as you spotted. The attached I'll squash into this patch.
Thanks.
t/t7102-reset.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
t/t7102-reset.sh +1 -1
@@ -460,7 +460,7 @@ test_expect_success 'resetting an unmodified path is a no-op' ' git diff-index --cached --exit-code HEAD ' -cat >expect << EOF +cat >expect <<EOF Unstaged changes after reset: M file2 EOF
Re: [PATCH v5 3/5][Outreachy] t7102,t7201: remove whitespace after redirect operator
Quoted 9 lines · Junio C Hamano
Quoted 3 lines · Eric Sunshine
There's still a space after the '<<' operator which should be removed:
cat >expect <<EOF
Also, this is outside any test_expect_*, which is unusual in modernized test scripts. There are many other instances of preparing expected output outside test_expect_* in this file, so we may need another patch to clean them up.
I noticed that, as well, but wasn't sure if mentioning it was worthwhile considering that this is a microproject and we're already at v5. It can certainly be addressed by someone as a follow-on patch if desired.
t/t7102-reset.sh test_expect_success 'resetting an unmodified path is a no-op' ' · line 463
Quoted 6 lines
For now, within the context of this patch, let's just fix the space after the << here-doc redirection operator, as you spotted. The attached I'll squash into this patch.
t/t7102-reset.sh +1
-1-cat >expect << EOF +cat >expect <<EOF
Looks fine.
Re: [PATCH v5 3/5][Outreachy] t7102,t7201: remove whitespace after redirect operator
In reply to Junio C HamanoQuoted 8 lines · Junio C Hamano
Also, this is outside any test_expect_*, which is unusual in modernized test scripts. There are many other instances of preparing expected output outside test_expect_* in this file, so we may need another patch to clean them up.
For now, within the context of this patch, let's just fix the space after the << here-doc redirection operator, as you spotted. The attached I'll squash into this patch.
And the other clean-up patch would look like this.
--- >8 ---
Subject: t7102: prepare expected output inside test_expect_* block
That way we can notice if there is a breakage/bug in the parts of the test that prepare the expected outcome, which is how modern tests are arranged.
--- t/t7102-reset.sh | 244 +++++++++++++++++++++++++++---------------------------- 1 file changed, 121 insertions(+), 123 deletions(-)
t/t7102-reset.sh +121 -123
@@ -82,15 +82,15 @@ test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' ' test_i18ncmp .expected .actual ' ->.diff_expect ->.cached_expect -cat >.cat_expect <<EOF -secondfile: -1st line 2nd file -2nd line 2nd file -EOF - test_expect_success 'giving a non existing revision should fail' ' + >.diff_expect && + >.cached_expect && + cat >.cat_expect <<-\EOF && + secondfile: + 1st line 2nd file + 2nd line 2nd file + EOF + test_must_fail git reset aaaaaa && test_must_fail git reset --mixed aaaaaa && test_must_fail git reset --soft aaaaaa &&
@@ -191,38 +191,38 @@ test_expect_success 'resetting to HEAD with no changes should succeed and do not check_changes $head5 ' ->.diff_expect -cat >.cached_expect <<EOF -diff --git a/secondfile b/secondfile -index $head5p1s..$head5s 100644 ---- a/secondfile -+++ b/secondfile -@@ -1 +1,2 @@ --2nd file -+1st line 2nd file -+2nd line 2nd file -EOF -cat >.cat_expect <<EOF -secondfile: -1st line 2nd file -2nd line 2nd file -EOF test_expect_success '--soft reset only should show changes in diff --cached' ' + >.diff_expect && + cat >.cached_expect <<-EOF && + diff --git a/secondfile b/secondfile + index $head5p1s..$head5s 100644 + --- a/secondfile + +++ b/secondfile + @@ -1 +1,2 @@ + -2nd file + +1st line 2nd file + +2nd line 2nd file + EOF + cat >.cat_expect <<-\EOF && + secondfile: + 1st line 2nd file + 2nd line 2nd file + EOF git reset --soft HEAD^ && check_changes $head5p1 && test "$(git rev-parse ORIG_HEAD)" = \ $head5 ' ->.diff_expect ->.cached_expect -cat >.cat_expect <<EOF -secondfile: -1st line 2nd file -2nd line 2nd file -3rd line 2nd file -EOF test_expect_success 'changing files and redo the last commit should succeed' ' + >.diff_expect && + >.cached_expect && + cat >.cat_expect <<-\EOF && + secondfile: + 1st line 2nd file + 2nd line 2nd file + 3rd line 2nd file + EOF echo "3rd line 2nd file" >>secondfile && git commit -a -C ORIG_HEAD && head4=$(git rev-parse --verify HEAD) &&
@@ -231,54 +231,54 @@ test_expect_success 'changing files and redo the last commit should succeed' ' $head5 ' ->.diff_expect ->.cached_expect -cat >.cat_expect <<EOF -first: -1st file -2nd line 1st file -second: -2nd file -EOF test_expect_success '--hard reset should change the files and undo commits permanently' ' + >.diff_expect && + >.cached_expect && + cat >.cat_expect <<-\EOF && + first: + 1st file + 2nd line 1st file + second: + 2nd file + EOF git reset --hard HEAD~2 && check_changes $head5p2 && test "$(git rev-parse ORIG_HEAD)" = \ $head4 ' ->.diff_expect -cat >.cached_expect <<EOF -diff --git a/first b/first -deleted file mode 100644 -index $head5p2f..0000000 ---- a/first -+++ /dev/null -@@ -1,2 +0,0 @@ --1st file --2nd line 1st file -diff --git a/second b/second -deleted file mode 100644 -index $head5p1s..0000000 ---- a/second -+++ /dev/null -@@ -1 +0,0 @@ --2nd file -diff --git a/secondfile b/secondfile -new file mode 100644 -index 0000000..$head5s ---- /dev/null -+++ b/secondfile -@@ -0,0 +1,2 @@ -+1st line 2nd file -+2nd line 2nd file -EOF -cat >.cat_expect <<EOF -secondfile: -1st line 2nd file -2nd line 2nd file -EOF test_expect_success 'redoing changes adding them without commit them should succeed' ' + >.diff_expect && + cat >.cached_expect <<-EOF && + diff --git a/first b/first + deleted file mode 100644 + index $head5p2f..0000000 + --- a/first + +++ /dev/null + @@ -1,2 +0,0 @@ + -1st file + -2nd line 1st file + diff --git a/second b/second + deleted file mode 100644 + index $head5p1s..0000000 + --- a/second + +++ /dev/null + @@ -1 +0,0 @@ + -2nd file + diff --git a/secondfile b/secondfile + new file mode 100644 + index 0000000..$head5s + --- /dev/null + +++ b/secondfile + @@ -0,0 +1,2 @@ + +1st line 2nd file + +2nd line 2nd file + EOF + cat >.cat_expect <<-\EOF && + secondfile: + 1st line 2nd file + 2nd line 2nd file + EOF git rm first && git mv second secondfile &&
@@ -288,46 +288,45 @@ test_expect_success 'redoing changes adding them without commit them should succ check_changes $head5p2 ' -cat >.diff_expect <<EOF -diff --git a/first b/first -deleted file mode 100644 -index $head5p2f..0000000 ---- a/first -+++ /dev/null -@@ -1,2 +0,0 @@ --1st file --2nd line 1st file -diff --git a/second b/second -deleted file mode 100644 -index $head5p1s..0000000 ---- a/second -+++ /dev/null -@@ -1 +0,0 @@ --2nd file -EOF ->.cached_expect -cat >.cat_expect <<EOF -secondfile: -1st line 2nd file -2nd line 2nd file -EOF test_expect_success '--mixed reset to HEAD should unadd the files' ' + cat >.diff_expect <<-EOF && + diff --git a/first b/first + deleted file mode 100644 + index $head5p2f..0000000 + --- a/first + +++ /dev/null + @@ -1,2 +0,0 @@ + -1st file + -2nd line 1st file + diff --git a/second b/second + deleted file mode 100644 + index $head5p1s..0000000 + --- a/second + +++ /dev/null + @@ -1 +0,0 @@ + -2nd file + EOF + >.cached_expect && + cat >.cat_expect <<-\EOF && + secondfile: + 1st line 2nd file + 2nd line 2nd file + EOF git reset && check_changes $head5p2 && test "$(git rev-parse ORIG_HEAD)" = $head5p2 ' ->.diff_expect ->.cached_expect -cat >.cat_expect <<EOF -secondfile: -1st line 2nd file -2nd line 2nd file -EOF test_expect_success 'redoing the last two commits should succeed' ' + >.diff_expect && + >.cached_expect && + cat >.cat_expect <<-\EOF && + secondfile: + 1st line 2nd file + 2nd line 2nd file + EOF git add secondfile && git reset --hard $head5p2 && - git rm first && git mv second secondfile && git commit -a -m "remove 1st and rename 2nd" &&
@@ -340,15 +339,15 @@ test_expect_success 'redoing the last two commits should succeed' ' check_changes $head5 ' ->.diff_expect ->.cached_expect -cat >.cat_expect <<EOF -secondfile: -1st line 2nd file -2nd line 2nd file -3rd line in branch2 -EOF test_expect_success '--hard reset to HEAD should clear a failed merge' ' + >.diff_expect && + >.cached_expect && + cat >.cat_expect <<-\EOF && + secondfile: + 1st line 2nd file + 2nd line 2nd file + 3rd line in branch2 + EOF git branch branch1 && git branch branch2 &&
@@ -366,14 +365,14 @@ test_expect_success '--hard reset to HEAD should clear a failed merge' ' check_changes $head3 ' ->.diff_expect ->.cached_expect -cat >.cat_expect <<EOF -secondfile: -1st line 2nd file -2nd line 2nd file -EOF test_expect_success '--hard reset to ORIG_HEAD should clear a fast-forward merge' ' + >.diff_expect && + >.cached_expect && + cat >.cat_expect <<-\EOF && + secondfile: + 1st line 2nd file + 2nd line 2nd file + EOF git reset --hard HEAD^ && check_changes $head5 &&
@@ -460,12 +459,11 @@ test_expect_success 'resetting an unmodified path is a no-op' ' git diff-index --cached --exit-code HEAD ' -cat >expect <<EOF -Unstaged changes after reset: -M file2 -EOF - test_expect_success '--mixed refreshes the index' ' + cat >expect <<-\EOF && + Unstaged changes after reset: + M file2 + EOF echo 123 >> file2 && git reset --mixed HEAD >output && test_i18ncmp expect output
Re: [PATCH v5 3/5][Outreachy] t7102,t7201: remove whitespace after redirect operator
Quoted 8 lines · Junio C Hamano
Subject: t7102: prepare expected output inside test_expect_* block
Signed-off-by Junio C Hamano <[email protected]>---
w/t/t7102-reset.sh renamed from c/t/t7102-reset.sh +0
-2@@ -82,15 +82,15 @@ test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' ' ->.diff_expect ->.cached_expect
w/t/t7102-reset.sh test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' ' · line 87
Quoted 10 lines
w/t/t7102-reset.sh renamed from c/t/t7102-reset.sh +5
-4-cat >.cat_expect <<EOF -secondfile: -EOF - test_expect_success 'giving a non existing revision should fail' ' + >.diff_expect && + >.cached_expect && + cat >.cat_expect <<-\EOF && + secondfile: + EOF
You used <<-\EOF rather than plain <<-EOF when possible. Good.
(Might be worth mention in the commit message, but perhaps too minor?)
w/t/t7102-reset.sh test_expect_success 'resetting to HEAD with no changes should succeed and do not · line 195
Quoted 6 lines
w/t/t7102-reset.sh renamed from c/t/t7102-reset.sh +4
-0@@ -191,38 +191,38 @@ test_expect_success 'resetting to HEAD with no changes should succeed and do not test_expect_success '--soft reset only should show changes in diff --cached' ' + >.diff_expect && + cat >.cached_expect <<-EOF && + diff --git a/secondfile b/secondfile + index $head5p1s..$head5s 100644
And used plain <<-EOF when necessary. Fine.
Re: [PATCH v5 3/5][Outreachy] t7102,t7201: remove whitespace after redirect operator
In reply to Junio C HamanoQuoted 26 lines · Junio C Hamano
Quoted 16 lines · Eric Sunshine
t/t7102-reset.sh test_expect_success 'resetting an unmodified path is a no-op' ' · line 460
Quoted 12 lines · Charvi Mendiratta
According to
Documentation/CodingGuidelines, redirect operator is written with space before, but no space after them.Let's remove these whitespaces after redirect operators.
Signed-off-by Charvi Mendiratta <[email protected]>---
t/t7102-reset.sh +1
-1@@ -460,14 +460,14 @@ test_expect_success 'resetting an unmodified path is a no-op' ' -cat > expect << EOF +cat >expect << EOFThere's still a space after the '<<' operator which should be removed:
Quoted 1 line
cat >expect <<EOF
Also, this is outside any test_expect_*, which is unusual in modernized test scripts. There are many other instances of preparing expected output outside test_expect_* in this file, so we may need another patch to clean them up.
Quoted 6 lines
For now, within the context of this patch, let's just fix the space after the << here-doc redirection operator, as you spotted. The attached I'll squash into this patch.
Thanks.
Thanks Eric and Junio, I am resending the patch with the fix of space after << as mentioned.
Quoted 19 lines
t/t7102-reset.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)t/t7102-reset.sh +1
-1@@ -460,7 +460,7 @@ test_expect_success 'resetting an unmodified path is a no-op' ' git diff-index --cached --exit-code HEAD ' -cat >expect << EOF +cat >expect <<EOF Unstaged changes after reset: M file2 EOF
v6 cover modernize test scripts
In reply to Charvi MendirattaIn this patch series, I have fixed the remaining errors of whitespace after redirect operator in t7102 test script and v5 3/5 is updated. Other patches remains unchanged.
This patch series :
-modernize the three test scripts : t7101, t7201 and t7102.
- cleans up with 5 types of changes in all the three scripts.
1. Converting the old style test format to new one
2. Removing blankspaces in test bodies
3. Removing whitespaces after the redirect operator, according to CodingGuidelines
4. Using 'git -C' to avoid use of another subshell
5. Placing commands in separate lines
Charvi Mendiratta (5):
t7101,t7102,t7201: modernize test formatting t7102,t7201: remove unnecessary blank spaces in test body t7102,t7201: remove whitespace after redirect operator
t7201: use 'git -C' to avoid subshell
t7201: put each command on a separate line
t/t7101-reset-empty-subdirs.sh | 66 ++++++++++----------- t/t7102-reset.sh | 65 ++++++++------------- t/t7201-co.sh | 102 +++++++++++++-------------------- 3 files changed, 97 insertions(+), 136 deletions(-)
Signature · 1 line
2.29.0.rc1
PATCH v6 1/5 t7101,t7102,t7201: modernize test formatting
In reply to Charvi MendirattaSome tests in these scripts are formatted using a very old style:
test_expect_success \
'title' \
'body line 1 &&
body line 2'Updating the formatting to the modern style:
test_expect_success 'title' '
body line 1 &&
body line 2
'
--- t/t7101-reset-empty-subdirs.sh | 66 +++++++++++++++++----------------- t/t7102-reset.sh | 24 +++++-------- t/t7201-co.sh | 31 ++++++++-------- 3 files changed, 56 insertions(+), 65 deletions(-)
t/t7101-reset-empty-subdirs.sh +33 -33
@@ -6,16 +6,15 @@ test_description='git reset should cull empty subdirs' . ./test-lib.sh -test_expect_success \ - 'creating initial files' \ - 'mkdir path0 && +test_expect_success 'creating initial files' ' + mkdir path0 && cp "$TEST_DIRECTORY"/../COPYING path0/COPYING && git add path0/COPYING && - git commit -m add -a' + git commit -m add -a +' -test_expect_success \ - 'creating second files' \ - 'mkdir path1 && +test_expect_success 'creating second files' ' + mkdir path1 && mkdir path1/path2 && cp "$TEST_DIRECTORY"/../COPYING path1/path2/COPYING && cp "$TEST_DIRECTORY"/../COPYING path1/COPYING &&
@@ -25,39 +24,40 @@ test_expect_success \ git add path1/COPYING && git add COPYING && git add path0/COPYING-TOO && - git commit -m change -a' + git commit -m change -a +' -test_expect_success \ - 'resetting tree HEAD^' \ - 'git reset --hard HEAD^' +test_expect_success 'resetting tree HEAD^' ' + git reset --hard HEAD^ +' -test_expect_success \ - 'checking initial files exist after rewind' \ - 'test -d path0 && - test -f path0/COPYING' +test_expect_success 'checking initial files exist after rewind' ' + test -d path0 && + test -f path0/COPYING +' -test_expect_success \ - 'checking lack of path1/path2/COPYING' \ - '! test -f path1/path2/COPYING' +test_expect_success 'checking lack of path1/path2/COPYING' ' + ! test -f path1/path2/COPYING +' -test_expect_success \ - 'checking lack of path1/COPYING' \ - '! test -f path1/COPYING' +test_expect_success 'checking lack of path1/COPYING' ' + ! test -f path1/COPYING +' -test_expect_success \ - 'checking lack of COPYING' \ - '! test -f COPYING' +test_expect_success 'checking lack of COPYING' ' + ! test -f COPYING +' -test_expect_success \ - 'checking checking lack of path1/COPYING-TOO' \ - '! test -f path0/COPYING-TOO' +test_expect_success 'checking checking lack of path1/COPYING-TOO' ' + ! test -f path0/COPYING-TOO +' -test_expect_success \ - 'checking lack of path1/path2' \ - '! test -d path1/path2' +test_expect_success 'checking lack of path1/path2' ' + ! test -d path1/path2 +' -test_expect_success \ - 'checking lack of path1' \ - '! test -d path1' +test_expect_success 'checking lack of path1' ' + ! test -d path1 +' test_done
t/t7102-reset.sh +8 -16
@@ -107,8 +107,7 @@ test_expect_success 'reset --soft with unmerged index should fail' ' git rm --cached -- un ' -test_expect_success \ - 'giving paths with options different than --mixed should fail' ' +test_expect_success 'giving paths with options different than --mixed should fail' ' test_must_fail git reset --soft -- first && test_must_fail git reset --hard -- first && test_must_fail git reset --soft HEAD^ -- first &&
@@ -128,8 +127,7 @@ test_expect_success 'giving unrecognized options should fail' ' check_changes $head5 ' -test_expect_success \ - 'trying to do reset --soft with pending merge should fail' ' +test_expect_success 'trying to do reset --soft with pending merge should fail' ' git branch branch1 && git branch branch2 &&
@@ -152,8 +150,7 @@ test_expect_success \ check_changes $head5 ' -test_expect_success \ - 'trying to do reset --soft with pending checkout merge should fail' ' +test_expect_success 'trying to do reset --soft with pending checkout merge should fail' ' git branch branch3 && git branch branch4 &&
@@ -175,8 +172,7 @@ test_expect_success \ check_changes $head5 ' -test_expect_success \ - 'resetting to HEAD with no changes should succeed and do nothing' ' +test_expect_success 'resetting to HEAD with no changes should succeed and do nothing' ' git reset --hard && check_changes $head5 && git reset --hard HEAD &&
@@ -226,8 +222,7 @@ secondfile: 2nd line 2nd file 3rd line 2nd file EOF -test_expect_success \ - 'changing files and redo the last commit should succeed' ' +test_expect_success 'changing files and redo the last commit should succeed' ' echo "3rd line 2nd file" >>secondfile && git commit -a -C ORIG_HEAD && head4=$(git rev-parse --verify HEAD) &&
@@ -245,8 +240,7 @@ first: second: 2nd file EOF -test_expect_success \ - '--hard reset should change the files and undo commits permanently' ' +test_expect_success '--hard reset should change the files and undo commits permanently' ' git reset --hard HEAD~2 && check_changes $head5p2 && test "$(git rev-parse ORIG_HEAD)" = \
@@ -284,8 +278,7 @@ secondfile: 1st line 2nd file 2nd line 2nd file EOF -test_expect_success \ - 'redoing changes adding them without commit them should succeed' ' +test_expect_success 'redoing changes adding them without commit them should succeed' ' git rm first && git mv second secondfile &&
@@ -380,8 +373,7 @@ secondfile: 1st line 2nd file 2nd line 2nd file EOF -test_expect_success \ - '--hard reset to ORIG_HEAD should clear a fast-forward merge' ' +test_expect_success '--hard reset to ORIG_HEAD should clear a fast-forward merge' ' git reset --hard HEAD^ && check_changes $head5 &&
t/t7201-co.sh +15 -16
@@ -62,7 +62,7 @@ test_expect_success setup ' git checkout master ' -test_expect_success "checkout from non-existing branch" ' +test_expect_success 'checkout from non-existing branch' ' git checkout -b delete-me master && git update-ref -d --no-deref refs/heads/delete-me &&
@@ -71,7 +71,7 @@ test_expect_success "checkout from non-existing branch" ' test refs/heads/master = "$(git symbolic-ref HEAD)" ' -test_expect_success "checkout with dirty tree without -m" ' +test_expect_success 'checkout with dirty tree without -m' ' fill 0 1 2 3 4 5 6 7 8 >one && if git checkout side
@@ -84,7 +84,7 @@ test_expect_success "checkout with dirty tree without -m" ' ' -test_expect_success "checkout with unrelated dirty tree without -m" ' +test_expect_success 'checkout with unrelated dirty tree without -m' ' git checkout -f master && fill 0 1 2 3 4 5 6 7 8 >same &&
@@ -95,7 +95,7 @@ test_expect_success "checkout with unrelated dirty tree without -m" ' test_cmp messages.expect messages ' -test_expect_success "checkout -m with dirty tree" ' +test_expect_success 'checkout -m with dirty tree' ' git checkout -f master && git clean -f &&
@@ -120,7 +120,7 @@ test_expect_success "checkout -m with dirty tree" ' test_must_be_empty current.index ' -test_expect_success "checkout -m with dirty tree, renamed" ' +test_expect_success 'checkout -m with dirty tree, renamed' ' git checkout -f master && git clean -f &&
@@ -388,22 +388,22 @@ test_expect_success 'checkout specific path while in subdirectory' ' ' -test_expect_success \ - 'checkout w/--track sets up tracking' ' +test_expect_success 'checkout w/--track sets up tracking' ' git config branch.autosetupmerge false && git checkout master && git checkout --track -b track1 && test "$(git config branch.track1.remote)" && - test "$(git config branch.track1.merge)"' + test "$(git config branch.track1.merge)" +' -test_expect_success \ - 'checkout w/autosetupmerge=always sets up tracking' ' +test_expect_success 'checkout w/autosetupmerge=always sets up tracking' ' test_when_finished git config branch.autosetupmerge false && git config branch.autosetupmerge always && git checkout master && git checkout -b track2 && test "$(git config branch.track2.remote)" && - test "$(git config branch.track2.merge)"' + test "$(git config branch.track2.merge)" +' test_expect_success 'checkout w/--track from non-branch HEAD fails' ' git checkout master^0 &&
@@ -435,8 +435,7 @@ test_expect_success 'detach a symbolic link HEAD' ' test "z$(git rev-parse --verify refs/heads/master)" = "z$here" ' -test_expect_success \ - 'checkout with --track fakes a sensible -b <name>' ' +test_expect_success 'checkout with --track fakes a sensible -b <name>' ' git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" && git update-ref refs/remotes/origin/koala/bear renamer &&
@@ -457,9 +456,9 @@ test_expect_success \ test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" ' -test_expect_success \ - 'checkout with --track, but without -b, fails with too short tracked name' ' - test_must_fail git checkout --track renamer' +test_expect_success 'checkout with --track, but without -b, fails with too short tracked name' ' + test_must_fail git checkout --track renamer +' setup_conflicting_index () { rm -f .git/index &&
Signature · 1 line
2.29.0.rc1
PATCH v6 2/5 t7102,t7201: remove unnecessary blank spaces in test body
In reply to Charvi Mendirattat7102 and t7201 still follow the old style of having blank lines around test body, which is not consistence with our current practice.
Let's remove those unnecessary blank lines.
--- t/t7102-reset.sh | 9 --------- t/t7201-co.sh | 25 ------------------------- 2 files changed, 34 deletions(-)
t/t7102-reset.sh +0 -9
@@ -439,7 +439,6 @@ test_expect_success 'test --mixed <paths>' ' ' test_expect_success 'test resetting the index at give paths' ' - mkdir sub && >sub/file1 && >sub/file2 &&
@@ -452,7 +451,6 @@ test_expect_success 'test resetting the index at give paths' ' echo "$U" && test_must_fail git diff-index --cached --exit-code "$T" && test "$T" != "$U" - ' test_expect_success 'resetting an unmodified path is a no-op' '
@@ -490,7 +488,6 @@ test_expect_success 'resetting specific path that is unmerged' ' ' test_expect_success 'disambiguation (1)' ' - git reset --hard && >secondfile && git add secondfile &&
@@ -499,11 +496,9 @@ test_expect_success 'disambiguation (1)' ' test -z "$(git diff --cached --name-only)" && test -f secondfile && test_must_be_empty secondfile - ' test_expect_success 'disambiguation (2)' ' - git reset --hard && >secondfile && git add secondfile &&
@@ -511,11 +506,9 @@ test_expect_success 'disambiguation (2)' ' test_must_fail git reset secondfile && test -n "$(git diff --cached --name-only -- secondfile)" && test ! -f secondfile - ' test_expect_success 'disambiguation (3)' ' - git reset --hard && >secondfile && git add secondfile &&
@@ -524,11 +517,9 @@ test_expect_success 'disambiguation (3)' ' test_must_fail git diff --quiet && test -z "$(git diff --cached --name-only)" && test ! -f secondfile - ' test_expect_success 'disambiguation (4)' ' - git reset --hard && >secondfile && git add secondfile &&
t/t7201-co.sh +0 -25
@@ -33,7 +33,6 @@ fill () { test_expect_success setup ' - fill x y z > same && fill 1 2 3 4 5 6 7 8 >one && fill a b c d e >two &&
@@ -63,7 +62,6 @@ test_expect_success setup ' ' test_expect_success 'checkout from non-existing branch' ' - git checkout -b delete-me master && git update-ref -d --no-deref refs/heads/delete-me && test refs/heads/delete-me = "$(git symbolic-ref HEAD)" &&
@@ -72,7 +70,6 @@ test_expect_success 'checkout from non-existing branch' ' ' test_expect_success 'checkout with dirty tree without -m' ' - fill 0 1 2 3 4 5 6 7 8 >one && if git checkout side then
@@ -81,11 +78,9 @@ test_expect_success 'checkout with dirty tree without -m' ' else echo "happy - failed correctly" fi - ' test_expect_success 'checkout with unrelated dirty tree without -m' ' - git checkout -f master && fill 0 1 2 3 4 5 6 7 8 >same && cp same kept &&
@@ -96,7 +91,6 @@ test_expect_success 'checkout with unrelated dirty tree without -m' ' ' test_expect_success 'checkout -m with dirty tree' ' - git checkout -f master && git clean -f &&
@@ -121,7 +115,6 @@ test_expect_success 'checkout -m with dirty tree' ' ' test_expect_success 'checkout -m with dirty tree, renamed' ' - git checkout -f master && git clean -f && fill 1 2 3 4 5 7 8 >one &&
@@ -139,11 +132,9 @@ test_expect_success 'checkout -m with dirty tree, renamed' ' ! test -f one && git diff --cached >current && test_must_be_empty current - ' test_expect_success 'checkout -m with merge conflict' ' - git checkout -f master && git clean -f && fill 1 T 3 4 5 6 S 8 >one &&
@@ -166,7 +157,6 @@ test_expect_success 'checkout -m with merge conflict' ' ' test_expect_success 'format of merge conflict from checkout -m' ' - git checkout -f master && git clean -f && fill b d > two &&
@@ -190,7 +180,6 @@ test_expect_success 'format of merge conflict from checkout -m' ' ' test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' - git checkout -f master && git reset --hard && git clean -f && fill b d > two &&
@@ -216,7 +205,6 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' ' test_expect_success 'switch to another branch while carrying a deletion' ' - git checkout -f master && git reset --hard && git clean -f && git rm two &&
@@ -228,7 +216,6 @@ test_expect_success 'switch to another branch while carrying a deletion' ' ' test_expect_success 'checkout to detach HEAD (with advice declined)' ' - git config advice.detachedHead false && rev=$(git rev-parse --short renamer^) && git checkout -f renamer && git clean -f &&
@@ -267,7 +254,6 @@ test_expect_success 'checkout to detach HEAD' ' ' test_expect_success 'checkout to detach HEAD with branchname^' ' - git checkout -f master && git clean -f && git checkout renamer^ && H=$(git rev-parse --verify HEAD) &&
@@ -283,7 +269,6 @@ test_expect_success 'checkout to detach HEAD with branchname^' ' ' test_expect_success 'checkout to detach HEAD with :/message' ' - git checkout -f master && git clean -f && git checkout ":/Initial" && H=$(git rev-parse --verify HEAD) &&
@@ -299,7 +284,6 @@ test_expect_success 'checkout to detach HEAD with :/message' ' ' test_expect_success 'checkout to detach HEAD with HEAD^0' ' - git checkout -f master && git clean -f && git checkout HEAD^0 && H=$(git rev-parse --verify HEAD) &&
@@ -315,7 +299,6 @@ test_expect_success 'checkout to detach HEAD with HEAD^0' ' ' test_expect_success 'checkout with ambiguous tag/branch names' ' - git tag both side && git branch both master && git reset --hard &&
@@ -327,11 +310,9 @@ test_expect_success 'checkout with ambiguous tag/branch names' ' test "z$H" = "z$M" && name=$(git symbolic-ref HEAD 2>/dev/null) && test "z$name" = zrefs/heads/both - ' test_expect_success 'checkout with ambiguous tag/branch names' ' - git reset --hard && git checkout master &&
@@ -351,11 +332,9 @@ test_expect_success 'checkout with ambiguous tag/branch names' ' else : happy fi - ' test_expect_success 'switch branches while in subdirectory' ' - git reset --hard && git checkout master &&
@@ -366,11 +345,9 @@ test_expect_success 'switch branches while in subdirectory' ' ) && ! test -f subs/one && rm -fr subs - ' test_expect_success 'checkout specific path while in subdirectory' ' - git reset --hard && git checkout side && mkdir subs &&
@@ -385,7 +362,6 @@ test_expect_success 'checkout specific path while in subdirectory' ' git checkout side -- bero ) && test -f subs/bero - ' test_expect_success 'checkout w/--track sets up tracking' '
@@ -608,7 +584,6 @@ test_expect_success 'failing checkout -b should not break working tree' ' test $(git symbolic-ref HEAD) = refs/heads/master && git diff --exit-code && git diff --cached --exit-code - ' test_expect_success 'switch out of non-branch' '
Signature · 1 line
2.29.0.rc1
PATCH v6 3/5 t7102,t7201: remove whitespace after redirect operator
In reply to Charvi MendirattaAccording to Documentation/CodingGuidelines, redirect operator is written with space before, but no space after them.
Let's remove these whitespaces after redirect operators.
--- t/t7102-reset.sh | 32 ++++++++++++++++---------------- t/t7201-co.sh | 10 +++++----- 2 files changed, 21 insertions(+), 21 deletions(-)
t/t7102-reset.sh +16 -16
@@ -70,15 +70,15 @@ check_changes () { test_expect_success 'reset --hard message' ' hex=$(git log -1 --format="%h") && - git reset --hard > .actual && - echo HEAD is now at $hex $(commit_msg) > .expected && + git reset --hard >.actual && + echo HEAD is now at $hex $(commit_msg) >.expected && test_i18ncmp .expected .actual ' test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' ' hex=$(git log -1 --format="%h") && - git -c "i18n.logOutputEncoding=$test_encoding" reset --hard > .actual && - echo HEAD is now at $hex $(commit_msg $test_encoding) > .expected && + git -c "i18n.logOutputEncoding=$test_encoding" reset --hard >.actual && + echo HEAD is now at $hex $(commit_msg $test_encoding) >.expected && test_i18ncmp .expected .actual '
@@ -387,25 +387,25 @@ test_expect_success '--hard reset to ORIG_HEAD should clear a fast-forward merge ' test_expect_success 'test --mixed <paths>' ' - echo 1 > file1 && - echo 2 > file2 && + echo 1 >file1 && + echo 2 >file2 && git add file1 file2 && test_tick && git commit -m files && before1=$(git rev-parse --short HEAD:file1) && before2=$(git rev-parse --short HEAD:file2) && git rm file2 && - echo 3 > file3 && - echo 4 > file4 && - echo 5 > file1 && + echo 3 >file3 && + echo 4 >file4 && + echo 5 >file1 && after1=$(git rev-parse --short $(git hash-object file1)) && after4=$(git rev-parse --short $(git hash-object file4)) && git add file1 file3 file4 && git reset HEAD -- file1 file2 file3 && test_must_fail git diff --quiet && - git diff > output && + git diff >output && - cat > expect <<-EOF && + cat >expect <<-EOF && diff --git a/file1 b/file1 index $before1..$after1 100644 --- a/file1
@@ -423,9 +423,9 @@ test_expect_success 'test --mixed <paths>' ' EOF test_cmp expect output && - git diff --cached > output && + git diff --cached >output && - cat > cached_expect <<-EOF && + cat >cached_expect <<-EOF && diff --git a/file4 b/file4 new file mode 100644 index 0000000..$after4
@@ -460,14 +460,14 @@ test_expect_success 'resetting an unmodified path is a no-op' ' git diff-index --cached --exit-code HEAD ' -cat > expect << EOF +cat >expect <<EOF Unstaged changes after reset: M file2 EOF test_expect_success '--mixed refreshes the index' ' - echo 123 >> file2 && - git reset --mixed HEAD > output && + echo 123 >>file2 && + git reset --mixed HEAD >output && test_i18ncmp expect output '
t/t7201-co.sh +5 -5
@@ -33,7 +33,7 @@ fill () { test_expect_success setup ' - fill x y z > same && + fill x y z >same && fill 1 2 3 4 5 6 7 8 >one && fill a b c d e >two && git add same one two &&
@@ -55,7 +55,7 @@ test_expect_success setup ' git checkout -b simple master && rm -f one && - fill a c e > two && + fill a c e >two && git commit -a -m "Simple D one, M two" && git checkout master
@@ -95,7 +95,7 @@ test_expect_success 'checkout -m with dirty tree' ' git clean -f && fill 0 1 2 3 4 5 6 7 8 >one && - git checkout -m side > messages && + git checkout -m side >messages && test "$(git symbolic-ref HEAD)" = "refs/heads/side" &&
@@ -159,7 +159,7 @@ test_expect_success 'checkout -m with merge conflict' ' test_expect_success 'format of merge conflict from checkout -m' ' git checkout -f master && git clean -f && - fill b d > two && + fill b d >two && git checkout -m simple && git ls-files >current &&
@@ -182,7 +182,7 @@ test_expect_success 'format of merge conflict from checkout -m' ' test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' git checkout -f master && git reset --hard && git clean -f && - fill b d > two && + fill b d >two && git checkout --merge --conflict=diff3 simple && cat <<-EOF >expect &&
Signature · 1 line
2.29.0.rc1
PATCH v6 4/5 t7201: use 'git -C' to avoid subshell
In reply to Charvi Mendiratta--- t/t7201-co.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
t/t7201-co.sh +2 -8
@@ -339,10 +339,7 @@ test_expect_success 'switch branches while in subdirectory' ' git checkout master && mkdir subs && - ( - cd subs && - git checkout side - ) && + git -C subs checkout side && ! test -f subs/one && rm -fr subs '
@@ -357,10 +354,7 @@ test_expect_success 'checkout specific path while in subdirectory' ' git checkout master && mkdir -p subs && - ( - cd subs && - git checkout side -- bero - ) && + git -C subs checkout side -- bero && test -f subs/bero '
Signature · 1 line
2.29.0.rc1
PATCH v6 5/5 t7201: put each command on a separate line
In reply to Charvi MendirattaModern practice is to avoid multiple commands per line, and instead place each command on its own line.
--- t/t7201-co.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
t/t7201-co.sh +18 -8
@@ -157,7 +157,8 @@ test_expect_success 'checkout -m with merge conflict' ' ' test_expect_success 'format of merge conflict from checkout -m' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && fill b d >two && git checkout -m simple &&
@@ -180,7 +181,9 @@ test_expect_success 'format of merge conflict from checkout -m' ' ' test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' - git checkout -f master && git reset --hard && git clean -f && + git checkout -f master && + git reset --hard && + git clean -f && fill b d >two && git checkout --merge --conflict=diff3 simple &&
@@ -205,7 +208,9 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' ' test_expect_success 'switch to another branch while carrying a deletion' ' - git checkout -f master && git reset --hard && git clean -f && + git checkout -f master && + git reset --hard && + git clean -f && git rm two && test_must_fail git checkout simple 2>errs &&
@@ -218,7 +223,8 @@ test_expect_success 'switch to another branch while carrying a deletion' ' test_expect_success 'checkout to detach HEAD (with advice declined)' ' git config advice.detachedHead false && rev=$(git rev-parse --short renamer^) && - git checkout -f renamer && git clean -f && + git checkout -f renamer && + git clean -f && git checkout renamer^ 2>messages && test_i18ngrep "HEAD is now at $rev" messages && test_line_count = 1 messages &&
@@ -237,7 +243,8 @@ test_expect_success 'checkout to detach HEAD (with advice declined)' ' test_expect_success 'checkout to detach HEAD' ' git config advice.detachedHead true && rev=$(git rev-parse --short renamer^) && - git checkout -f renamer && git clean -f && + git checkout -f renamer && + git clean -f && GIT_TEST_GETTEXT_POISON=false git checkout renamer^ 2>messages && grep "HEAD is now at $rev" messages && test_line_count -gt 1 messages &&
@@ -254,7 +261,8 @@ test_expect_success 'checkout to detach HEAD' ' ' test_expect_success 'checkout to detach HEAD with branchname^' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout renamer^ && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&
@@ -269,7 +277,8 @@ test_expect_success 'checkout to detach HEAD with branchname^' ' ' test_expect_success 'checkout to detach HEAD with :/message' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout ":/Initial" && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&
@@ -284,7 +293,8 @@ test_expect_success 'checkout to detach HEAD with :/message' ' ' test_expect_success 'checkout to detach HEAD with HEAD^0' ' - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout HEAD^0 && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) &&
Signature · 1 line
2.29.0.rc1
Re: [PATCH v5 3/5][Outreachy] t7102,t7201: remove whitespace after redirect operator
In reply to Eric SunshineQuoted 24 lines · Eric Sunshine
Quoted 8 lines · Junio C Hamano
Subject: t7102: prepare expected output inside test_expect_* block
Signed-off-by Junio C Hamano <[email protected]>---
w/t/t7102-reset.sh renamed from c/t/t7102-reset.sh +0
-2@@ -82,15 +82,15 @@ test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' ' ->.diff_expect ->.cached_expectw/t/t7102-reset.sh test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' ' · line 87
Quoted 10 lines
w/t/t7102-reset.sh renamed from c/t/t7102-reset.sh +5
-4-cat >.cat_expect <<EOF -secondfile: -EOF - test_expect_success 'giving a non existing revision should fail' ' + >.diff_expect && + >.cached_expect && + cat >.cat_expect <<-\EOF && + secondfile: + EOFYou used <<-\EOF rather than plain <<
-EOFwhen possible. Good.(Might be worth mention in the commit message, but perhaps too minor?)
Quoted 8 lines
w/t/t7102-reset.sh test_expect_success 'resetting to HEAD with no changes should succeed and do not · line 195
Quoted 6 lines
w/t/t7102-reset.sh renamed from c/t/t7102-reset.sh +4
-0@@ -191,38 +191,38 @@ test_expect_success 'resetting to HEAD with no changes should succeed and do not test_expect_success '--soft reset only should show changes in diff --cached' ' + >.diff_expect && + cat >.cached_expect <<-EOF && + diff --git a/secondfile b/secondfile + index $head5p1s..$head5s 100644And used plain <<
-EOFwhen necessary. Fine.
Yup.
Let's declare victory with v5 plus this one as [patch 6/5], and move on.
We both know very well that through the microproject that it has been demonstrated that Charvi can now comfortably work with us in the review discussions.
Thanks, both.