Message ID | patch-v2-6.8-5715ff7f0f7-20221202T000227Z-avarab@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | tests: fix ignored & hidden exit codes | expand |
Am 02.12.2022 um 01:06 schrieb Ævar Arnfjörð Bjarmason: > Change the verify_mergeheads() helper the check the exit code of "git > rev-parse". The "$rest" variable added in 274a5c06d52 (merge: record > tag objects without peeling in MERGE_HEAD, 2011-11-07) wasn't being > used. > > Such a thing is needed to support the .git/MERGE_HEAD format in > general, but in this case we have no such addition to the line. So > let's compare with "test_cmp" instead, we can always add back this > "$rest" parsing if it's needed in the future. > > Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> > --- > t/t7600-merge.sh | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh > index 7c3f6ed9943..f5c4cbae9c8 100755 > --- a/t/t7600-merge.sh > +++ b/t/t7600-merge.sh > @@ -102,12 +102,11 @@ verify_parents () { > } > > verify_mergeheads () { > - test_write_lines "$@" >mergehead.expected && > - while read sha1 rest > + for rev in "$@" > do > - git rev-parse $sha1 > - done <.git/MERGE_HEAD >mergehead.actual && > - test_cmp mergehead.expected mergehead.actual > + git rev-parse $rev || return 1 > + done >mergehead.expected && > + test_cmp mergehead.expected .git/MERGE_HEAD Why all these changes and not just add "|| return 1"? > } > > verify_no_mergehead () {
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index 7c3f6ed9943..f5c4cbae9c8 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -102,12 +102,11 @@ verify_parents () { } verify_mergeheads () { - test_write_lines "$@" >mergehead.expected && - while read sha1 rest + for rev in "$@" do - git rev-parse $sha1 - done <.git/MERGE_HEAD >mergehead.actual && - test_cmp mergehead.expected mergehead.actual + git rev-parse $rev || return 1 + done >mergehead.expected && + test_cmp mergehead.expected .git/MERGE_HEAD } verify_no_mergehead () {
Change the verify_mergeheads() helper the check the exit code of "git rev-parse". The "$rest" variable added in 274a5c06d52 (merge: record tag objects without peeling in MERGE_HEAD, 2011-11-07) wasn't being used. Such a thing is needed to support the .git/MERGE_HEAD format in general, but in this case we have no such addition to the line. So let's compare with "test_cmp" instead, we can always add back this "$rest" parsing if it's needed in the future. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- t/t7600-merge.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)