# [PATCH 1/2] fmt-merge-msg: respect core.commentchar in people credits

12 messages from 2013-04-07 to 2013-04-21. Participants: Ralf Thielow, Johannes Sixt, Junio C Hamano, Jonathan Nieder.
Thread: https://gitlist.dev/t/33419

## Ralf Thielow, 2013-04-07 15:25

Subject: [PATCH 1/2] fmt-merge-msg: respect core.commentchar in people credits
Message-ID: <1365348344-1648-1-git-send-email-ralf.thielow@gmail.com>
URL: https://gitlist.dev/e/1365348344-1648-1-git-send-email-ralf.thielow%40gmail.com

```
Commit eff80a9 (Allow custom "comment char") introduced a custom
comment character for commit messages but forgot to use it in
people credits which can be a part of a commit message.

With this commit, the custom comment character is also used
in people credits.

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
---
 builtin/fmt-merge-msg.c  |  6 +++---
 t/t6200-fmt-merge-msg.sh | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index 265a925..88df93a 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -287,10 +287,10 @@ static void credit_people(struct strbuf *out,
 	const char *me;
 
 	if (kind == 'a') {
-		label = "\n# By ";
+		label = "By";
 		me = git_author_info(IDENT_NO_DATE);
 	} else {
-		label = "\n# Via ";
+		label = "Via";
 		me = git_committer_info(IDENT_NO_DATE);
 	}
 
@@ -300,7 +300,7 @@ static void credit_people(struct strbuf *out,
 	     (me = skip_prefix(me, them->items->string)) != NULL &&
 	     skip_prefix(me, " <")))
 		return;
-	strbuf_addstr(out, label);
+	strbuf_addf(out, "\n%c %s ", comment_line_char, label);
 	add_people_count(out, them);
 }
 
diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh
index 992c2a0..84e10fd 100755
--- a/t/t6200-fmt-merge-msg.sh
+++ b/t/t6200-fmt-merge-msg.sh
@@ -180,6 +180,24 @@ test_expect_success 'merge.log=5 shows all 5 commits' '
 	test_cmp expected actual
 '
 
+test_expect_success '--log=5 with custom comment character' '
+	cat >expected <<-EOF &&
+	Merge branch ${apos}left${apos}
+
+	/ By Another Author (3) and A U Thor (2)
+	/ Via Another Committer
+	* left:
+	  Left #5
+	  Left #4
+	  Left #3
+	  Common #2
+	  Common #1
+	EOF
+
+	git -c core.commentchar="/" fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
+	test_cmp expected actual
+'
+
 test_expect_success 'merge.log=0 disables shortlog' '
 	echo "Merge branch ${apos}left${apos}" >expected
 	git -c merge.log=0 fmt-merge-msg <.git/FETCH_HEAD >actual &&
-- 
1.8.2.470.g21ccebe

```

## Ralf Thielow, 2013-04-07 15:25

Subject: [PATCH 2/2] fmt-merge-msg: use core.commentchar in tag signatures completely
Message-ID: <1365348344-1648-2-git-send-email-ralf.thielow@gmail.com>
URL: https://gitlist.dev/e/1365348344-1648-2-git-send-email-ralf.thielow%40gmail.com
In-Reply-To: <1365348344-1648-1-git-send-email-ralf.thielow@gmail.com>

```
Commit eff80a9 (Allow custom "comment char") introduced a custom
comment character for commit messages but didn't use it completely
in the tag signature part.

This commit fixes that.

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
---
 builtin/fmt-merge-msg.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index 88df93a..1c04070 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -503,14 +503,18 @@ static void fmt_merge_msg_sigs(struct strbuf *out)
 		} else {
 			if (tag_number == 2) {
 				struct strbuf tagline = STRBUF_INIT;
-				strbuf_addf(&tagline, "\n# %s\n",
-					    origins.items[first_tag].string);
+				strbuf_addch(&tagline, '\n');
+				strbuf_add_commented_lines(&tagline,
+						origins.items[first_tag].string,
+						strlen(origins.items[first_tag].string));
 				strbuf_insert(&tagbuf, 0, tagline.buf,
 					      tagline.len);
 				strbuf_release(&tagline);
 			}
-			strbuf_addf(&tagbuf, "\n# %s\n",
-				    origins.items[i].string);
+			strbuf_addch(&tagbuf, '\n');
+			strbuf_add_commented_lines(&tagbuf,
+					origins.items[i].string,
+					strlen(origins.items[i].string));
 			fmt_tag_signature(&tagbuf, &sig, buf, len);
 		}
 		strbuf_release(&sig);
-- 
1.8.2.470.g21ccebe

```

## Johannes Sixt, 2013-04-18 06:42

Subject: t6200: avoid path mangling issue on Windows
Message-ID: <516F95D1.5070209@viscovery.net>
URL: https://gitlist.dev/e/516F95D1.5070209%40viscovery.net
In-Reply-To: <1365348344-1648-2-git-send-email-ralf.thielow@gmail.com>

```
From: Johannes Sixt <j6t@kdbg.org>

MSYS bash interprets the slash in the argument core.commentchar="/"
as root directory and mangles it into a Windows style path. Use a
different core.commentchar to dodge the issue.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 t/t6200-fmt-merge-msg.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh
index e7e945d..54b5744 100755
--- a/t/t6200-fmt-merge-msg.sh
+++ b/t/t6200-fmt-merge-msg.sh
@@ -179,8 +179,8 @@ test_expect_success '--log=5 with custom comment character' '
 	cat >expected <<-EOF &&
 	Merge branch ${apos}left${apos}
 
-	/ By Another Author (3) and A U Thor (2)
-	/ Via Another Committer
+	x By Another Author (3) and A U Thor (2)
+	x Via Another Committer
 	* left:
 	  Left #5
 	  Left #4
@@ -189,7 +189,7 @@ test_expect_success '--log=5 with custom comment character' '
 	  Common #1
 	EOF
 
-	git -c core.commentchar="/" fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
+	git -c core.commentchar="x" fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
 	test_cmp expected actual
 '
 
-- 
1.8.2.1.1678.gf713add

```

## Junio C Hamano, 2013-04-18 17:05

Subject: Re: t6200: avoid path mangling issue on Windows
Message-ID: <7v38un93br.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v38un93br.fsf%40alter.siamese.dyndns.org
In-Reply-To: <516F95D1.5070209@viscovery.net>

```
Johannes Sixt <j.sixt@viscovery.net> writes:

> From: Johannes Sixt <j6t@kdbg.org>
>
> MSYS bash interprets the slash in the argument core.commentchar="/"
> as root directory and mangles it into a Windows style path. Use a
> different core.commentchar to dodge the issue.
>
> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
> ...
> -	git -c core.commentchar="/" fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
> +	git -c core.commentchar="x" fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&

Sigh... Again?

Are folks working on Msys bash aware that sometimes the users may
want to say key=value on their command line without the value
getting molested in any way and giving them some escape hatch would
help them?  Perhaps they have already decided that it is not
feasible after thinking about the issue, in which case I do not have
new ideas to offer.

I'll apply the patch as-is, but this feels really painful to the
users.

Thanks.

```

## Johannes Sixt, 2013-04-19 05:48

Subject: Re: t6200: avoid path mangling issue on Windows
Message-ID: <5170DA96.9000300@viscovery.net>
URL: https://gitlist.dev/e/5170DA96.9000300%40viscovery.net
In-Reply-To: <7v38un93br.fsf@alter.siamese.dyndns.org>

```
Am 4/18/2013 19:05, schrieb Junio C Hamano:
> Johannes Sixt <j.sixt@viscovery.net> writes:
> 
>> From: Johannes Sixt <j6t@kdbg.org>
>>
>> MSYS bash interprets the slash in the argument core.commentchar="/"
>> as root directory and mangles it into a Windows style path. Use a
>> different core.commentchar to dodge the issue.
>>
>> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
>> ...
>> -	git -c core.commentchar="/" fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
>> +	git -c core.commentchar="x" fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
> 
> Sigh... Again?
> 
> Are folks working on Msys bash aware that sometimes the users may
> want to say key=value on their command line without the value
> getting molested in any way and giving them some escape hatch would
> help them?  Perhaps they have already decided that it is not
> feasible after thinking about the issue, in which case I do not have
> new ideas to offer.

What is "the issue"? And in which way would an escape hatch help us here?
We would have to apply a patch anyway after a glitch like this shows up,
because disabling path mangling whole-sale (if there were a method --
there is none currently) is a no-go in the context of our test suite, let
a lone in our scripted tool set.

When "foo=/" appears on the command line, the most obvious interpretation
of the slash for a program without mind-reading mode is that it is an
absolute path, and then path mangling must happen (if and only if the
invoked program is a non-MSYS program such as git).

> I'll apply the patch as-is, but this feels really painful to the
> users.

No, generally, path mangling is a service for the user.

-- Hannes

```

## Junio C Hamano, 2013-04-19 16:33

Subject: Re: t6200: avoid path mangling issue on Windows
Message-ID: <7vr4i632fp.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vr4i632fp.fsf%40alter.siamese.dyndns.org
In-Reply-To: <5170DA96.9000300@viscovery.net>

```
Johannes Sixt <j.sixt@viscovery.net> writes:

> Am 4/18/2013 19:05, schrieb Junio C Hamano:
>> Johannes Sixt <j.sixt@viscovery.net> writes:
>> 
>>> From: Johannes Sixt <j6t@kdbg.org>
>>>
>>> MSYS bash interprets the slash in the argument core.commentchar="/"
>>> as root directory and mangles it into a Windows style path. Use a
>>> different core.commentchar to dodge the issue.
>>>
>>> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
>>> ...
>>> -	git -c core.commentchar="/" fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
>>> +	git -c core.commentchar="x" fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
>> 
>> Sigh... Again?
>> 
>> Are folks working on Msys bash aware that sometimes the users may
>> want to say key=value on their command line without the value
>> getting molested in any way and giving them some escape hatch would
>> help them?  Perhaps they have already decided that it is not
>> feasible after thinking about the issue, in which case I do not have
>> new ideas to offer.
>
> What is "the issue"? And in which way would an escape hatch help us here?

When the user passes key=value and value begins with a slash, value
may be a path in the filesystem very often, and adjusting it to the
local filesystem convention helps Windows users a lot.

But there are cases outside that very often when the user wants the
value passed literally.  There seems to be no way to do so.

That is the issue I was wondering. If there is a clean solution to
disable path mangling per token, we could cleanly solve it.

For example, while making sure that a value that begins with slash
in normal cases is still adjusted, i.e. mangling all of the
following,

	xyzzy key=/a/b/c
        xyzzy key="/a/b/c"
        value=/a/b/c; xyzzy key="$value"
        value=/a/b/c; xyzzy "key=$value"


if bash could be told with a very unnatural and not so hard to type
way that the particular value is not to be mangled, e.g.

	xyzzy key="""/a/b/c"""
        value=/a/b/c; xyzzy """key=$value"""

which a normal bash would interpret as the concatenation of an empty
string inside dq, /a/b/c/ (or key=$value) inside dq, and an empty
string inside dq, which is the same as /a/b/c (or key=$value) inside
dq, it would help the less common case.  Nobody would type a string
surrounded by two empty strings to be concatenated on purpose
(i.e. very unnatural) and typing the same dq four more times than
you would normally do is not too much of a hassle (not so hard to
type).  The problematic case can then be fixed to

	git -c core.commentchar="""/""" fmt-merge-msg ...

and it will work the same way on and off Windows.

```

## Johannes Sixt, 2013-04-19 19:46

Subject: Re: t6200: avoid path mangling issue on Windows
Message-ID: <51719F18.3020508@kdbg.org>
URL: https://gitlist.dev/e/51719F18.3020508%40kdbg.org
In-Reply-To: <7vr4i632fp.fsf@alter.siamese.dyndns.org>

```
Am 19.04.2013 18:33, schrieb Junio C Hamano:
> Johannes Sixt <j.sixt@viscovery.net> writes:
> 
>> Am 4/18/2013 19:05, schrieb Junio C Hamano:
>>> Johannes Sixt <j.sixt@viscovery.net> writes:
>>>
>>>> From: Johannes Sixt <j6t@kdbg.org>
>>>>
>>>> MSYS bash interprets the slash in the argument core.commentchar="/"
>>>> as root directory and mangles it into a Windows style path. Use a
>>>> different core.commentchar to dodge the issue.
>>>>
>>>> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
>>>> ...
>>>> -	git -c core.commentchar="/" fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
>>>> +	git -c core.commentchar="x" fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
>>>
>>> Sigh... Again?
>>>
>>> Are folks working on Msys bash aware that sometimes the users may
>>> want to say key=value on their command line without the value
>>> getting molested in any way and giving them some escape hatch would
>>> help them?  Perhaps they have already decided that it is not
>>> feasible after thinking about the issue, in which case I do not have
>>> new ideas to offer.
>>
>> What is "the issue"? And in which way would an escape hatch help us here?
> 
> When the user passes key=value and value begins with a slash, value
> may be a path in the filesystem very often, and adjusting it to the
> local filesystem convention helps Windows users a lot.
> 
> But there are cases outside that very often when the user wants the
> value passed literally.  There seems to be no way to do so.
> ...
> if bash could be told with a very unnatural and not so hard to type
> way that the particular value is not to be mangled, e.g.
> 
> 	xyzzy key="""/a/b/c"""

I'll not argue whether such a feature would make sense or not, or
whether it can be implemented, because it is aimed at the user, but
misses one important point: It does in no way help our development process.

A patch auther whose first instinct is to write 'foo=/' will never write
'foo=x', let alone 'foo="""/"""'. Someone will have to discover the
issue eventually and write a patch to fix it, and someone will have to
apply it.

I don't think that we can do anything about it.

-- Hannes

```

## Junio C Hamano, 2013-04-19 21:22

Subject: Re: t6200: avoid path mangling issue on Windows
Message-ID: <7va9ouz04y.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7va9ouz04y.fsf%40alter.siamese.dyndns.org
In-Reply-To: <51719F18.3020508@kdbg.org>

```
Johannes Sixt <j6t@kdbg.org> writes:

> A patch auther whose first instinct is to write 'foo=/' will never write
> 'foo=x', let alone 'foo="""/"""'. Someone will have to discover the
> issue eventually and write a patch to fix it, and someone will have to
> apply it.

That is a separate issue.  Didn't I say I'll apply it as-is at the
very beginning?

Our _tests_ can afford to use an unrealistic setting like

    git -c core.commentchar="x" fmt-merge-msg

to work it around, because the tests do not _care_ how the final
outcome looks like. It only cares what we specified gets used.

But a _real user_ who wants to use a slash there has no way of doing
so.  It is still not realistic, as it is more likely that she would
want to use a double-slash, but that would not fit in a commentchar,
and she is a lot more likely to have it in the configuration file,
but I wouldn't imagine that there are things other than "-c var=val"
that are more commonly given on the command line that share the same
pain point as this one.

That is what I meant by "feels painful to the users" and wondered if
bash on Windows can be more helpful to them.

```

## Jonathan Nieder, 2013-04-21 00:05

Subject: Re: t6200: avoid path mangling issue on Windows
Message-ID: <20130421000522.GB10043@elie.Belkin>
URL: https://gitlist.dev/e/20130421000522.GB10043%40elie.Belkin
In-Reply-To: <7va9ouz04y.fsf@alter.siamese.dyndns.org>

```
Junio C Hamano wrote:

> But a _real user_ who wants to use a slash there has no way of doing
> so.

Doesn't foo=// do that in the msys world?  If I am reading
mingw/msys/rt/src/winsup/cygwin/path.cc correctly then the way to pass
a true double-slash is foo=///.

Jonathan

```

## Johannes Sixt, 2013-04-21 06:22

Subject: Re: t6200: avoid path mangling issue on Windows
Message-ID: <517385A6.8020908@kdbg.org>
URL: https://gitlist.dev/e/517385A6.8020908%40kdbg.org
In-Reply-To: <20130421000522.GB10043@elie.Belkin>

```
Am 21.04.2013 02:05, schrieb Jonathan Nieder:
> Junio C Hamano wrote:
> 
>> But a _real user_ who wants to use a slash there has no way of doing
>> so.
> 
> Doesn't foo=// do that in the msys world?  If I am reading
> mingw/msys/rt/src/winsup/cygwin/path.cc correctly then the way to pass
> a true double-slash is foo=///.

That would be totally unexpected.

-- Hannes

```

## Jonathan Nieder, 2013-04-21 06:35

Subject: Re: t6200: avoid path mangling issue on Windows
Message-ID: <20130421063550.GC10429@elie.Belkin>
URL: https://gitlist.dev/e/20130421063550.GC10429%40elie.Belkin
In-Reply-To: <517385A6.8020908@kdbg.org>

```
Johannes Sixt wrote:
> Am 21.04.2013 02:05, schrieb Jonathan Nieder:
>> Junio C Hamano wrote:

>>> But a _real user_ who wants to use a slash there has no way of doing
>>> so.
>>
>> Doesn't foo=// do that in the msys world?  If I am reading
>> mingw/msys/rt/src/winsup/cygwin/path.cc correctly then the way to pass
>> a true double-slash is foo=///.
>
> That would be totally unexpected.

There is an exception to the path mangling for //unc/paths, if that's
what you mean.

>From [1]:

  if (path[0] == '/' && path[1] == '/')
    {
      int tidx = 2;
      while (spath[tidx] && spath[tidx] == '/')
	  tidx++;
      if (strchr (&spath[tidx], '/'))
	{
	  retpathcpy (spath);
	}
      else
	{
	  retpathcpy (&spath[1]);
	}
      return ScrubRetpath (retpath);
    }

I haven't tested, since I don't have easy access to a Windows test
setup.

Regards,
Jonathan

[1] http://mingw.cvs.sourceforge.net/viewvc/mingw/msys/rt/src/winsup/cygwin/path.cc?content-type=text%2Fplain

```

## Junio C Hamano, 2013-04-21 07:12

Subject: Re: t6200: avoid path mangling issue on Windows
Message-ID: <7vli8cwe5v.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vli8cwe5v.fsf%40alter.siamese.dyndns.org
In-Reply-To: <20130421000522.GB10043@elie.Belkin>

```
Jonathan Nieder <jrnieder@gmail.com> writes:

> Junio C Hamano wrote:
>
>> But a _real user_ who wants to use a slash there has no way of doing
>> so.
>
> Doesn't foo=// do that in the msys world?

"that" refers to...?  Do you mean:

    $ value=/; mycmd key="$value"

    breaks msys, but you can say

    $ value=//; mycmd key="$value"

    instead to pass a value that is a single slash.

then that is not a valid workaround; it would work differently
between Windows (passes one slash?) and everybody else (passes two
slashes).

I do not mean to say the "'' (empty string) and what you want to say
and '' (empty string) concatenated together" I suggested in the
previous message is a workable (let alone the best) proposition, but
if

    $ value=/; mycmd key=''"$value"''

worked as a way to temporarily turn off the path mangling, it at
least would be a usable workaround that would work the same way
between Windows and everybody else.

```
