# [PATCH 0/2] Two tests for rr/fmt-merge-msg

7 messages from 2010-08-27 to 2010-08-28. Participants: Ramkumar Ramachandra, Jonathan Nieder.
Thread: https://gitlist.dev/t/24887

## Ramkumar Ramachandra, 2010-08-27 14:14

Subject: [PATCH 0/2] Two tests for rr/fmt-merge-msg
Message-ID: <1282918490-5190-1-git-send-email-artagnon@gmail.com>
URL: https://gitlist.dev/e/1282918490-5190-1-git-send-email-artagnon%40gmail.com

```
These tests exercise the feature in rr/fmt-merge-msg.

Ramkumar Ramachandra (2):
  t6200-fmt-merge-msg: Exercise 'merge.log' to configure shortlog
    length
  t6200-fmt-merge-msg: Exercise '--log' to configure shortlog length

 t/t6200-fmt-merge-msg.sh |  111 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 111 insertions(+), 0 deletions(-)

-- 
1.7.2.2.409.gdbb11.dirty

```

## Ramkumar Ramachandra, 2010-08-27 14:14

Subject: [PATCH 1/2] t6200-fmt-merge-msg: Exercise 'merge.log' to configure shortlog length
Message-ID: <1282918490-5190-2-git-send-email-artagnon@gmail.com>
URL: https://gitlist.dev/e/1282918490-5190-2-git-send-email-artagnon%40gmail.com
In-Reply-To: <1282918490-5190-1-git-send-email-artagnon@gmail.com>

```
Add a test to exercise the 'merge.log' configuration option of 'git
fmt-merge-msg'. It controls the number of shortlog entries to display
in merge commit messages.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 t/t6200-fmt-merge-msg.sh |   55 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh
index 71f6cad..750568e 100755
--- a/t/t6200-fmt-merge-msg.sh
+++ b/t/t6200-fmt-merge-msg.sh
@@ -129,6 +129,61 @@ test_expect_success '[merge] summary/log configuration' '
 	test_cmp expected actual2
 '
 
+test_expect_success 'configurable shortlog length: merge.log' '
+	cat >expected_a <<-EOF &&
+	Merge branch ${apos}left${apos}
+
+	* left: (5 commits)
+	  Left #5
+	  Left #4
+	  Left #3
+	  ...
+	EOF
+
+	git config merge.log 3 &&
+	test_might_fail git config --unset-all merge.summary &&
+
+	git checkout master &&
+	test_tick &&
+	git fetch . left &&
+
+	git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
+
+	test_might_fail git config --unset-all merge.log &&
+	git config merge.summary 3 &&
+
+	git checkout master &&
+	test_tick &&
+	git fetch . left &&
+
+	git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
+
+	echo "Merge branch ${apos}left${apos}" >expected_b &&
+
+	git config merge.log 0 &&
+	test_might_fail git config --unset-all merge.summary &&
+
+	git checkout master &&
+	test_tick &&
+	git fetch . left &&
+
+	git fmt-merge-msg <.git/FETCH_HEAD >actual3 &&
+
+	test_might_fail git config --unset-all merge.log &&
+	test_might_fail git config --unset-all merge.summary &&
+
+	git checkout master &&
+	test_tick &&
+	git fetch . left &&
+
+	git fmt-merge-msg <.git/FETCH_HEAD >actual4 &&
+
+	test_cmp expected_a actual1 &&
+	test_cmp expected_a actual2 &&
+	test_cmp expected_b actual3 &&
+	test_cmp expected_b actual4
+'
+
 test_expect_success 'fmt-merge-msg -m' '
 	echo "Sync with left" >expected &&
 	cat >expected.log <<-EOF &&
-- 
1.7.2.2.409.gdbb11.dirty

```

## Ramkumar Ramachandra, 2010-08-27 14:14

Subject: [PATCH 2/2] t6200-fmt-merge-msg: Exercise '--log' to configure shortlog length
Message-ID: <1282918490-5190-3-git-send-email-artagnon@gmail.com>
URL: https://gitlist.dev/e/1282918490-5190-3-git-send-email-artagnon%40gmail.com
In-Reply-To: <1282918490-5190-1-git-send-email-artagnon@gmail.com>

```
Add a test to exercise the '--log' command-line option of 'git
fmt-merge-msg'. It controls the number of shortlog entries to display
in merge commit messages.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 t/t6200-fmt-merge-msg.sh |   56 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh
index 750568e..b308c3b 100755
--- a/t/t6200-fmt-merge-msg.sh
+++ b/t/t6200-fmt-merge-msg.sh
@@ -184,6 +184,62 @@ test_expect_success 'configurable shortlog length: merge.log' '
 	test_cmp expected_b actual4
 '
 
+test_expect_success 'configurable shortlog length: --log' '
+	cat >expected1 <<-EOF &&
+	Merge branch ${apos}left${apos}
+
+	* left: (5 commits)
+	  Left #5
+	  Left #4
+	  Left #3
+	  ...
+	EOF
+
+	test_might_fail git config --unset-all merge.log &&
+	test_might_fail git config --unset-all merge.summary &&
+
+	git checkout master &&
+	test_tick &&
+	git fetch . left &&
+
+	git fmt-merge-msg --log=3 <.git/FETCH_HEAD >actual1 &&
+
+	cat >expected_b <<-EOF &&
+	Merge branch ${apos}left${apos}
+
+	* left:
+	  Left #5
+	  Left #4
+	  Left #3
+	  Common #2
+	  Common #1
+	EOF
+
+	test_might_fail git config --unset-all merge.log &&
+	test_might_fail git config --unset-all merge.summary &&
+
+	git checkout master &&
+	test_tick &&
+	git fetch . left &&
+
+	git fmt-merge-msg --log <.git/FETCH_HEAD >actual2 &&
+
+	echo "Merge branch ${apos}left${apos}" >expected_c &&
+
+	test_might_fail git config --unset-all merge.log &&
+	test_might_fail git config --unset-all merge.summary &&
+
+	git checkout master &&
+	test_tick &&
+	git fetch . left &&
+
+	git fmt-merge-msg --no-log <.git/FETCH_HEAD >actual3 &&
+
+	test_cmp expected_a actual1 &&
+	test_cmp expected_b actual2 &&
+	test_cmp expected_c actual3
+'
+
 test_expect_success 'fmt-merge-msg -m' '
 	echo "Sync with left" >expected &&
 	cat >expected.log <<-EOF &&
-- 
1.7.2.2.409.gdbb11.dirty

```

## Jonathan Nieder, 2010-08-28 02:00

Subject: Re: [PATCH 1/2] t6200-fmt-merge-msg: Exercise 'merge.log' to configure shortlog length
Message-ID: <20100828020018.GD2004@burratino>
URL: https://gitlist.dev/e/20100828020018.GD2004%40burratino
In-Reply-To: <1282918490-5190-2-git-send-email-artagnon@gmail.com>

```
Hi,

Ramkumar Ramachandra wrote:

> Add a test to exercise the 'merge.log' configuration option

Thanks!

> +test_expect_success 'configurable shortlog length: merge.log' '

I suspect this test would be easier to understand if split up (yes, I
know I'm guilty of the same in other tests from this file).

Maybe something like this?

	test_expect_success 'setup: clear [merge] configuration' '
		test_might_fail git config --unset-all merge.log &&
		test_might_fail git config --unset-all merge.summary
	'

	test_expect_success 'set up FETCH_HEAD' '
		git checkout master &&
		git fetch . left
	'

	test_expect_success 'merge.log=3 limits shortlog length' '
		test_might_fail git config --unset merge.log &&
		test_might_fail git config --unset merge.summary &&

		cat >expected <<-\EOF &&
		  Left #3
		  ...
		EOF
		git -c merge.log=3 fmt-merge-msg <.git/FETCH_HEAD >msg &&

		tail -n 2 msg >actual &&
		test_cmp expected actual
	'

	test_expect_success 'shortlog length defaults to 20' '
		[...]
	'

	test_expect_success 'merge.log=5 does not limit shortlog length' '
		[...]
	'

	test_expect_success 'merge.log=6 does not limit shortlog length' '
		[...]
	'

	test_expect_success 'merge.log=0 disables shortlog' '
		[...]
	'

	test_expect_success 'merge.log=-1 does something sane' '
		[...]
	'

I can clean up the earlier tests afterwards. :)
Jonathan

```

## Jonathan Nieder, 2010-08-28 02:05

Subject: Re: [PATCH 1/2] t6200-fmt-merge-msg: Exercise 'merge.log' to configure shortlog length
Message-ID: <20100828020512.GE2004@burratino>
URL: https://gitlist.dev/e/20100828020512.GE2004%40burratino
In-Reply-To: <20100828020018.GD2004@burratino>

```
Jonathan Nieder wrote:

> Maybe something like this?
> 
> 	test_expect_success 'setup: clear [merge] configuration' '
> 		test_might_fail git config --unset-all merge.log &&
> 		test_might_fail git config --unset-all merge.summary
> 	'
> 
> 	test_expect_success 'set up FETCH_HEAD' '
> 		git checkout master &&
> 		git fetch . left
> 	'
> 
> 	test_expect_success 'merge.log=3 limits shortlog length' '
> 		test_might_fail git config --unset merge.log &&
> 		test_might_fail git config --unset merge.summary &&

Erm, these two lines wouldn't be necessary given the earlier setup,
of course.
> 
> 		cat >expected <<-\EOF &&
> 		  Left #3
> 		  ...
> 		EOF
> 		git -c merge.log=3 fmt-merge-msg <.git/FETCH_HEAD >msg &&
> 
> 		tail -n 2 msg >actual &&
> 		test_cmp expected actual
> 	'

Sorry for the noise.

*goes off to sleep*

```

## Ramkumar Ramachandra, 2010-08-28 10:35

Subject: Re: [PATCH 1/2] t6200-fmt-merge-msg: Exercise 'merge.log' to configure shortlog length
Message-ID: <20100828103536.GA12205@kytes>
URL: https://gitlist.dev/e/20100828103536.GA12205%40kytes
In-Reply-To: <20100828020018.GD2004@burratino>

```
Hi Jonathan,

Jonathan Nieder writes:
> I suspect this test would be easier to understand if split up (yes, I
> know I'm guilty of the same in other tests from this file).

I sort of tried to follow what was done in the rest of the file. If
this style is desired instead, I'll post an alternative series
instead.

> 	test_expect_success 'setup: clear [merge] configuration' '
> 		test_might_fail git config --unset-all merge.log &&
> 		test_might_fail git config --unset-all merge.summary
> 	'
> 
> 	test_expect_success 'set up FETCH_HEAD' '
> 		git checkout master &&
> 		git fetch . left
> 	'

Okay.

> 	test_expect_success 'merge.log=3 limits shortlog length' '
> 		test_might_fail git config --unset merge.log &&
> 		test_might_fail git config --unset merge.summary &&

Redundant, as you pointed out in another email.

> 		cat >expected <<-\EOF &&
> 		  Left #3
> 		  ...
> 		EOF
> 		git -c merge.log=3 fmt-merge-msg <.git/FETCH_HEAD >msg &&
> 
> 		tail -n 2 msg >actual &&
> 		test_cmp expected actual
> 	'

Ok. I don't like the `tail` thing. Why are you doing it instead of
comparing full outputs like the tests in the rest of the file?

> 	test_expect_success 'shortlog length defaults to 20' '
> 		[...]
> 	'

Actually, we can't test this unless we actually create a branch with
20 commits and merge it. I've dropped this- you might like to add it
during the cleanup.

> 	test_expect_success 'merge.log=5 does not limit shortlog length' '
> 		[...]
> 	'

Okay.

> 	test_expect_success 'merge.log=6 does not limit shortlog length' '
> 		[...]
> 	'

I thought this was a bit of an overkill, so I removed it.

> 	test_expect_success 'merge.log=0 disables shortlog' '
> 		[...]
> 	'

Okay.

> 	test_expect_success 'merge.log=-1 does something sane' '
> 		[...]
> 	'

Thanks! I found a bug and fixed it (patch will come in a moment).

> I can clean up the earlier tests afterwards. :)

Okay, sounds good.

-- Ram

```

## Jonathan Nieder, 2010-08-28 17:09

Subject: Re: [PATCH 1/2] t6200-fmt-merge-msg: Exercise 'merge.log' to configure shortlog length
Message-ID: <20100828170926.GA1945@burratino>
URL: https://gitlist.dev/e/20100828170926.GA1945%40burratino
In-Reply-To: <20100828103536.GA12205@kytes>

```
Ramkumar Ramachandra wrote:
> Jonathan Nieder writes:

>> 		cat >expected <<-\EOF &&
>> 		  Left #3
>> 		  ...
>> 		EOF
>> 		git -c merge.log=3 fmt-merge-msg <.git/FETCH_HEAD >msg &&
>> 
>> 		tail -n 2 msg >actual &&
>> 		test_cmp expected actual
>> 	'
>
> Ok. I don't like the `tail` thing. Why are you doing it instead of
> comparing full outputs like the tests in the rest of the file?

No good reason. :)

Thanks,
Jonathan

```
