AFAIU, we avoid using `touch` unless we really do want to update the mtime. Here, we just want to create empty files, so write `>foo` instead. Signed-off-by: Martin Ågren <martin.agren@xxxxxxxxx> --- ...3-pre-commit-and-pre-merge-commit-hooks.sh | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/t/t7503-pre-commit-and-pre-merge-commit-hooks.sh b/t/t7503-pre-commit-and-pre-merge-commit-hooks.sh index 5cc6c98375..a6f1240aa2 100755 --- a/t/t7503-pre-commit-and-pre-merge-commit-hooks.sh +++ b/t/t7503-pre-commit-and-pre-merge-commit-hooks.sh @@ -43,7 +43,8 @@ test_expect_success 'root commit' ' test_expect_success 'with no hook' ' test_when_finished "rm -f expected_hooks actual_hooks" && - touch expected_hooks actual_hooks && + >expected_hooks && + >actual_hooks && echo "foo" >file && git add file && git commit -m "first" && @@ -52,7 +53,8 @@ test_expect_success 'with no hook' ' test_expect_success 'with no hook (merge)' ' test_when_finished "rm -f expected_hooks actual_hooks" && - touch expected_hooks actual_hooks && + >expected_hooks && + >actual_hooks && git checkout side && git merge -m "merge master" master && git checkout master && @@ -61,7 +63,8 @@ test_expect_success 'with no hook (merge)' ' test_expect_success '--no-verify with no hook' ' test_when_finished "rm -f expected_hooks actual_hooks" && - touch expected_hooks actual_hooks && + >expected_hooks && + >actual_hooks && echo "bar" >file && git add file && git commit --no-verify -m "bar" && @@ -70,7 +73,8 @@ test_expect_success '--no-verify with no hook' ' test_expect_success '--no-verify with no hook (merge)' ' test_when_finished "rm -f expected_hooks actual_hooks" && - touch expected_hooks actual_hooks && + >expected_hooks && + >actual_hooks && git checkout side && git merge --no-verify -m "merge master" master && git checkout master && @@ -80,7 +84,7 @@ test_expect_success '--no-verify with no hook (merge)' ' test_expect_success 'with succeeding hook' ' test_when_finished "rm -f \"$PRECOMMIT\" expected_hooks actual_hooks" && ln -s "success.sample" "$PRECOMMIT" && - touch actual_hooks && + >actual_hooks && echo "$PRECOMMIT" >expected_hooks && echo "more" >>file && git add file && @@ -91,7 +95,7 @@ test_expect_success 'with succeeding hook' ' test_expect_success 'with succeeding hook (merge)' ' test_when_finished "rm -f \"$PREMERGE\" expected_hooks actual_hooks" && ln -s "success.sample" "$PREMERGE" && - touch actual_hooks && + >actual_hooks && echo "$PREMERGE" >expected_hooks && git checkout side && git merge -m "merge master" master && @@ -102,7 +106,8 @@ test_expect_success 'with succeeding hook (merge)' ' test_expect_success '--no-verify with succeeding hook' ' test_when_finished "rm -f \"$PRECOMMIT\" expected_hooks actual_hooks" && ln -s "success.sample" "$PRECOMMIT" && - touch expected_hooks actual_hooks && + >expected_hooks && + >actual_hooks && echo "even more" >>file && git add file && git commit --no-verify -m "even more" && @@ -112,7 +117,8 @@ test_expect_success '--no-verify with succeeding hook' ' test_expect_success '--no-verify with succeeding hook (merge)' ' test_when_finished "rm -f \"$PREMERGE\" expected_hooks actual_hooks" && ln -s "success.sample" "$PREMERGE" && - touch expected_hooks actual_hooks && + >expected_hooks && + >actual_hooks && git checkout side && git merge --no-verify -m "merge master" master && git checkout master && @@ -122,7 +128,7 @@ test_expect_success '--no-verify with succeeding hook (merge)' ' test_expect_success 'with failing hook' ' test_when_finished "rm -f \"$PRECOMMIT\" expected_hooks actual_hooks" && ln -s "fail.sample" "$PRECOMMIT" && - touch actual_hooks && + >actual_hooks && echo "$PRECOMMIT" >expected_hooks && echo "another" >>file && git add file && @@ -133,7 +139,8 @@ test_expect_success 'with failing hook' ' test_expect_success '--no-verify with failing hook' ' test_when_finished "rm -f \"$PRECOMMIT\" expected_hooks actual_hooks" && ln -s "fail.sample" "$PRECOMMIT" && - touch expected_hooks actual_hooks && + >expected_hooks && + >actual_hooks && echo "stuff" >>file && git add file && git commit --no-verify -m "stuff" && @@ -143,7 +150,7 @@ test_expect_success '--no-verify with failing hook' ' test_expect_success 'with failing hook (merge)' ' test_when_finished "rm -f \"$PREMERGE\" expected_hooks actual_hooks" && ln -s "fail.sample" "$PREMERGE" && - touch actual_hooks && + >actual_hooks && echo "$PREMERGE" >expected_hooks && git checkout side && test_must_fail git merge -m "merge master" master && @@ -154,7 +161,8 @@ test_expect_success 'with failing hook (merge)' ' test_expect_success '--no-verify with failing hook (merge)' ' test_when_finished "rm -f \"$PREMERGE\" expected_hooks actual_hooks" && ln -s "fail.sample" "$PREMERGE" && - touch expected_hooks actual_hooks && + >expected_hooks && + >actual_hooks && git checkout side && git merge --no-verify -m "merge master" master && git checkout master && @@ -165,7 +173,8 @@ test_expect_success POSIXPERM 'with non-executable hook' ' test_when_finished "rm -f \"$PRECOMMIT\" expected_hooks actual_hooks && chmod +x \"$HOOKDIR/fail.sample\"" && ln -s "fail.sample" "$PRECOMMIT" && chmod -x "$HOOKDIR/fail.sample" && - touch expected_hooks actual_hooks && + >expected_hooks && + >actual_hooks && echo "content" >>file && git add file && git commit -m "content" && @@ -176,7 +185,8 @@ test_expect_success POSIXPERM '--no-verify with non-executable hook' ' test_when_finished "rm -f \"$PRECOMMIT\" expected_hooks actual_hooks && chmod +x \"$HOOKDIR/fail.sample\"" && ln -s "fail.sample" "$PRECOMMIT" && chmod -x "$HOOKDIR/fail.sample" && - touch expected_hooks actual_hooks && + >expected_hooks && + >actual_hooks && echo "more content" >>file && git add file && git commit --no-verify -m "more content" && -- 2.23.0.rc0.30.g51cf315870