From: Junio C Hamano <gitster@pobox.com>
To: Robert Luberda <robert@debian.org>
Cc: Eric Wong <normalperson@yhbt.net>, git@vger.kernel.org
Subject: Re: [PATCH/RFC] git svn: optionally trim imported log messages
Date: Sun, 19 Aug 2012 16:59:41 -0700 [thread overview]
Message-ID: <7vsjbio2ky.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1345413170-2519-1-git-send-email-robert@debian.org> (Robert Luberda's message of "Sun, 19 Aug 2012 23:52:50 +0200")
Robert Luberda <robert@debian.org> writes:
> Introduce a `--trim-svn-log' option and svn.trimsvnlog boolean
> configuration key for git svn commands.
>
> When enabled while retrieving commits from svn, git svn will strip any
> white spaces from beginnings and endings of SVN commit messages and will
> skip adding an extra new line character before `git-svn-id:' line in case
> the commit message already ends with a pseudo-headers section (a section
> starting with an empty line followed by one or more pseudo-headers like
> `From: ', `Signed-off-by: ', or `Change-Id: ').
>
> Additionally, while creating new commits in svn when the new option is
> enabled and `--add-author-from' is in effect, git svn will not add
> a new line character before the `From: ' pseudo-header if the commit
> message already ends with a pseudo-headers section.
>
> The new option allows one to use gerrit code review system on
> git-svn-managed repositories. gerrit expects its `Change-Id:' header
> to appear in the last paragraph of commit message and the standard
> behaviour of preceding `git-svn-id:' line with a new line character
> was breaking this expectation.
> ---
Sign-off?
> Documentation/git-svn.txt | 16 ++
> git-svn.perl | 8 +-
> perl/Git/SVN.pm | 19 +-
> t/t9165-git-svn-import-messages.sh | 387 ++++++++++++++++++++++++++++++++++++
> 4 files changed, 427 insertions(+), 3 deletions(-)
> create mode 100755 t/t9165-git-svn-import-messages.sh
>
> diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
> index cfe8d2b..79c21ee 100644
> --- a/Documentation/git-svn.txt
> +++ b/Documentation/git-svn.txt
> @@ -603,6 +603,22 @@ creating the branch or tag.
> git commit's author string. If you use this, then `--use-log-author`
> will retrieve a valid author string for all commits.
>
> +--trim-svn-log::
> + When retrieving svn commits into git (as part of 'fetch', 'rebase',
> + or 'dcommit') trim the whitespaces from beginnings and endings
> + of the svn log messages and avoid preceding `git-svn-id:` line with
> + a new line character in case the log message already ends with a
> + pseudo-headers section (i.e. section starting with an empty line
> + followed by one or more lines like `Signed-off-by: `, `From: `,
> + or `Change-Id: `).
> ++
> +When committing to svn from git (as part of 'commit-diff', 'set-tree'
> +or 'dcommit') and '--add-author-from' is in effect, a new line character
> +is not added before the `From: ` line if the log message ends with
> +a pseudo-headers section.
I think it would be saner to call them "trailers" to avoid
confusion.
I've seen S-o-b, Cc and Change-Id there, but does anybody actually
put "From: " there?
There needs an explanation to the reader why this is an optional
feature.
> --- /dev/null
> +++ b/t/t9165-git-svn-import-messages.sh
> @@ -0,0 +1,387 @@
> +#!/bin/sh
> +#
> +# Copyright (c) 2012 Robert Luberda
> +#
> +
> +test_description='checks behaviour of --trim-svn-log option of git svn'
> +. ./lib-git-svn.sh
> +
> +# The test cases in this file check if the --trim-svn-log option
> +# of git svn works as expected.
> +#
> +# Basically the test cases use two git repositories:
> +# * work-TRIM.git, created by git svn clone with the option enabled,
> +# * work-NOTR.git, created with the option disabled.
> +#
> +# Each test case (except for the first two) does the following:
> +# 1. commit a change to svn with either svn commit, or git svn dcommit
> +# (what is important is the commit log message, not the changed file)
> +# 2. git svn rebase the work-NOTR.git repository and check its most recent
> +# log message against some expected output
> +# 3. git svn rebase the work-TRIM.git repository and similarly check the
> +# latest log message
> +#
> +# The following two prerequisites are defined mostly for debugging purposes
> +# to make it possible to skip test cases or parts of the test cases that
> +# operate on one of the two git repositories. For example to ignore checking
The prerequisite mechanism is to allow some tests in an environment
where they cannot be run (e.g. no SVN available on the platform);
any code that uses set_prereq unconditionally looks extremely
strange. It is OK while the patch is in RFC stage under active
debugging, but they would want to go away before the polishing is
done.
> +# of log messages imported when --trim-svn-log is enabled, one needs to comment
> +# out the PRQ_TRIM pre-requisite (this makes it possible to run the test with
> +# a version of git svn that does not support the option yet). Similarly
> +# commenting out the PRQ_NOTR pre-requisite will check only the effects of the
> +# svn log trimming option.
> +# Please note that a whole test case must be marked as requiring one of
> +# those pre-requisites if and only if it uses `git svn dcommit' for committing
> +# changes to svn.
> +test_set_prereq PRQ_TRIM
> +test_set_prereq PRQ_NOTR
> +N=0
> +NL="" # for better readability only, e.g.:
> + # "$NL" " " "$NL" is cleaner than "" " " ""
What does En-El stand for? We often see (but not in Git where we
prefer LF for that purpose)
NL='
' ;# newline
and using $NL to mean "empty" may be misleading to the readers.
> +next_N()
> +{
> + N=$((N + 1)) &&
> + echo "N is $N"
> +}
Most shells tolerate writing a bare N inside arith substitution, but
for better portability, please spell this as
next_N () {
N=$(($N + 1)) &&
...
}
(the above also has two style fixes).
> +
> +# An utility function used for writing log messages to files
> +get_file_contents()
> +{
> + for line in "$@"; do
> + echo "$line"
> + done
> +}
(Style)
get_file_contents () {
for line
do
...
done
}
next prev parent reply other threads:[~2012-08-19 23:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-01 21:23 [PATCH/RFC] git svn: don't introduce new paragraph for git-svn-id Robert Luberda
2012-08-01 21:43 ` Eric Wong
2012-08-01 22:27 ` Robert Luberda
2012-08-01 23:01 ` Eric Wong
2012-08-19 21:46 ` Robert Luberda
2012-08-19 21:52 ` [PATCH/RFC] git svn: optionally trim imported log messages Robert Luberda
2012-08-19 23:59 ` Junio C Hamano [this message]
2012-08-24 22:38 ` Robert Luberda
2012-08-24 23:38 ` Junio C Hamano
2012-08-21 21:45 ` [PATCH/RFC] git svn: don't introduce new paragraph for git-svn-id Eric Wong
2012-08-21 22:35 ` Junio C Hamano
2012-08-24 23:14 ` Robert Luberda
2012-08-26 0:36 ` Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vsjbio2ky.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=normalperson@yhbt.net \
--cc=robert@debian.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).