threads / patch / 4657

patchRe: [PATCH] git-commit: filter out log message lines only when editor was run.

Subject: Re: [PATCH] git-commit: filter out log message lines only when editor was run.

## tl;dr

3 messages between Jun 24, 2006 and Jun 25, 2006. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Yann Dirson· Jun 24, 2006, 09:42 UTC · lore
Junio wrote:
> I agree with this in principle but we would need to make sure
> that our own scripts do not expect that the message is cleaned
> up when feeding a commit log message via stdin, -m or -F, and if
> they do fix them before applying this patch.

The only tools in git.git I could identify as using git-commit rather than commit-tree are:

git-revert.sh: OK git-rebase.sh: only uses -C

cogito, stgit, and pg also use commit-tree. Only qgit seems to be using git-commit, and probably makes use of this (mis)feature.

I guess the easiest way to get the 1.4.0 behaviour is to change git-commit calls to "git-commit -e" with EDITOR=true in the environment. I'm not sure it would be worth adding a new flag to switch on/off log stripping.

Best regards,
-- 
Yann Dirson    <ydirson@altern.org> |
Debian-related: <dirson@debian.org> |   Support Debian GNU/Linux:
                                    |  Freedom, Power, Stability, Gratis
     http://ydirson.free.fr/        | Check <http://www.debian.org/>
Marco Costalba· Jun 25, 2006, 07:08 UTC · re: Yann Dirson · lore
On 6/24/06, Yann Dirson <ydirson@altern.org> wrote:
Show 15 quoted lines
> Junio wrote:
> > I agree with this in principle but we would need to make sure
> > that our own scripts do not expect that the message is cleaned
> > up when feeding a commit log message via stdin, -m or -F, and if
> > they do fix them before applying this patch.
>
> The only tools in git.git I could identify as using git-commit rather
> than commit-tree are:
>
> git-revert.sh: OK
> git-rebase.sh: only uses -C
>
> cogito, stgit, and pg also use commit-tree.  Only qgit seems to be
> using git-commit, and probably makes use of this (mis)feature.
>
Yes, qgit uses git-commit, but issue is different.

qgit uses the output of git status as a 'default text' used in the commit dialog. When commit button is pressed, after some message editing by the user, the comment lines are stripped _before_ to save the content of commit message in a temporary file to be used by git-commit with -F option.

The comment stripping is done by this code:
	msg = textEditMsg->text();
	msg.remove(QRegExp("\\n\\s*#[^\\n]*")); // strip comments
	msg.replace(QRegExp("[ \\t\\r\\f\\v]+\\n"), "\n"); // strip line trailing cruft
	msg = msg.stripWhiteSpace();
as you see it rely on the  '#' character.
So conclusions are:
1) It's ok to let git-comit do not strip comment lines, it's already
done by qgit.
2) Please don't change git status output to use another symbol to mark
comment lines because it will break line stripping code.
        Marco
Yann Dirson· Jun 25, 2006, 07:21 UTC · re: Marco Costalba · lore
On Sun, Jun 25, 2006 at 09:08:02AM +0200, Marco Costalba wrote:
> 1) It's ok to let git-comit do not strip comment lines, it's already
> done by qgit.
That's great news :)
> 2) Please don't change git status output to use another symbol to mark
> comment lines because it will break line stripping code.

If it ever gets changed, it should anyway IMHO be made a parameter. A strategy could be to make it customizable first, advertize this loudly so tools adapt themselves to force the prefix to what suits them best, and then eventually change the default in a major release.

Best regards,
-- 
Yann Dirson    <ydirson@altern.org> |
Debian-related: <dirson@debian.org> |   Support Debian GNU/Linux:
                                    |  Freedom, Power, Stability, Gratis
     http://ydirson.free.fr/        | Check <http://www.debian.org/>

← back to recent threads