Re: [PATCH 2/6] t3433: remove loops from tests
- From
Elijah Newren <newren@gmail.com>
- Date
- Apr 7, 2020, 14:30 UTC
- Message-ID
- <CABPp-BENw_tdukSEix+0EyjYbh4-jxyN9GYqHbuHNVaK9ax36Q@mail.gmail.com>
- In-Reply-To
- <20200407141125.30872-3-phillip.wood123@gmail.com>
On Tue, Apr 7, 2020 at 7:11 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
Show 7 quoted lines
> > From: Phillip Wood <phillip.wood@dunelm.org.uk> > > Looping inside a test is asking for trouble as we only detect any > failure on the last iteration. Instead get all the dates at once which > is also more efficient. Note the previous code accidentally compared the > diffs as well as the dates this is fixed as well.
Add a semicolon between "dates" and "this" in the last sentence?
Show 40 quoted lines
> > Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> > --- > t/t3433-rebase-options-compatibility.sh | 18 +++++------------- > 1 file changed, 5 insertions(+), 13 deletions(-) > > diff --git a/t/t3433-rebase-options-compatibility.sh b/t/t3433-rebase-options-compatibility.sh > index 5166f158dd..2b4d75f1ef 100755 > --- a/t/t3433-rebase-options-compatibility.sh > +++ b/t/t3433-rebase-options-compatibility.sh > @@ -90,13 +90,9 @@ test_expect_success '--committer-date-is-author-date works with rebase -r' ' > git checkout side && > git merge --no-ff commit3 && > git rebase -r --root --committer-date-is-author-date && > - git rev-list HEAD >rev_list && > - while read HASH > - do > - git show $HASH --pretty="format:%ai" >authortime > - git show $HASH --pretty="format:%ci" >committertime > - test_cmp authortime committertime > - done <rev_list > + git log --pretty="format:%ai" >authortime && > + git log --pretty="format:%ci" >committertime && > + test_cmp authortime committertime > ' > > # Checking for +0000 in author time is enough since default > @@ -120,12 +116,8 @@ test_expect_success '--ignore-date works with rebase -r' ' > git checkout side && > git merge --no-ff commit3 && > git rebase -r --root --ignore-date && > - git rev-list HEAD >rev_list && > - while read HASH > - do > - git show $HASH --pretty="format:%ai" >authortime > - grep "+0000" authortime > - done <rev_list > + git log --pretty=%ai >authortime && > + ! grep -v "+0000" authortime > '
The new form is much more readable (and more correct and efficient, as you point out). Thanks.