t4041 (diff-submodule-option): minor cleanup
cover t4041 (diff-submodule-option): minor cleanup
Hi,
This is the result of one lazy afternoon.
Ram
Ramkumar Ramachandra (4):
t4041 (diff-submodule-option): parse digests sensibly t4041 (diff-submodule-option): rewrite add_file() routine t4041 (diff-submodule-option): modernize style t4041 (diff-submodule-option): change tense of test names
t/t4041-diff-submodule-option.sh | 484 +++++++++++++++++++------------------- 1 files changed, 240 insertions(+), 244 deletions(-)
Signature · 1 line
1.7.8.1.362.g5d6df.dirty
PATCH 1/4 t4041 (diff-submodule-option): parse digests sensibly
git rev-list --max-count=1 HEAD is a roundabout way of saying git rev-parse --verify HEAD; replace a bunch of instances of the former with the latter. Also, don't unnecessarily cut -c1-7 the rev-parse output when the --short option is available.
--- t/t4041-diff-submodule-option.sh | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-)
t/t4041-diff-submodule-option.sh +7 -7
@@ -21,7 +21,7 @@ add_file () { test_tick && git commit -m "Add $name" done >/dev/null - git rev-parse --verify HEAD | cut -c1-7 + git rev-parse --short --verify HEAD cd "$owd" } commit_file () {
@@ -33,7 +33,7 @@ test_create_repo sm1 && add_file . foo >/dev/null head1=$(add_file sm1 foo1 foo2) -fullhead1=$(cd sm1; git rev-list --max-count=1 $head1) +fullhead1=$(cd sm1; git rev-parse --verify $head1) test_expect_success 'added submodule' " git add sm1 &&
@@ -116,8 +116,8 @@ EOF test_cmp expected actual " -fullhead2=$(cd sm1; git rev-list --max-count=1 $head2) test_expect_success 'modified submodule(forward) --submodule=short' " +fullhead2=$(cd sm1; git rev-parse --verify $head2) git diff --submodule=short >actual && cat >expected <<-EOF && diff --git a/sm1 b/sm1
@@ -135,7 +135,7 @@ commit_file sm1 && head3=$( cd sm1 && git reset --hard HEAD~2 >/dev/null && - git rev-parse --verify HEAD | cut -c1-7 + git rev-parse --short --verify HEAD ) test_expect_success 'modified submodule(backward)' "
@@ -220,8 +220,8 @@ EOF rm -f sm1 && test_create_repo sm1 && head6=$(add_file sm1 foo6 foo7) -fullhead6=$(cd sm1; git rev-list --max-count=1 $head6) test_expect_success 'nonexistent commit' " +fullhead6=$(cd sm1; git rev-parse --verify $head6) git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && Submodule sm1 $head4...$head6 (commits not present)
@@ -318,8 +318,8 @@ EOF " (cd sm1; git commit -mchange foo6 >/dev/null) && -head8=$(cd sm1; git rev-parse --verify HEAD | cut -c1-7) && test_expect_success 'submodule is modified' " +head8=$(cd sm1; git rev-parse --short --verify HEAD) && git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && Submodule sm1 $head6..$head8:
@@ -461,7 +461,7 @@ EOF test_cmp expected actual " -fullhead7=$(cd sm2; git rev-list --max-count=1 $head7) +fullhead7=$(cd sm2; git rev-parse --verify $head7) test_expect_success 'given commit --submodule=short' " git diff-index -p --submodule=short HEAD^ >actual &&
Signature · 1 line
1.7.8.1.362.g5d6df.dirty
Re: [PATCH 1/4] t4041 (diff-submodule-option): parse digests sensibly
Quoted 24 lines · Ramkumar Ramachandra
git rev-list --max-count=1 HEADis a roundabout way of sayinggit rev-parse --verify HEAD; replace a bunch of instances of the former with the latter. Also, don't unnecessarilycut -c1-7the rev-parse output when the--shortoption is available.Signed-off-by Ramkumar Ramachandra <[email protected]>--- t/t4041-diff-submodule-option.sh | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-)t/t4041-diff-submodule-option.sh +1
-1@@ -21,7 +21,7 @@ add_file () { test_tick && git commit -m "Add $name" done >/dev/null - git rev-parse --verify HEAD | cut -c1-7 + git rev-parse --short --verify HEAD cd "$owd" } commit_file () {
t/t4041-diff-submodule-option.sh test_create_repo sm1 && · line 36
Quoted 5 lines
t/t4041-diff-submodule-option.sh +1
-1@@ -33,7 +33,7 @@ test_create_repo sm1 && add_file . foo >/dev/null head1=$(add_file sm1 foo1 foo2) -fullhead1=$(cd sm1; git rev-list --max-count=1 $head1) +fullhead1=$(cd sm1; git rev-parse --verify $head1)
That still is a roundabout way to say "git rev-parse --verify HEAD", no? Why feed a shortened one to get the expanded result when you know the full representation of HEAD is what you want?
Quoted 50 lines
t/t4041-diff-submodule-option.sh +5
-5test_expect_success 'added submodule' " git add sm1 &&@@ -116,8 +116,8 @@ EOF test_cmp expected actual " -fullhead2=$(cd sm1; git rev-list --max-count=1 $head2) test_expect_success 'modified submodule(forward) --submodule=short' " +fullhead2=$(cd sm1; git rev-parse --verify $head2) git diff --submodule=short >actual && cat >expected <<-EOF && diff --git a/sm1 b/sm1@@ -135,7 +135,7 @@ commit_file sm1 && head3=$( cd sm1 && git reset --hard HEAD~2 >/dev/null && - git rev-parse --verify HEAD | cut -c1-7 + git rev-parse --short --verify HEAD ) test_expect_success 'modified submodule(backward)' "@@ -220,8 +220,8 @@ EOF rm -f sm1 && test_create_repo sm1 && head6=$(add_file sm1 foo6 foo7) -fullhead6=$(cd sm1; git rev-list --max-count=1 $head6) test_expect_success 'nonexistent commit' " +fullhead6=$(cd sm1; git rev-parse --verify $head6) git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && Submodule sm1 $head4...$head6 (commits not present)@@ -318,8 +318,8 @@ EOF " (cd sm1; git commit -mchange foo6 >/dev/null) && -head8=$(cd sm1; git rev-parse --verify HEAD | cut -c1-7) && test_expect_success 'submodule is modified' " +head8=$(cd sm1; git rev-parse --short --verify HEAD) && git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && Submodule sm1 $head6..$head8:@@ -461,7 +461,7 @@ EOF test_cmp expected actual " -fullhead7=$(cd sm2; git rev-list --max-count=1 $head7) +fullhead7=$(cd sm2; git rev-parse --verify $head7) test_expect_success 'given commit --submodule=short' " git diff-index -p --submodule=short HEAD^ >actual &&
PATCH 2/4 t4041 (diff-submodule-option): rewrite add_file() routine
In reply to Ramkumar RamachandraInstead of "cd there and then come back", use the "cd there in a subshell" pattern. Also fix '&&' chaining in one place.
--- t/t4041-diff-submodule-option.sh | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-)
t/t4041-diff-submodule-option.sh +5 -8
@@ -11,18 +11,15 @@ This test tries to verify the sanity of the --submodule option of git diff. . ./test-lib.sh add_file () { - sm=$1 - shift - owd=$(pwd) - cd "$sm" - for name; do + (cd "$1" && + shift && + for name; do echo "$name" > "$name" && git add "$name" && test_tick && git commit -m "Add $name" - done >/dev/null - git rev-parse --short --verify HEAD - cd "$owd" + done >/dev/null && + git rev-parse --short --verify HEAD) } commit_file () { test_tick &&
Signature · 1 line
1.7.8.1.362.g5d6df.dirty
PATCH 3/4 t4041 (diff-submodule-option): modernize style
In reply to Ramkumar Ramachandra- Enclose tests in single quotes as opposed to double quotes. This is the prevalent style in other tests.
- Remove the unused variable $head4_full.
- Indent the expected output so that it lines up with the rest of the test text.
--- t/t4041-diff-submodule-option.sh | 459 +++++++++++++++++++------------------- 1 files changed, 229 insertions(+), 230 deletions(-)
t/t4041-diff-submodule-option.sh +229 -230
@@ -32,41 +32,41 @@ add_file . foo >/dev/null head1=$(add_file sm1 foo1 foo2) fullhead1=$(cd sm1; git rev-parse --verify $head1) -test_expect_success 'added submodule' " +test_expect_success 'added submodule' ' git add sm1 && git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 0000000...$head1 (new submodule) -EOF + Submodule sm1 0000000...$head1 (new submodule) + EOF test_cmp expected actual -" +' -test_expect_success 'added submodule, set diff.submodule' " +test_expect_success 'added submodule, set diff.submodule' ' git config diff.submodule log && git add sm1 && git diff --cached >actual && cat >expected <<-EOF && -Submodule sm1 0000000...$head1 (new submodule) -EOF + Submodule sm1 0000000...$head1 (new submodule) + EOF git config --unset diff.submodule && test_cmp expected actual -" +' -test_expect_success '--submodule=short overrides diff.submodule' " +test_expect_success '--submodule=short overrides diff.submodule' ' test_config diff.submodule log && git add sm1 && git diff --submodule=short --cached >actual && cat >expected <<-EOF && -diff --git a/sm1 b/sm1 -new file mode 160000 -index 0000000..$head1 ---- /dev/null -+++ b/sm1 -@@ -0,0 +1 @@ -+Subproject commit $fullhead1 -EOF + diff --git a/sm1 b/sm1 + new file mode 160000 + index 0000000..$head1 + --- /dev/null + +++ b/sm1 + @@ -0,0 +1 @@ + +Subproject commit $fullhead1 + EOF test_cmp expected actual -" +' test_expect_success 'diff.submodule does not affect plumbing' ' test_config diff.submodule log &&
@@ -86,47 +86,47 @@ test_expect_success 'diff.submodule does not affect plumbing' ' commit_file sm1 && head2=$(add_file sm1 foo3) -test_expect_success 'modified submodule(forward)' " +test_expect_success 'modified submodule(forward)' ' git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 $head1..$head2: - > Add foo3 -EOF + Submodule sm1 $head1..$head2: + > Add foo3 + EOF test_cmp expected actual -" +' -test_expect_success 'modified submodule(forward)' " +test_expect_success 'modified submodule(forward)' ' git diff --submodule=log >actual && cat >expected <<-EOF && -Submodule sm1 $head1..$head2: - > Add foo3 -EOF + Submodule sm1 $head1..$head2: + > Add foo3 + EOF test_cmp expected actual -" +' -test_expect_success 'modified submodule(forward) --submodule' " +test_expect_success 'modified submodule(forward) --submodule' ' git diff --submodule >actual && cat >expected <<-EOF && -Submodule sm1 $head1..$head2: - > Add foo3 -EOF + Submodule sm1 $head1..$head2: + > Add foo3 + EOF test_cmp expected actual -" +' -test_expect_success 'modified submodule(forward) --submodule=short' " fullhead2=$(cd sm1; git rev-parse --verify $head2) +test_expect_success 'modified submodule(forward) --submodule=short' ' git diff --submodule=short >actual && cat >expected <<-EOF && -diff --git a/sm1 b/sm1 -index $head1..$head2 160000 ---- a/sm1 -+++ b/sm1 -@@ -1 +1 @@ --Subproject commit $fullhead1 -+Subproject commit $fullhead2 -EOF + diff --git a/sm1 b/sm1 + index $head1..$head2 160000 + --- a/sm1 + +++ b/sm1 + @@ -1 +1 @@ + -Subproject commit $fullhead1 + +Subproject commit $fullhead2 + EOF test_cmp expected actual -" +' commit_file sm1 && head3=$(
@@ -135,29 +135,28 @@ head3=$( git rev-parse --short --verify HEAD ) -test_expect_success 'modified submodule(backward)' " +test_expect_success 'modified submodule(backward)' ' git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 $head2..$head3 (rewind): - < Add foo3 - < Add foo2 -EOF + Submodule sm1 $head2..$head3 (rewind): + < Add foo3 + < Add foo2 + EOF test_cmp expected actual -" +' -head4=$(add_file sm1 foo4 foo5) && -head4_full=$(GIT_DIR=sm1/.git git rev-parse --verify HEAD) -test_expect_success 'modified submodule(backward and forward)' " +head4=$(add_file sm1 foo4 foo5) +test_expect_success 'modified submodule(backward and forward)' ' git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 $head2...$head4: - > Add foo5 - > Add foo4 - < Add foo3 - < Add foo2 -EOF + Submodule sm1 $head2...$head4: + > Add foo5 + > Add foo4 + < Add foo3 + < Add foo2 + EOF test_cmp expected actual -" +' commit_file sm1 && mv sm1 sm1-bak &&
@@ -167,319 +166,319 @@ git add sm1 && rm -f sm1 && mv sm1-bak sm1 -test_expect_success 'typechanged submodule(submodule->blob), --cached' " +test_expect_success 'typechanged submodule(submodule->blob), --cached' ' git diff --submodule=log --cached >actual && cat >expected <<-EOF && -Submodule sm1 $head4...0000000 (submodule deleted) -diff --git a/sm1 b/sm1 -new file mode 100644 -index 0000000..$head5 ---- /dev/null -+++ b/sm1 -@@ -0,0 +1 @@ -+sm1 -EOF + Submodule sm1 $head4...0000000 (submodule deleted) + diff --git a/sm1 b/sm1 + new file mode 100644 + index 0000000..$head5 + --- /dev/null + +++ b/sm1 + @@ -0,0 +1 @@ + +sm1 + EOF test_cmp expected actual -" +' -test_expect_success 'typechanged submodule(submodule->blob)' " +test_expect_success 'typechanged submodule(submodule->blob)' ' git diff --submodule=log >actual && cat >expected <<-EOF && -diff --git a/sm1 b/sm1 -deleted file mode 100644 -index $head5..0000000 ---- a/sm1 -+++ /dev/null -@@ -1 +0,0 @@ --sm1 -Submodule sm1 0000000...$head4 (new submodule) -EOF + diff --git a/sm1 b/sm1 + deleted file mode 100644 + index $head5..0000000 + --- a/sm1 + +++ /dev/null + @@ -1 +0,0 @@ + -sm1 + Submodule sm1 0000000...$head4 (new submodule) + EOF test_cmp expected actual -" +' rm -rf sm1 && git checkout-index sm1 -test_expect_success 'typechanged submodule(submodule->blob)' " +test_expect_success 'typechanged submodule(submodule->blob)' ' git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 $head4...0000000 (submodule deleted) -diff --git a/sm1 b/sm1 -new file mode 100644 -index 0000000..$head5 ---- /dev/null -+++ b/sm1 -@@ -0,0 +1 @@ -+sm1 -EOF + Submodule sm1 $head4...0000000 (submodule deleted) + diff --git a/sm1 b/sm1 + new file mode 100644 + index 0000000..$head5 + --- /dev/null + +++ b/sm1 + @@ -0,0 +1 @@ + +sm1 + EOF test_cmp expected actual -" +' rm -f sm1 && test_create_repo sm1 && head6=$(add_file sm1 foo6 foo7) -test_expect_success 'nonexistent commit' " fullhead6=$(cd sm1; git rev-parse --verify $head6) +test_expect_success 'nonexistent commit' ' git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 $head4...$head6 (commits not present) -EOF + Submodule sm1 $head4...$head6 (commits not present) + EOF test_cmp expected actual -" +' commit_file -test_expect_success 'typechanged submodule(blob->submodule)' " +test_expect_success 'typechanged submodule(blob->submodule)' ' git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && -diff --git a/sm1 b/sm1 -deleted file mode 100644 -index $head5..0000000 ---- a/sm1 -+++ /dev/null -@@ -1 +0,0 @@ --sm1 -Submodule sm1 0000000...$head6 (new submodule) -EOF + diff --git a/sm1 b/sm1 + deleted file mode 100644 + index $head5..0000000 + --- a/sm1 + +++ /dev/null + @@ -1 +0,0 @@ + -sm1 + Submodule sm1 0000000...$head6 (new submodule) + EOF test_cmp expected actual -" +' commit_file sm1 && -test_expect_success 'submodule is up to date' " +test_expect_success 'submodule is up to date' ' git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && -EOF + EOF test_cmp expected actual -" +' -test_expect_success 'submodule contains untracked content' " +test_expect_success 'submodule contains untracked content' ' echo new > sm1/new-file && git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 contains untracked content -EOF + Submodule sm1 contains untracked content + EOF test_cmp expected actual -" +' -test_expect_success 'submodule contains untracked content (untracked ignored)' " +test_expect_success 'submodule contains untracked content (untracked ignored)' ' git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual && ! test -s actual -" +' -test_expect_success 'submodule contains untracked content (dirty ignored)' " +test_expect_success 'submodule contains untracked content (dirty ignored)' ' git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual && ! test -s actual -" +' -test_expect_success 'submodule contains untracked content (all ignored)' " +test_expect_success 'submodule contains untracked content (all ignored)' ' git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual && ! test -s actual -" +' -test_expect_success 'submodule contains untracked and modifed content' " +test_expect_success 'submodule contains untracked and modifed content' ' echo new > sm1/foo6 && git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 contains untracked content -Submodule sm1 contains modified content -EOF + Submodule sm1 contains untracked content + Submodule sm1 contains modified content + EOF test_cmp expected actual -" +' -test_expect_success 'submodule contains untracked and modifed content (untracked ignored)' " +test_expect_success 'submodule contains untracked and modifed content (untracked ignored)' ' echo new > sm1/foo6 && git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 contains modified content -EOF + Submodule sm1 contains modified content + EOF test_cmp expected actual -" +' -test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' " +test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' ' echo new > sm1/foo6 && git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual && ! test -s actual -" +' -test_expect_success 'submodule contains untracked and modifed content (all ignored)' " +test_expect_success 'submodule contains untracked and modifed content (all ignored)' ' echo new > sm1/foo6 && git diff-index -p --ignore-submodules --submodule=log HEAD >actual && ! test -s actual -" +' -test_expect_success 'submodule contains modifed content' " +test_expect_success 'submodule contains modifed content' ' rm -f sm1/new-file && git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 contains modified content -EOF + Submodule sm1 contains modified content + EOF test_cmp expected actual -" +' (cd sm1; git commit -mchange foo6 >/dev/null) && -test_expect_success 'submodule is modified' " head8=$(cd sm1; git rev-parse --short --verify HEAD) && +test_expect_success 'submodule is modified' ' git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 $head6..$head8: - > change -EOF + Submodule sm1 $head6..$head8: + > change + EOF test_cmp expected actual -" +' -test_expect_success 'modified submodule contains untracked content' " +test_expect_success 'modified submodule contains untracked content' ' echo new > sm1/new-file && git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 contains untracked content -Submodule sm1 $head6..$head8: - > change -EOF + Submodule sm1 contains untracked content + Submodule sm1 $head6..$head8: + > change + EOF test_cmp expected actual -" +' -test_expect_success 'modified submodule contains untracked content (untracked ignored)' " +test_expect_success 'modified submodule contains untracked content (untracked ignored)' ' git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 $head6..$head8: - > change -EOF + Submodule sm1 $head6..$head8: + > change + EOF test_cmp expected actual -" +' -test_expect_success 'modified submodule contains untracked content (dirty ignored)' " +test_expect_success 'modified submodule contains untracked content (dirty ignored)' ' git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 $head6..$head8: - > change -EOF + Submodule sm1 $head6..$head8: + > change + EOF test_cmp expected actual -" +' -test_expect_success 'modified submodule contains untracked content (all ignored)' " +test_expect_success 'modified submodule contains untracked content (all ignored)' ' git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual && ! test -s actual -" +' -test_expect_success 'modified submodule contains untracked and modifed content' " +test_expect_success 'modified submodule contains untracked and modifed content' ' echo modification >> sm1/foo6 && git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 contains untracked content -Submodule sm1 contains modified content -Submodule sm1 $head6..$head8: - > change -EOF + Submodule sm1 contains untracked content + Submodule sm1 contains modified content + Submodule sm1 $head6..$head8: + > change + EOF test_cmp expected actual -" +' -test_expect_success 'modified submodule contains untracked and modifed content (untracked ignored)' " +test_expect_success 'modified submodule contains untracked and modifed content (untracked ignored)' ' echo modification >> sm1/foo6 && git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 contains modified content -Submodule sm1 $head6..$head8: - > change -EOF + Submodule sm1 contains modified content + Submodule sm1 $head6..$head8: + > change + EOF test_cmp expected actual -" +' -test_expect_success 'modified submodule contains untracked and modifed content (dirty ignored)' " +test_expect_success 'modified submodule contains untracked and modifed content (dirty ignored)' ' echo modification >> sm1/foo6 && git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 $head6..$head8: - > change -EOF + Submodule sm1 $head6..$head8: + > change + EOF test_cmp expected actual -" +' -test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' " +test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' ' echo modification >> sm1/foo6 && git diff-index -p --ignore-submodules --submodule=log HEAD >actual && ! test -s actual -" +' -test_expect_success 'modified submodule contains modifed content' " +test_expect_success 'modified submodule contains modifed content' ' rm -f sm1/new-file && git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 contains modified content -Submodule sm1 $head6..$head8: - > change -EOF + Submodule sm1 contains modified content + Submodule sm1 $head6..$head8: + > change + EOF test_cmp expected actual -" +' rm -rf sm1 -test_expect_success 'deleted submodule' " +test_expect_success 'deleted submodule' ' git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 $head6...0000000 (submodule deleted) -EOF + Submodule sm1 $head6...0000000 (submodule deleted) + EOF test_cmp expected actual -" +' test_create_repo sm2 && head7=$(add_file sm2 foo8 foo9) && git add sm2 -test_expect_success 'multiple submodules' " +test_expect_success 'multiple submodules' ' git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && -Submodule sm1 $head6...0000000 (submodule deleted) -Submodule sm2 0000000...$head7 (new submodule) -EOF + Submodule sm1 $head6...0000000 (submodule deleted) + Submodule sm2 0000000...$head7 (new submodule) + EOF test_cmp expected actual -" +' -test_expect_success 'path filter' " +test_expect_success 'path filter' ' git diff-index -p --submodule=log HEAD sm2 >actual && cat >expected <<-EOF && -Submodule sm2 0000000...$head7 (new submodule) -EOF + Submodule sm2 0000000...$head7 (new submodule) + EOF test_cmp expected actual -" +' commit_file sm2 -test_expect_success 'given commit' " +test_expect_success 'given commit' ' git diff-index -p --submodule=log HEAD^ >actual && cat >expected <<-EOF && -Submodule sm1 $head6...0000000 (submodule deleted) -Submodule sm2 0000000...$head7 (new submodule) -EOF + Submodule sm1 $head6...0000000 (submodule deleted) + Submodule sm2 0000000...$head7 (new submodule) + EOF test_cmp expected actual -" +' -test_expect_success 'given commit --submodule' " +test_expect_success 'given commit --submodule' ' git diff-index -p --submodule HEAD^ >actual && cat >expected <<-EOF && -Submodule sm1 $head6...0000000 (submodule deleted) -Submodule sm2 0000000...$head7 (new submodule) -EOF + Submodule sm1 $head6...0000000 (submodule deleted) + Submodule sm2 0000000...$head7 (new submodule) + EOF test_cmp expected actual -" +' fullhead7=$(cd sm2; git rev-parse --verify $head7) -test_expect_success 'given commit --submodule=short' " +test_expect_success 'given commit --submodule=short' ' git diff-index -p --submodule=short HEAD^ >actual && cat >expected <<-EOF && -diff --git a/sm1 b/sm1 -deleted file mode 160000 -index $head6..0000000 ---- a/sm1 -+++ /dev/null -@@ -1 +0,0 @@ --Subproject commit $fullhead6 -diff --git a/sm2 b/sm2 -new file mode 160000 -index 0000000..$head7 ---- /dev/null -+++ b/sm2 -@@ -0,0 +1 @@ -+Subproject commit $fullhead7 -EOF - test_cmp expected actual -" + diff --git a/sm1 b/sm1 + deleted file mode 160000 + index $head6..0000000 + --- a/sm1 + +++ /dev/null + @@ -1 +0,0 @@ + -Subproject commit $fullhead6 + diff --git a/sm2 b/sm2 + new file mode 160000 + index 0000000..$head7 + --- /dev/null + +++ b/sm2 + @@ -0,0 +1 @@ + +Subproject commit $fullhead7 + EOF + test_cmp expected actual +' test_expect_success 'setup .git file for sm2' ' (cd sm2 &&
@@ -491,9 +490,9 @@ test_expect_success 'setup .git file for sm2' ' test_expect_success 'diff --submodule with .git file' ' git diff --submodule HEAD^ >actual && cat >expected <<-EOF && -Submodule sm1 $head6...0000000 (submodule deleted) -Submodule sm2 0000000...$head7 (new submodule) -EOF + Submodule sm1 $head6...0000000 (submodule deleted) + Submodule sm2 0000000...$head7 (new submodule) + EOF test_cmp expected actual '
Signature · 1 line
1.7.8.1.362.g5d6df.dirty
PATCH 4/4 t4041 (diff-submodule-option): change tense of test names
In reply to Ramkumar RamachandraChange the tense of test names from past to present, as this is the prevalent style.
--- t/t4041-diff-submodule-option.sh | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-)
t/t4041-diff-submodule-option.sh +12 -12
@@ -32,7 +32,7 @@ add_file . foo >/dev/null head1=$(add_file sm1 foo1 foo2) fullhead1=$(cd sm1; git rev-parse --verify $head1) -test_expect_success 'added submodule' ' +test_expect_success 'add submodule' ' git add sm1 && git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF &&
@@ -41,7 +41,7 @@ test_expect_success 'added submodule' ' test_cmp expected actual ' -test_expect_success 'added submodule, set diff.submodule' ' +test_expect_success 'add submodule, set diff.submodule' ' git config diff.submodule log && git add sm1 && git diff --cached >actual &&
@@ -86,7 +86,7 @@ test_expect_success 'diff.submodule does not affect plumbing' ' commit_file sm1 && head2=$(add_file sm1 foo3) -test_expect_success 'modified submodule(forward)' ' +test_expect_success 'modify submodule(forward)' ' git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && Submodule sm1 $head1..$head2:
@@ -95,7 +95,7 @@ test_expect_success 'modified submodule(forward)' ' test_cmp expected actual ' -test_expect_success 'modified submodule(forward)' ' +test_expect_success 'modify submodule(forward)' ' git diff --submodule=log >actual && cat >expected <<-EOF && Submodule sm1 $head1..$head2:
@@ -104,7 +104,7 @@ test_expect_success 'modified submodule(forward)' ' test_cmp expected actual ' -test_expect_success 'modified submodule(forward) --submodule' ' +test_expect_success 'modify submodule(forward) --submodule' ' git diff --submodule >actual && cat >expected <<-EOF && Submodule sm1 $head1..$head2:
@@ -114,7 +114,7 @@ test_expect_success 'modified submodule(forward) --submodule' ' ' fullhead2=$(cd sm1; git rev-parse --verify $head2) -test_expect_success 'modified submodule(forward) --submodule=short' ' +test_expect_success 'modify submodule(forward) --submodule=short' ' git diff --submodule=short >actual && cat >expected <<-EOF && diff --git a/sm1 b/sm1
@@ -135,7 +135,7 @@ head3=$( git rev-parse --short --verify HEAD ) -test_expect_success 'modified submodule(backward)' ' +test_expect_success 'modify submodule(backward)' ' git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && Submodule sm1 $head2..$head3 (rewind):
@@ -146,7 +146,7 @@ test_expect_success 'modified submodule(backward)' ' ' head4=$(add_file sm1 foo4 foo5) -test_expect_success 'modified submodule(backward and forward)' ' +test_expect_success 'modify submodule(backward and forward)' ' git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && Submodule sm1 $head2...$head4:
@@ -166,7 +166,7 @@ git add sm1 && rm -f sm1 && mv sm1-bak sm1 -test_expect_success 'typechanged submodule(submodule->blob), --cached' ' +test_expect_success 'typechange submodule(submodule->blob), --cached' ' git diff --submodule=log --cached >actual && cat >expected <<-EOF && Submodule sm1 $head4...0000000 (submodule deleted)
@@ -181,7 +181,7 @@ test_expect_success 'typechanged submodule(submodule->blob), --cached' ' test_cmp expected actual ' -test_expect_success 'typechanged submodule(submodule->blob)' ' +test_expect_success 'typechange submodule(submodule->blob)' ' git diff --submodule=log >actual && cat >expected <<-EOF && diff --git a/sm1 b/sm1
@@ -198,7 +198,7 @@ test_expect_success 'typechanged submodule(submodule->blob)' ' rm -rf sm1 && git checkout-index sm1 -test_expect_success 'typechanged submodule(submodule->blob)' ' +test_expect_success 'typechange submodule(submodule->blob)' ' git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && Submodule sm1 $head4...0000000 (submodule deleted)
@@ -226,7 +226,7 @@ test_expect_success 'nonexistent commit' ' ' commit_file -test_expect_success 'typechanged submodule(blob->submodule)' ' +test_expect_success 'typechange submodule(blob->submodule)' ' git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && diff --git a/sm1 b/sm1
Signature · 1 line
1.7.8.1.362.g5d6df.dirty
Re: [PATCH 2/4] t4041 (diff-submodule-option): rewrite add_file() routine
In reply to Ramkumar RamachandraQuoted 16 lines · Ramkumar Ramachandra
Instead of "cd there and then come back", use the "cd there in a subshell" pattern. Also fix '&&' chaining in one place.
Suggested-by Junio C Hamano <[email protected]>Signed-off-by Ramkumar Ramachandra <[email protected]>--- t/t4041-diff-submodule-option.sh | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-)t/t4041-diff-submodule-option.sh +0
-0@@ -11,18 +11,15 @@ This test tries to verify the sanity of the --submodule option of git diff. . ./test-lib.sh
t/t4041-diff-submodule-option.sh This test tries to verify the sanity of the --submodule option of git diff. · line 22
Quoted 10 lines
t/t4041-diff-submodule-option.sh +5
-0add_file () { + (cd "$1" && + shift && + for name; do echo "$name" > "$name" && git add "$name" && test_tick && git commit -m "Add $name" + done >/dev/null && + git rev-parse --short --verify HEAD)
While at it, why not do the "indent with a single tab", and other style fixes? e.g.
(
cd "$1" &&
shift &&
for name
do
echo "$name" >"$name" &&
git add $name" &&
test_tick &&
git commit -m "Add $name" || exit
done >/dev/null &&
git rev-parse --short --verify HEAD
)The "|| exit" is needed to catch failures inside the loop (not that "git commit" there is likely to fail, so it is just for completeness).
Re: [PATCH 4/4] t4041 (diff-submodule-option): change tense of test names
In reply to Ramkumar RamachandraQuoted 5 lines · Ramkumar Ramachandra
Change the tense of test names from past to present, as this is the prevalent style.
Signed-off-by Ramkumar Ramachandra <[email protected]>---
I see most of them are not "past" but "past particle" used as if they are adjectives.
For example, I think this test
Quoted 1 line
-test_expect_success 'added submodule' '
tries to say "See what happens to an added submodule".
The same for the others.
Quoted 1 line
-test_expect_success 'modified submodule(forward)' '
"See what is shown for modified submodule."
Quoted 1 line
-test_expect_success 'typechanged
submodule(submodule->blob), --cached' '
"See what is shown for typechanged one, when --cached option is given".
So I do not think this patch is needed; the current wording looks not so grammatically kosher, but still is understandable. Updated result isn't.