git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Avery Pennarun <apenwarr@gmail.com>
Cc: git@vger.kernel.org, Eric Wong <normalperson@yhbt.net>,
	Sam Vilain <sam.vilain@catalyst.net.nz>
Subject: Re: [PATCH 1/2] git-svn: don't append extra newlines at the end of commit messages.
Date: Thu, 12 Jun 2008 22:41:46 -0700	[thread overview]
Message-ID: <7vfxrhyjqd.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <1213312251-8081-1-git-send-email-apenwarr@gmail.com> (Avery Pennarun's message of "Thu, 12 Jun 2008 19:10:50 -0400")

Avery Pennarun <apenwarr@gmail.com> writes:

> In git, all commits end in exactly one newline character.  In svn, commits
> end in zero or more newlines.  Thus, when importing commits from svn into
> git, git-svn always appends two extra newlines to ensure that the
> git-svn-id: line is separated from the main commit message by at least one
> blank line.
>
> Combined with the terminating newline that's always present in svn commits
> produced by git, you usually end up with two blank lines instead of one
> between the commit message and git-svn-id: line, which is undesirable.
>
> Instead, let's remove all trailing whitespace from the git commit on the way
> through to svn.

Perl part of the code looks fine but I am unsure if we like the
ramifications of this patch on existing git-svn managed repositories.
Doesn't this change the commit object name on our end for almost all of
them?

> Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
> ---
>  git-svn.perl |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/git-svn.perl b/git-svn.perl
> index 47b0c37..a54979d 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -1023,6 +1023,7 @@ sub get_commit_entry {
>  		my $in_msg = 0;
>  		my $author;
>  		my $saw_from = 0;
> +		my $msgbuf = "";
>  		while (<$msg_fh>) {
>  			if (!$in_msg) {
>  				$in_msg = 1 if (/^\s*$/);
> @@ -1035,14 +1036,15 @@ sub get_commit_entry {
>  				if (/^From:/ || /^Signed-off-by:/) {
>  					$saw_from = 1;
>  				}
> -				print $log_fh $_ or croak $!;
> +				$msgbuf .= $_;
>  			}
>  		}
> +		$msgbuf =~ s/\s+$//s;
>  		if ($Git::SVN::_add_author_from && defined($author)
>  		    && !$saw_from) {
> -			print $log_fh "\nFrom: $author\n"
> -			      or croak $!;
> +			$msgbuf .= "\n\nFrom: $author";
>  		}
> +		print $log_fh $msgbuf or croak $!;
>  		command_close_pipe($msg_fh, $ctx);
>  	}
>  	close $log_fh or croak $!;
> -- 
> 1.5.4.3

  parent reply	other threads:[~2008-06-13  5:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-12 23:10 [PATCH 1/2] git-svn: don't append extra newlines at the end of commit messages Avery Pennarun
2008-06-12 23:10 ` [PATCH 2/2] git-svn: test that extra blank lines aren't inserted in " Avery Pennarun
2008-06-13  5:41 ` Junio C Hamano [this message]
2008-06-13  6:29   ` [PATCH 1/2] git-svn: don't append extra newlines at the end of " Karl Hasselström
2008-06-13 16:17   ` Avery Pennarun
2008-06-13  7:23 ` Andreas Ericsson
2008-06-13  8:09   ` Karl Hasselström
2008-06-14  8:43     ` Karl Hasselström
2008-06-13 16:23   ` Avery Pennarun

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=7vfxrhyjqd.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=apenwarr@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=normalperson@yhbt.net \
    --cc=sam.vilain@catalyst.net.nz \
    /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).