Improve tests for detached worktree in git-submodule
PATCH 1/1 Improve tests for detached worktree in git-submodule
--- t/t7409-submodule-detached-worktree.sh | 31 ++++++++++++++++++++++++------- 1 files changed, 24 insertions(+), 7 deletions(-)
t/t7409-submodule-detached-worktree.sh +24 -7
@@ -15,7 +15,11 @@ TEST_NO_CREATE_REPO=1 test_expect_success 'submodule on detached working tree' ' git init --bare remote && test_create_repo bundle1 && - (cd bundle1 && test_commit "shoot") && + ( + cd bundle1 && + test_commit "shoot" && + git rev-list --max-count=1 HEAD > "$TRASH_DIRECTORY/expect" + ) && mkdir home && ( cd home &&
@@ -23,14 +27,27 @@ test_expect_success 'submodule on detached working tree' ' git clone --bare ../remote .dotfiles && git submodule add ../bundle1 .vim/bundle/sogood && test_commit "sogood" && + ( + unset GIT_WORK_TREE GIT_DIR && + cd .vim/bundle/sogood && + git rev-list --max-count=1 HEAD > actual && + test_cmp actual "$TRASH_DIRECTORY/expect" + ) && git push origin master - ) && + ) mkdir home2 && ( cd home2 && - export GIT_WORK_TREE="$(pwd)" GIT_DIR="$(pwd)/.dotfiles" && git clone --bare ../remote .dotfiles && - git submodule update --init + export GIT_WORK_TREE="$(pwd)" GIT_DIR="$(pwd)/.dotfiles" && + git checkout master && + git submodule update --init && + ( + unset GIT_WORK_TREE GIT_DIR && + cd .vim/bundle/sogood && + git rev-list --max-count=1 HEAD > actual && + test_cmp actual "$TRASH_DIRECTORY/expect" + ) ) '
@@ -42,6 +59,7 @@ test_expect_success 'submodule on detached working pointed by core.worktree' ' git clone --bare ../remote "$GIT_DIR" && git config core.bare false && git config core.worktree .. && + git checkout master && git submodule add ../bundle1 .vim/bundle/dupe && test_commit "dupe" && git push origin master
@@ -52,9 +70,8 @@ test_expect_success 'submodule on detached working pointed by core.worktree' ' git config core.bare false && git config core.worktree .. && git pull && - git submodule update && - git submodule status && - test -d .vim/bundle/dupe + git submodule update --init && + test -e .vim/bundle/dupe/shoot.t ) '
Signature · 1 line
1.7.5.4
Quoted 3 lines · Daniel Graña
Subject: Re: [PATCH] Improve tests for detached worktree in git-submodule
Signed-off-by Daniel Graña <[email protected]>
The space between the subject and your S-o-b is an excellent place to explain the rationale for your commit.
How are we improving them? What cases or classes of failure does this catch that the original did not? It may be because I have not been following this topic closely, but reading the patch, I am not sure what the purpose is. Please make life easier for reviewers by telling us what to expect and why before we even get to the patch.
-Peff
PATCH 1/1 Improve tests for detached worktree in git-submodule
In reply to a message not in the archiveForwardning for the record as vger rejected my previous HTML email.
---------- Forwarded message ----------
From: Daniel Graña <[email protected]>
Date: Mon, Jul 30, 2012 at 2:04 PM
Subject: Re: [PATCH] Improve tests for detached worktree in git-submodule
To: Jeff King <[email protected]>
Cc: Junio C Hamano <[email protected]>, [email protected]
Hi Jeff,
I understand your complain and I must apologize for confusing you with Jens from this thread
http://thread.gmane.org/gmane.comp.version-control.git/201851
This patch is a follow up to that thread (that I fail to include as reply-to) and tries to address the issues noted by Junio and Jens there.
Quoted 18 lines · Jeff King
Quoted 4 lines · Daniel Graña
Subject: Re: [PATCH] Improve tests for detached worktree in git-submodule
Signed-off-by Daniel Graña <[email protected]>The space between the subject and your S-o-b is an excellent place to explain the rationale for your commit.
How are we improving them? What cases or classes of failure does this catch that the original did not? It may be because I have not been following this topic closely, but reading the patch, I am not sure what the purpose is. Please make life easier for reviewers by telling us what to expect and why before we even get to the patch.
-Peff
Quoted 10 lines · Daniel Graña
Signed-off-by Daniel Graña <[email protected]>--- t/t7409-submodule-detached-worktree.sh | 31 ++++++++++++++++++++++++------- 1 files changed, 24 insertions(+), 7 deletions(-)t/t7409-submodule-detached-worktree.sh +0
-0
t/t7409-submodule-detached-worktree.sh TEST_NO_CREATE_REPO=1 · line 21
Quoted 8 lines
t/t7409-submodule-detached-worktree.sh +4
-1@@ -15,7 +15,11 @@ TEST_NO_CREATE_REPO=1 test_expect_success 'submodule on detached working tree' ' git init --bare remote && test_create_repo bundle1 && - (cd bundle1 && test_commit "shoot") && + ( + cd bundle1 && + test_commit "shoot" && + git rev-list --max-count=1 HEAD > "$TRASH_DIRECTORY/expect"
Better written as
git rev-parse --verify HEAD >../expect
methinks.
t/t7409-submodule-detached-worktree.sh test_expect_success 'submodule on detached working tree' ' · line 34
Quoted 13 lines
t/t7409-submodule-detached-worktree.sh +6
-0+ ) && mkdir home && ( cd home &&@@ -23,14 +27,27 @@ test_expect_success 'submodule on detached working tree' ' git clone --bare ../remote .dotfiles && git submodule add ../bundle1 .vim/bundle/sogood && test_commit "sogood" && + ( + unset GIT_WORK_TREE GIT_DIR && + cd .vim/bundle/sogood && + git rev-list --max-count=1 HEAD > actual && + test_cmp actual "$TRASH_DIRECTORY/expect"
Likewise.
git rev-parse --verify HEAD >actual &&
test_cmp ../expect actualAs test_cmp turns into "diff -u", comparing expect against actual (instead of the other way around) shows the deviation in a more readable way when your test fails.
t/t7409-submodule-detached-worktree.sh test_expect_success 'submodule on detached working tree' ' · line 42
Quoted 11 lines
t/t7409-submodule-detached-worktree.sh +3
-3+ ) && git push origin master - ) && + ) mkdir home2 && ( cd home2 && - export GIT_WORK_TREE="$(pwd)" GIT_DIR="$(pwd)/.dotfiles" && git clone --bare ../remote .dotfiles && - git submodule update --init + export GIT_WORK_TREE="$(pwd)" GIT_DIR="$(pwd)/.dotfiles" &&
So you used to clone with the two environment variables in effect to create the .otfiles, but now you don't use them while cloning. That makes more sense to me, especially the .otfiles is created "bare".
t/t7409-submodule-detached-worktree.sh test_expect_success 'submodule on detached working tree' ' · line 43
Quoted 1 line
t/t7409-submodule-detached-worktree.sh +1
-0+ git checkout master &&
So you populate the newly created home2 working tree out of the .otfiles repository in it.
t/t7409-submodule-detached-worktree.sh test_expect_success 'submodule on detached working tree' ' · line 49
Quoted 6 lines
t/t7409-submodule-detached-worktree.sh +6
-0+ git submodule update --init && + ( + unset GIT_WORK_TREE GIT_DIR && + cd .vim/bundle/sogood && + git rev-list --max-count=1 HEAD > actual && + test_cmp actual "$TRASH_DIRECTORY/expect"
Likewise.
Quoted 13 lines
t/t7409-submodule-detached-worktree.sh +2
-0+ ) ) '@@ -42,6 +59,7 @@ test_expect_success 'submodule on detached working pointed by core.worktree' ' git clone --bare ../remote "$GIT_DIR" && git config core.bare false && git config core.worktree .. && + git checkout master && git submodule add ../bundle1 .vim/bundle/dupe && test_commit "dupe" && git push origin master
t/t7409-submodule-detached-worktree.sh test_expect_success 'submodule on detached working pointed by core.worktree' ' · line 74
Quoted 8 lines
t/t7409-submodule-detached-worktree.sh +2
-3@@ -52,9 +70,8 @@ test_expect_success 'submodule on detached working pointed by core.worktree' ' git config core.bare false && git config core.worktree .. && git pull && - git submodule update && - git submodule status && - test -d .vim/bundle/dupe + git submodule update --init && + test -e .vim/bundle/dupe/shoot.t
Is the "existence" the only thing you care about? That's not all that different from the old test that only checked the existence of the directory dupe, no?
Quoted 2 lines
t/t7409-submodule-detached-worktree.sh +0
-0) '
PATCH 1/1 Improve tests for detached worktree in git-submodule
* Check submodule is correctly initialized and updated after cloning .dotfiles
---
Remove $TRASH_DIRECTORY and "git rev-parse --verify HEAD" as suggested by Junio
t/t7409-submodule-detached-worktree.sh | 31 ++++++++++++++++++++++++------- 1 files changed, 24 insertions(+), 7 deletions(-)
t/t7409-submodule-detached-worktree.sh +24 -7
@@ -15,7 +15,11 @@ TEST_NO_CREATE_REPO=1 test_expect_success 'submodule on detached working tree' ' git init --bare remote && test_create_repo bundle1 && - (cd bundle1 && test_commit "shoot") && + ( + cd bundle1 && + test_commit "shoot" && + git rev-parse --verify HEAD > ../expect + ) && mkdir home && ( cd home &&
@@ -23,14 +27,27 @@ test_expect_success 'submodule on detached working tree' ' git clone --bare ../remote .dotfiles && git submodule add ../bundle1 .vim/bundle/sogood && test_commit "sogood" && + ( + unset GIT_WORK_TREE GIT_DIR && + cd .vim/bundle/sogood && + git rev-parse --verify HEAD > actual && + test_cmp ../../../../expect actual + ) && git push origin master - ) && + ) mkdir home2 && ( cd home2 && - export GIT_WORK_TREE="$(pwd)" GIT_DIR="$(pwd)/.dotfiles" && git clone --bare ../remote .dotfiles && - git submodule update --init + export GIT_WORK_TREE="$(pwd)" GIT_DIR="$(pwd)/.dotfiles" && + git checkout master && + git submodule update --init && + ( + unset GIT_WORK_TREE GIT_DIR && + cd .vim/bundle/sogood && + git rev-parse --verify HEAD > actual && + test_cmp ../../../../expect actual + ) ) '
@@ -42,6 +59,7 @@ test_expect_success 'submodule on detached working pointed by core.worktree' ' git clone --bare ../remote "$GIT_DIR" && git config core.bare false && git config core.worktree .. && + git checkout master && git submodule add ../bundle1 .vim/bundle/dupe && test_commit "dupe" && git push origin master
@@ -52,9 +70,8 @@ test_expect_success 'submodule on detached working pointed by core.worktree' ' git config core.bare false && git config core.worktree .. && git pull && - git submodule update && - git submodule status && - test -d .vim/bundle/dupe + git submodule update --init && + test -e .vim/bundle/dupe/shoot.t ) '
Signature · 1 line
1.7.5.4
Quoted 4 lines · Daniel Graña
* Check submodule is correctly initialized and updated after cloning .dotfiles
Signed-off-by Daniel Graña <[email protected]>---
Ignore this patch, I am sending another without extra space after standard output redirection.
Quoted 77 lines
Remove $TRASH_DIRECTORY and "git rev-parse --verify HEAD" as suggested by Junio
t/t7409-submodule-detached-worktree.sh | 31 ++++++++++++++++++++++++------- 1 files changed, 24 insertions(+), 7 deletions(-)t/t7409-submodule-detached-worktree.sh +24
-8@@ -15,7 +15,11 @@ TEST_NO_CREATE_REPO=1 test_expect_success 'submodule on detached working tree' ' git init --bare remote && test_create_repo bundle1 && - (cd bundle1 && test_commit "shoot") && + ( + cd bundle1 && + test_commit "shoot" && + git rev-parse --verify HEAD > ../expect + ) && mkdir home && ( cd home &&@@ -23,14 +27,27 @@ test_expect_success 'submodule on detached working tree' ' git clone --bare ../remote .dotfiles && git submodule add ../bundle1 .vim/bundle/sogood && test_commit "sogood" && + ( + unset GIT_WORK_TREE GIT_DIR && + cd .vim/bundle/sogood && + git rev-parse --verify HEAD > actual && + test_cmp ../../../../expect actual + ) && git push origin master - ) && + ) mkdir home2 && ( cd home2 && - export GIT_WORK_TREE="$(pwd)" GIT_DIR="$(pwd)/.dotfiles" && git clone --bare ../remote .dotfiles && - git submodule update --init + export GIT_WORK_TREE="$(pwd)" GIT_DIR="$(pwd)/.dotfiles" && + git checkout master && + git submodule update --init && + ( + unset GIT_WORK_TREE GIT_DIR && + cd .vim/bundle/sogood && + git rev-parse --verify HEAD > actual && + test_cmp ../../../../expect actual + ) ) '@@ -42,6 +59,7 @@ test_expect_success 'submodule on detached working pointed by core.worktree' ' git clone --bare ../remote "$GIT_DIR" && git config core.bare false && git config core.worktree .. && + git checkout master && git submodule add ../bundle1 .vim/bundle/dupe && test_commit "dupe" && git push origin master@@ -52,9 +70,8 @@ test_expect_success 'submodule on detached working pointed by core.worktree' ' git config core.bare false && git config core.worktree .. && git pull && - git submodule update && - git submodule status && - test -d .vim/bundle/dupe + git submodule update --init && + test -e .vim/bundle/dupe/shoot.t ) ' --1.7.5.4
Quoted 23 lines · Junio C Hamano
Quoted 10 lines · Daniel Graña
Signed-off-by Daniel Graña <[email protected]>--- t/t7409-submodule-detached-worktree.sh | 31 ++++++++++++++++++++++++------- 1 files changed, 24 insertions(+), 7 deletions(-)t/t7409-submodule-detached-worktree.sh +0
-0t/t7409-submodule-detached-worktree.sh TEST_NO_CREATE_REPO=1 · line 21
Quoted 8 lines
t/t7409-submodule-detached-worktree.sh +4
-1@@ -15,7 +15,11 @@ TEST_NO_CREATE_REPO=1 test_expect_success 'submodule on detached working tree' ' git init --bare remote && test_create_repo bundle1 && - (cd bundle1 && test_commit "shoot") && + ( + cd bundle1 && + test_commit "shoot" && + git rev-list --max-count=1 HEAD > "$TRASH_DIRECTORY/expect"Better written as
Quoted 3 lines
git rev-parse --verify HEAD >../expectmethinks.
You rule here,
is it still better than "git rev-parse --max-count=1 HEAD" seen in t7406-submodule.update.sh?
Quoted 17 lines
Quoted 6 lines
t/t7409-submodule-detached-worktree.sh +1
-0+ ) && mkdir home && ( cd home &&t/t7409-submodule-detached-worktree.sh test_expect_success 'submodule on detached working tree' ' · line 34
Quoted 8 lines
t/t7409-submodule-detached-worktree.sh +5
-0@@ -23,14 +27,27 @@ test_expect_success 'submodule on detached working tree' ' git clone --bare ../remote .dotfiles && git submodule add ../bundle1 .vim/bundle/sogood && test_commit "sogood" && + ( + unset GIT_WORK_TREE GIT_DIR && + cd .vim/bundle/sogood && + git rev-list --max-count=1 HEAD > actual && + test_cmp actual "$TRASH_DIRECTORY/expect"Likewise.
Quoted 2 lines
git rev-parse --verify HEAD >actual &&
test_cmp../expect actual
I tried to avoid the too many ".." usage, in that case it'd be:
test_cmp ../../../../expect actual
Quoted 4 lines
As
test_cmpturns into "diff -u", comparing expect against actual (instead of the other way around) shows the deviation in a more readable way when your test fails.
must agree, thanks.
Quoted 13 lines
t/t7409-submodule-detached-worktree.sh test_expect_success 'submodule on detached working tree' ' · line 42
Quoted 12 lines
t/t7409-submodule-detached-worktree.sh +3
-3+ ) && git push origin master - ) && + ) mkdir home2 && ( cd home2 && - export GIT_WORK_TREE="$(pwd)" GIT_DIR="$(pwd)/.dotfiles" && git clone --bare ../remote .dotfiles && - git submodule update --init + export GIT_WORK_TREE="$(pwd)" GIT_DIR="$(pwd)/.dotfiles" &&
Quoted 8 lines
So you used to clone with the two environment variables in effect to create the .otfiles, but now you don't use them while cloning. That makes more sense to me, especially the .otfiles is created "bare".
t/t7409-submodule-detached-worktree.sh test_expect_success 'submodule on detached working tree' ' · line 43
Quoted 1 line
t/t7409-submodule-detached-worktree.sh +1
-0+ git checkout master &&So you populate the newly created home2 working tree out of the .otfiles repository in it.
right, before it wasn't creating ~/.gitmodules and "git subodule update --init" wasn't taking effect.
Quoted 27 lines
t/t7409-submodule-detached-worktree.sh test_expect_success 'submodule on detached working tree' ' · line 49
Quoted 7 lines
t/t7409-submodule-detached-worktree.sh +6
-0+ git submodule update --init && + ( + unset GIT_WORK_TREE GIT_DIR && + cd .vim/bundle/sogood && + git rev-list --max-count=1 HEAD > actual && + test_cmp actual "$TRASH_DIRECTORY/expect"Likewise.
Quoted 17 lines
t/t7409-submodule-detached-worktree.sh +2
-1+ ) ) '@@ -42,6 +59,7 @@ test_expect_success 'submodule on detached working pointed by core.worktree' ' git clone --bare ../remote "$GIT_DIR" && git config core.bare false && git config core.worktree .. && + git checkout master && git submodule add ../bundle1 .vim/bundle/dupe && test_commit "dupe" && git push origin master@@ -52,9 +70,8 @@ test_expect_success 'submodule on detached working pointed by core.worktree' ' git config core.bare false && git config core.worktree .. && git pull && - git submodule update &&
Quoted 8 lines
t/t7409-submodule-detached-worktree.sh test_expect_success 'submodule on detached working pointed by core.worktree' ' · line 74
Quoted 4 lines
t/t7409-submodule-detached-worktree.sh +2
-2- git submodule status && - test -d .vim/bundle/dupe + git submodule update --init && + test -e .vim/bundle/dupe/shoot.tIs the "existence" the only thing you care about? That's not all that different from the old test that only checked the existence of the directory dupe, no?
Except the submodule wasn't updating but the directory still existed so test passed, now it check for a file that exists only if the submodule update works.
I check for file existence as a shortcut for checking for submodule revision and because I am not sure what else too check honestly.
the real purpose of this test is the use or "core.worktree" instead of GIT_WORK_TREE.
Quoted 24 lines · Daniel Graña
Quoted 23 lines · Junio C Hamano
Quoted 10 lines · Daniel Graña
Signed-off-by Daniel Graña <[email protected]>--- t/t7409-submodule-detached-worktree.sh | 31 ++++++++++++++++++++++++------- 1 files changed, 24 insertions(+), 7 deletions(-)t/t7409-submodule-detached-worktree.sh +0
-0t/t7409-submodule-detached-worktree.sh TEST_NO_CREATE_REPO=1 · line 21
Quoted 8 lines
t/t7409-submodule-detached-worktree.sh +4
-1@@ -15,7 +15,11 @@ TEST_NO_CREATE_REPO=1 test_expect_success 'submodule on detached working tree' ' git init --bare remote && test_create_repo bundle1 && - (cd bundle1 && test_commit "shoot") && + ( + cd bundle1 && + test_commit "shoot" && + git rev-list --max-count=1 HEAD > "$TRASH_DIRECTORY/expect"Better written as
Quoted 8 lines
Quoted 3 lines
git rev-parse --verify HEAD >../expectmethinks.
You rule here,
is it still better than "git rev-parse --max-count=1 HEAD" seen in
t7406-submodule.update.sh?
"git rev-parse --max-count=1 HEAD" will show "--max-count=1\n" followed by the value of HEAD, so if the expected result and the actual result were both prepared by that command, the comparison would succeed (as the irrelevant --max-count=1 line will appear in both output), but honestly, I do not think it makes any sense.
Who wrote that crap?
Quoted 18 lines
Quoted 18 lines
Quoted 7 lines
t/t7409-submodule-detached-worktree.sh +1
-0+ ) && mkdir home && ( cd home &&t/t7409-submodule-detached-worktree.sh test_expect_success 'submodule on detached working tree' ' · line 34
Quoted 8 lines
t/t7409-submodule-detached-worktree.sh +5
-0@@ -23,14 +27,27 @@ test_expect_success 'submodule on detached working tree' ' git clone --bare ../remote .dotfiles && git submodule add ../bundle1 .vim/bundle/sogood && test_commit "sogood" && + ( + unset GIT_WORK_TREE GIT_DIR && + cd .vim/bundle/sogood && + git rev-list --max-count=1 HEAD > actual && + test_cmp actual "$TRASH_DIRECTORY/expect"Likewise.
Quoted 6 lines
Quoted 2 lines
git rev-parse --verify HEAD >actual &&
test_cmp../expect actualI tried to avoid the too many ".." usage, in that case it'd be:
test_cmp ../../../../expect actual
"$TRASH_DIRECTORY/expect" is fine as well. Just drop the extra SP between the redirection '>' and the filename, and make sure the filename is inside double quotes for some versions of bash that issue an unnecessary warning.
Quoted 7 lines
Quoted 4 lines
t/t7409-submodule-detached-worktree.sh test_expect_success 'submodule on detached working tree' ' · line 35
Quoted 1 line
t/t7409-submodule-detached-worktree.sh +1
-0+ git checkout master &&So you populate the newly created home2 working tree out of the .otfiles repository in it.
right, before it wasn't creating ~/.gitmodules and "git subodule update --init" wasn't taking effect.
Good.
Quoted 7 lines
Quoted 3 lines
Is the "existence" the only thing you care about? That's not all that different from the old test that only checked the existence of the directory dupe, no?
Except the submodule wasn't updating but the directory still existed so test passed, now it check for a file that exists only if the submodule update works.
OK.
PATCH 1/1 Improve tests for detached worktree in git-submodule
* Check submodule is correctly initialized and updated after cloning .dotfiles
--- t/t7409-submodule-detached-worktree.sh | 31 ++++++++++++++++++++++++------- 1 files changed, 24 insertions(+), 7 deletions(-)
t/t7409-submodule-detached-worktree.sh +24 -7
@@ -15,7 +15,11 @@ TEST_NO_CREATE_REPO=1 test_expect_success 'submodule on detached working tree' ' git init --bare remote && test_create_repo bundle1 && - (cd bundle1 && test_commit "shoot") && + ( + cd bundle1 && + test_commit "shoot" && + git rev-parse --verify HEAD >../expect + ) && mkdir home && ( cd home &&
@@ -23,14 +27,27 @@ test_expect_success 'submodule on detached working tree' ' git clone --bare ../remote .dotfiles && git submodule add ../bundle1 .vim/bundle/sogood && test_commit "sogood" && + ( + unset GIT_WORK_TREE GIT_DIR && + cd .vim/bundle/sogood && + git rev-parse --verify HEAD >actual && + test_cmp ../../../../expect actual + ) && git push origin master - ) && + ) mkdir home2 && ( cd home2 && - export GIT_WORK_TREE="$(pwd)" GIT_DIR="$(pwd)/.dotfiles" && git clone --bare ../remote .dotfiles && - git submodule update --init + export GIT_WORK_TREE="$(pwd)" GIT_DIR="$(pwd)/.dotfiles" && + git checkout master && + git submodule update --init && + ( + unset GIT_WORK_TREE GIT_DIR && + cd .vim/bundle/sogood && + git rev-parse --verify HEAD >actual && + test_cmp ../../../../expect actual + ) ) '
@@ -42,6 +59,7 @@ test_expect_success 'submodule on detached working pointed by core.worktree' ' git clone --bare ../remote "$GIT_DIR" && git config core.bare false && git config core.worktree .. && + git checkout master && git submodule add ../bundle1 .vim/bundle/dupe && test_commit "dupe" && git push origin master
@@ -52,9 +70,8 @@ test_expect_success 'submodule on detached working pointed by core.worktree' ' git config core.bare false && git config core.worktree .. && git pull && - git submodule update && - git submodule status && - test -d .vim/bundle/dupe + git submodule update --init && + test -e .vim/bundle/dupe/shoot.t ) '
Signature · 1 line
1.7.5.4
Quoted 4 lines · Daniel Graña
* Check submodule is correctly initialized and updated after cloning .dotfiles
Signed-off-by Daniel Graña <[email protected]>---
Thanks.
t/t7409-submodule-detached-worktree.sh test_expect_success 'submodule on detached working tree' ' · line 37
Quoted 13 lines
t/t7409-submodule-detached-worktree.sh +7
-1@@ -23,14 +27,27 @@ test_expect_success 'submodule on detached working tree' ' git clone --bare ../remote .dotfiles && git submodule add ../bundle1 .vim/bundle/sogood && test_commit "sogood" && + ( + unset GIT_WORK_TREE GIT_DIR && + cd .vim/bundle/sogood && + git rev-parse --verify HEAD >actual && + test_cmp ../../../../expect actual + ) && git push origin master - ) && + )
I do not think you meant to break the && chain here on purpose. I'll queue with a minor fix-up here.
Quoted 37 lines
t/t7409-submodule-detached-worktree.sh +12
-5mkdir home2 && ( cd home2 && - export GIT_WORK_TREE="$(pwd)" GIT_DIR="$(pwd)/.dotfiles" && git clone --bare ../remote .dotfiles && - git submodule update --init + export GIT_WORK_TREE="$(pwd)" GIT_DIR="$(pwd)/.dotfiles" && + git checkout master && + git submodule update --init && + ( + unset GIT_WORK_TREE GIT_DIR && + cd .vim/bundle/sogood && + git rev-parse --verify HEAD >actual && + test_cmp ../../../../expect actual + ) ) '@@ -42,6 +59,7 @@ test_expect_success 'submodule on detached working pointed by core.worktree' ' git clone --bare ../remote "$GIT_DIR" && git config core.bare false && git config core.worktree .. && + git checkout master && git submodule add ../bundle1 .vim/bundle/dupe && test_commit "dupe" && git push origin master@@ -52,9 +70,8 @@ test_expect_success 'submodule on detached working pointed by core.worktree' ' git config core.bare false && git config core.worktree .. && git pull && - git submodule update && - git submodule status && - test -d .vim/bundle/dupe + git submodule update --init && + test -e .vim/bundle/dupe/shoot.t ) '
Quoted 9 lines · Junio C Hamano
Quoted 4 lines · Daniel Graña
* Check submodule is correctly initialized and updated after cloning .dotfiles
Signed-off-by Daniel Graña <[email protected]>---
Thanks.
Quoted 16 lines
t/t7409-submodule-detached-worktree.sh test_expect_success 'submodule on detached working tree' ' · line 37
Quoted 13 lines
t/t7409-submodule-detached-worktree.sh +7
-1@@ -23,14 +27,27 @@ test_expect_success 'submodule on detached working tree' ' git clone --bare ../remote .dotfiles && git submodule add ../bundle1 .vim/bundle/sogood && test_commit "sogood" && + ( + unset GIT_WORK_TREE GIT_DIR && + cd .vim/bundle/sogood && + git rev-parse --verify HEAD >actual && + test_cmp ../../../../expect actual + ) && git push origin master - ) && + )I do not think you meant to break the && chain here on purpose. I'll queue with a minor fix-up here.
great, thanks.
Quoted 38 lines
Quoted 38 lines
t/t7409-submodule-detached-worktree.sh +12
-5mkdir home2 && ( cd home2 && - export GIT_WORK_TREE="$(pwd)" GIT_DIR="$(pwd)/.dotfiles" && git clone --bare ../remote .dotfiles && - git submodule update --init + export GIT_WORK_TREE="$(pwd)" GIT_DIR="$(pwd)/.dotfiles" && + git checkout master && + git submodule update --init && + ( + unset GIT_WORK_TREE GIT_DIR && + cd .vim/bundle/sogood && + git rev-parse --verify HEAD >actual && + test_cmp ../../../../expect actual + ) ) '@@ -42,6 +59,7 @@ test_expect_success 'submodule on detached working pointed by core.worktree' ' git clone --bare ../remote "$GIT_DIR" && git config core.bare false && git config core.worktree .. && + git checkout master && git submodule add ../bundle1 .vim/bundle/dupe && test_commit "dupe" && git push origin master@@ -52,9 +70,8 @@ test_expect_success 'submodule on detached working pointed by core.worktree' ' git config core.bare false && git config core.worktree .. && git pull && - git submodule update && - git submodule status && - test -d .vim/bundle/dupe + git submodule update --init && + test -e .vim/bundle/dupe/shoot.t ) '
Quoted 10 lines · Junio C Hamano
Daniel Graña <[email protected]> writes:
...Quoted 2 lines
is it still better than "git rev-parse --max-count=1 HEAD" seen in
t7406-submodule.update.sh?"git rev-parse --max-count=1 HEAD" will show "--max-count=1\n" followed by the value of HEAD, so if the expected result and the actual result were both prepared by that command, the comparison would succeed (as the irrelevant --max-count=1 line will appear in both output), but honestly, I do not think it makes any sense.
Thanks for noticing; I'll queue this.
-- >8 --
Subject: [PATCH] t7406: fix misleading "rev-parse --max-count=1 HEAD"
The test happened to use "rev-parse --max-count=1 HEAD" consistently to prepare the expected output and the actual output, so the comparison between them gave us a correct success/failure because both output had irrelevant "--max-count=1" in it.
But that is not an excuse to keep it broken. Replace it a more meaningful construct "rev-parse --verify HEAD".
Noticed by Daniel Graña while working on his submodule tests.
--- t/t7406-submodule-update.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
t/t7406-submodule-update.sh +8 -8
@@ -305,7 +305,7 @@ test_expect_success 'submodule update continues after checkout error' ' git submodule init && git commit -am "new_submodule" && (cd submodule2 && - git rev-parse --max-count=1 HEAD > ../expect + git rev-parse --verify HEAD >../expect ) && (cd submodule && test_commit "update_submodule" file
@@ -322,7 +322,7 @@ test_expect_success 'submodule update continues after checkout error' ' git checkout HEAD^ && test_must_fail git submodule update && (cd submodule2 && - git rev-parse --max-count=1 HEAD > ../actual + git rev-parse --verify HEAD >../actual ) && test_cmp expect actual )
@@ -351,7 +351,7 @@ test_expect_success 'submodule update continues after recursive checkout error' test_commit "update_submodule_again_again" file ) && (cd submodule2 && - git rev-parse --max-count=1 HEAD > ../expect && + git rev-parse --verify HEAD >../expect && test_commit "update_submodule2_again" file ) && git add submodule &&
@@ -366,7 +366,7 @@ test_expect_success 'submodule update continues after recursive checkout error' ) && test_must_fail git submodule update --recursive && (cd submodule2 && - git rev-parse --max-count=1 HEAD > ../actual + git rev-parse --verify HEAD >../actual ) && test_cmp expect actual )
@@ -398,12 +398,12 @@ test_expect_success 'submodule update exit immediately in case of merge conflict ) && git checkout HEAD^ && (cd submodule2 && - git rev-parse --max-count=1 HEAD > ../expect + git rev-parse --verify HEAD >../expect ) && git config submodule.submodule.update merge && test_must_fail git submodule update && (cd submodule2 && - git rev-parse --max-count=1 HEAD > ../actual + git rev-parse --verify HEAD >../actual ) && test_cmp expect actual )
@@ -432,12 +432,12 @@ test_expect_success 'submodule update exit immediately after recursive rebase er ) && git checkout HEAD^ && (cd submodule2 && - git rev-parse --max-count=1 HEAD > ../expect + git rev-parse --verify HEAD >../expect ) && git config submodule.submodule.update rebase && test_must_fail git submodule update && (cd submodule2 && - git rev-parse --max-count=1 HEAD > ../actual + git rev-parse --verify HEAD >../actual ) && test_cmp expect actual )
Signature · 1 line
1.7.12.rc0.80.gb93a609