Skip to contentSkip to conversation

t3420-rebase-autostash: don't try to grep non-existing files

PATCH In review SZEDER Gábor 4 participants 5 messages Oct 10, 2021 – Jun 28

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 t3420-rebase-autostash: don't try to grep non-existing files

Several tests in 't3420-rebase-autostash.sh' start various rebase processes that are expected to fail because of merge conflicts. The tests [1] checking that 'git rebase --quit' and autostash work together as expected after such a failure then run '! grep ...' to ensure that the dirty contents of the file is gone. However, due to the test repo's history and the choice of upstream branch that file shouldn't exist in the conflicted state at all, and thus it shouldn't exist after the subsequent 'git rebase --quit' either. Consequently, this 'grep' doesn't fail as expected, i.e. because it can't find the dirty content, but instead it fails, because it can't open the file.

Thighten this check by using 'test_path_is_missing' instead, thereby avoiding unexpected errors from 'grep' as well.

Previously 2745817028 (t3420-rebase-autostash: don't try to grep non-existing files, 2018-08-22) fixed a couple of similar issues; this one was added later in 9b2df3e8d0 (rebase: save autostash entry into stash reflog on --quit, 2020-04-28).

[1] This patch modifies only a single test, but that test is run several times with different strategies ('--apply', '--merge', and '--interactive'), hence the plural "tests".

---
 t/t3420-rebase-autostash.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
t/t3420-rebase-autostash.sh +1 -1
index 43fcb68f27..bbe82d2c0c 100755
@@ -200,7 +200,7 @@ testrebase () {
 		git rebase --quit &&
 		test_when_finished git stash drop &&
 		test_path_is_missing $dotest/autostash &&
-		! grep dirty file3 &&
+		test_path_is_missing file3 &&
 		git stash show -p >actual &&
 		test_cmp expect actual &&
 		git reset --hard &&
Signature · 1 line
2.33.0.1279.g1a260bf8c2
#1 lore raw
Quoted 43 lines · SZEDER Gábor

Several tests in 't3420-rebase-autostash.sh' start various rebase processes that are expected to fail because of merge conflicts. The tests [1] checking that 'git rebase --quit' and autostash work together as expected after such a failure then run '! grep ...' to ensure that the dirty contents of the file is gone. However, due to the test repo's history and the choice of upstream branch that file shouldn't exist in the conflicted state at all, and thus it shouldn't exist after the subsequent 'git rebase --quit' either. Consequently, this 'grep' doesn't fail as expected, i.e. because it can't find the dirty content, but instead it fails, because it can't open the file.

Thighten this check by using 'test_path_is_missing' instead, thereby avoiding unexpected errors from 'grep' as well.

Previously 2745817028 (t3420-rebase-autostash: don't try to grep non-existing files, 2018-08-22) fixed a couple of similar issues; this one was added later in 9b2df3e8d0 (rebase: save autostash entry into stash reflog on --quit, 2020-04-28).

[1] This patch modifies only a single test, but that test is run several times with different strategies ('--apply', '--merge', and '--interactive'), hence the plural "tests".

---
 t/t3420-rebase-autostash.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
t/t3420-rebase-autostash.sh +1 -1
index 43fcb68f27..bbe82d2c0c 100755
@@ -200,7 +200,7 @@ testrebase () {
 		git rebase --quit &&
 		test_when_finished git stash drop &&
 		test_path_is_missing $dotest/autostash &&
-		! grep dirty file3 &&
+		test_path_is_missing file3 &&
 		git stash show -p >actual &&
 		test_cmp expect actual &&
 		git reset --hard &&
Signature · 1 line
2.33.0.1279.g1a260bf8c2

It appears that this patch might have fallen quite deep through the cracks... ;)

But the issue this patch is addressing is still there, and the patch still applies cleanly after almost 5 years.

#2 lore raw
Quoted 6 lines · SZEDER Gábor

t/t3420-rebase-autostash.sh testrebase () {

Quoted 5 lines · SZEDER Gábor
t/t3420-rebase-autostash.sh +0 -0
index 43fcb68f27..bbe82d2c0c 100755
@@ -200,7 +200,7 @@ testrebase () {

With an extra context line we see

		test_path_is_missing file3 &&>>   		git rebase --quit &&
Quoted 4 lines

t/t3420-rebase-autostash.sh testrebase () { · line 203

Quoted 4 lines
t/t3420-rebase-autostash.sh +1 -1
  		test_when_finished git stash drop &&
  		test_path_is_missing $dotest/autostash &&
-		! grep dirty file3 &&
+		test_path_is_missing file3 &&

and so it is quite clear that this change is correct

Thanks

Phillip

Quoted 12 lines
Quoted 5 lines
t/t3420-rebase-autostash.sh +0 -0
  		git stash show -p >actual &&
  		test_cmp expect actual &&
  		git reset --hard &&
Signature · 1 line
2.33.0.1279.g1a260bf8c2

It appears that this patch might have fallen quite deep through the cracks... ;)

But the issue this patch is addressing is still there, and the patch still applies cleanly after almost 5 years.

#3 lore raw
In reply to SZEDER Gábor
Quoted 12 lines · SZEDER Gábor
Quoted 11 lines · SZEDER Gábor

Several tests in 't3420-rebase-autostash.sh' start various rebase processes that are expected to fail because of merge conflicts. The tests [1] checking that 'git rebase --quit' and autostash work together as expected after such a failure then run '! grep ...' to ensure that the dirty contents of the file is gone. However, due to the test repo's history and the choice of upstream branch that file shouldn't exist in the conflicted state at all, and thus it shouldn't exist after the subsequent 'git rebase --quit' either. Consequently, this 'grep' doesn't fail as expected, i.e. because it can't find the dirty content, but instead it fails, because it can't open the file.

Quoted 2 lines
Quoted 2 lines

Thighten this check by using 'test_path_is_missing' instead, thereby avoiding unexpected errors from 'grep' as well.

Thighten -> Tighten

Signature · 1 line
Todd
#4 lore raw
In reply to SZEDER Gábor
Quoted 39 lines · SZEDER Gábor
Quoted 38 lines · SZEDER Gábor

Several tests in 't3420-rebase-autostash.sh' start various rebase processes that are expected to fail because of merge conflicts. The tests [1] checking that 'git rebase --quit' and autostash work together as expected after such a failure then run '! grep ...' to ensure that the dirty contents of the file is gone. However, due to the test repo's history and the choice of upstream branch that file shouldn't exist in the conflicted state at all, and thus it shouldn't exist after the subsequent 'git rebase --quit' either. Consequently, this 'grep' doesn't fail as expected, i.e. because it can't find the dirty content, but instead it fails, because it can't open the file.

Thighten this check by using 'test_path_is_missing' instead, thereby avoiding unexpected errors from 'grep' as well.

Previously 2745817028 (t3420-rebase-autostash: don't try to grep non-existing files, 2018-08-22) fixed a couple of similar issues; this one was added later in 9b2df3e8d0 (rebase: save autostash entry into stash reflog on --quit, 2020-04-28).

[1] This patch modifies only a single test, but that test is run several times with different strategies ('--apply', '--merge', and '--interactive'), hence the plural "tests".

---
 t/t3420-rebase-autostash.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
t/t3420-rebase-autostash.sh +1 -1
index 43fcb68f27..bbe82d2c0c 100755
@@ -200,7 +200,7 @@ testrebase () {
 		git rebase --quit &&
 		test_when_finished git stash drop &&
 		test_path_is_missing $dotest/autostash &&
-		! grep dirty file3 &&
+		test_path_is_missing file3 &&
Quoted 8 lines
Quoted 5 lines
t/t3420-rebase-autostash.sh +0 -0
 		git stash show -p >actual &&
 		test_cmp expect actual &&
 		git reset --hard &&
Signature · 1 line
2.33.0.1279.g1a260bf8c2

It appears that this patch might have fallen quite deep through the cracks... ;)

Yeah, that indeed seems to be the case. It is surprising that nobody even had any comment on it back then.

Quoted 2 lines

But the issue this patch is addressing is still there, and the patch still applies cleanly after almost 5 years.

Will take a look and queue. Thanks.