Message ID | 361911817559104672d273e199221e8367e8d595.1596349986.git.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Attr fixes | expand |
"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes: > t6038 had a pair of tests that were expected to fail, but weren't > failing for the expected reason. Both were meant to do a merge that > could be done cleanly after renormalization, but were supposed to fail > for lack of renormalization. Unfortunately, both tests has staged > changes, and checkout -m would abort due to the presence of those staged > changes before even attempting a merge. > > Fix this first issue by utilizing git-restore instead of git-checkout, > so that the index is left alone and just the working directory gets the > changes we want. Nicely analysed. > However, there is a second issue with these tests. Technically, they > just wanted to verify that after renormalization, no conflicts would be > present. This could have been checked for by grepping for a lack of > conflict markers, but the test instead tried to compare the working > directory files to an expected result. Unfortunately, the setting of > "text=auto" without setting core.eol to any value meant that the content > of the file (in particular, the line endings) would be > platform-dependent and the tests could only pass on some platforms. OK. > Replace the existing comparison with a call to 'git diff --no-index > --ignore-cr-at-eol' to verify that the contents, other than possible > carriage returns in the file, match the expected results and in > particular that the file has no conflicts from the checkout -m > operation. Makes sense. Thanks. > Signed-off-by: Elijah Newren <newren@gmail.com> > --- > t/t6038-merge-text-auto.sh | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/t/t6038-merge-text-auto.sh b/t/t6038-merge-text-auto.sh > index 5e8d5fa50c..27cea15533 100755 > --- a/t/t6038-merge-text-auto.sh > +++ b/t/t6038-merge-text-auto.sh > @@ -168,9 +168,9 @@ test_expect_failure 'checkout -m after setting text=auto' ' > git rm -fr . && > rm -f .gitattributes && > git reset --hard initial && > - git checkout a -- . && > + git restore --source=a -- . && > git checkout -m b && > - compare_files expected file > + git diff --no-index --ignore-cr-at-eol expected file > ' > > test_expect_failure 'checkout -m addition of text=auto' ' > @@ -183,9 +183,9 @@ test_expect_failure 'checkout -m addition of text=auto' ' > git rm -fr . && > rm -f .gitattributes file && > git reset --hard initial && > - git checkout b -- . && > + git restore --source=b -- . && > git checkout -m a && > - compare_files expected file > + git diff --no-index --ignore-cr-at-eol expected file > ' > > test_expect_failure 'cherry-pick patch from after text=auto was added' '
On Sun, Aug 2, 2020 at 2:33 AM Elijah Newren via GitGitGadget <gitgitgadget@gmail.com> wrote: > t6038 had a pair of tests that were expected to fail, but weren't > failing for the expected reason. Both were meant to do a merge that > could be done cleanly after renormalization, but were supposed to fail > for lack of renormalization. Unfortunately, both tests has staged s/has/had/ ...or... s/has/have/ > changes, and checkout -m would abort due to the presence of those staged > changes before even attempting a merge. > > Fix this first issue by utilizing git-restore instead of git-checkout, > so that the index is left alone and just the working directory gets the > changes we want. > > However, there is a second issue with these tests. Technically, they > just wanted to verify that after renormalization, no conflicts would be > present. This could have been checked for by grepping for a lack of > conflict markers, but the test instead tried to compare the working > directory files to an expected result. Unfortunately, the setting of > "text=auto" without setting core.eol to any value meant that the content > of the file (in particular, the line endings) would be > platform-dependent and the tests could only pass on some platforms. > Replace the existing comparison with a call to 'git diff --no-index > --ignore-cr-at-eol' to verify that the contents, other than possible > carriage returns in the file, match the expected results and in > particular that the file has no conflicts from the checkout -m > operation. > > Signed-off-by: Elijah Newren <newren@gmail.com>
On Sun, Aug 2, 2020 at 12:11 PM Eric Sunshine <sunshine@sunshineco.com> wrote: > > On Sun, Aug 2, 2020 at 2:33 AM Elijah Newren via GitGitGadget > <gitgitgadget@gmail.com> wrote: > > t6038 had a pair of tests that were expected to fail, but weren't > > failing for the expected reason. Both were meant to do a merge that > > could be done cleanly after renormalization, but were supposed to fail > > for lack of renormalization. Unfortunately, both tests has staged > > s/has/had/ > ...or... > s/has/have/ Thanks, will fix in next reroll.
diff --git a/t/t6038-merge-text-auto.sh b/t/t6038-merge-text-auto.sh index 5e8d5fa50c..27cea15533 100755 --- a/t/t6038-merge-text-auto.sh +++ b/t/t6038-merge-text-auto.sh @@ -168,9 +168,9 @@ test_expect_failure 'checkout -m after setting text=auto' ' git rm -fr . && rm -f .gitattributes && git reset --hard initial && - git checkout a -- . && + git restore --source=a -- . && git checkout -m b && - compare_files expected file + git diff --no-index --ignore-cr-at-eol expected file ' test_expect_failure 'checkout -m addition of text=auto' ' @@ -183,9 +183,9 @@ test_expect_failure 'checkout -m addition of text=auto' ' git rm -fr . && rm -f .gitattributes file && git reset --hard initial && - git checkout b -- . && + git restore --source=b -- . && git checkout -m a && - compare_files expected file + git diff --no-index --ignore-cr-at-eol expected file ' test_expect_failure 'cherry-pick patch from after text=auto was added' '