diff mbox series

[RFC,1/5] t6006: simplify and optimize empty message test

Message ID 20190826235226.15386-2-newren@gmail.com (mailing list archive)
State New, archived
Headers show
Series Remove git-filter-branch from git.git; host it elsewhere | expand

Commit Message

Elijah Newren Aug. 26, 2019, 11:52 p.m. UTC
Test t6006.71 ("oneline with empty message") was creating two commits
with simple commit messages, and then running filter-branch to rewrite
the commit messages to be empty.  This test was written this way because
the --allow-empty-message option to git commit did not exist at the
time.  Simplify this test and avoid the need to invoke filter-branch by
just using --allow-empty-message when creating the commit.

Despite only being one piece of the 71st test and there being 73 tests
overall, this small change to just this one test speeds up the overall
execution time of t6006 (as measured by the best of 3 runs of `time
./t6006-rev-list-format.sh`) by about 11% on Linux and by 13% on
Mac.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 t/t6006-rev-list-format.sh | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Derrick Stolee Aug. 27, 2019, 1:23 a.m. UTC | #1
On 8/26/2019 7:52 PM, Elijah Newren wrote:
> Test t6006.71 ("oneline with empty message") was creating two commits
> with simple commit messages, and then running filter-branch to rewrite
> the commit messages to be empty.  This test was written this way because
> the --allow-empty-message option to git commit did not exist at the
> time.  Simplify this test and avoid the need to invoke filter-branch by
> just using --allow-empty-message when creating the commit.
> 
> Despite only being one piece of the 71st test and there being 73 tests
> overall, this small change to just this one test speeds up the overall
> execution time of t6006 (as measured by the best of 3 runs of `time
> ./t6006-rev-list-format.sh`) by about 11% on Linux and by 13% on
> Mac.

Wow! A good cleanup to include, regardless of other concerns.

> 
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
>  t/t6006-rev-list-format.sh | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
> index da113d975b..d30e41c9f7 100755
> --- a/t/t6006-rev-list-format.sh
> +++ b/t/t6006-rev-list-format.sh
> @@ -501,9 +501,8 @@ test_expect_success 'reflog identity' '
>  '
>  
>  test_expect_success 'oneline with empty message' '
> -	git commit -m "dummy" --allow-empty &&
> -	git commit -m "dummy" --allow-empty &&
> -	git filter-branch --msg-filter "sed -e s/dummy//" HEAD^^.. &&
> +	git commit --allow-empty --allow-empty-message &&
> +	git commit --allow-empty --allow-empty-message &&
>  	git rev-list --oneline HEAD >test.txt &&
>  	test_line_count = 5 test.txt &&
>  	git rev-list --oneline --graph HEAD >testg.txt &&

LGTM.

-Stolee
diff mbox series

Patch

diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index da113d975b..d30e41c9f7 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -501,9 +501,8 @@  test_expect_success 'reflog identity' '
 '
 
 test_expect_success 'oneline with empty message' '
-	git commit -m "dummy" --allow-empty &&
-	git commit -m "dummy" --allow-empty &&
-	git filter-branch --msg-filter "sed -e s/dummy//" HEAD^^.. &&
+	git commit --allow-empty --allow-empty-message &&
+	git commit --allow-empty --allow-empty-message &&
 	git rev-list --oneline HEAD >test.txt &&
 	test_line_count = 5 test.txt &&
 	git rev-list --oneline --graph HEAD >testg.txt &&