threads / patch / 13288

patchSame default as cvsimport when using --use-log-author

Subject: [updated PATCH] Same default as cvsimport when using --use-log-author

## tl;dr

8 messages between Apr 27, 2008 and May 1, 2008. Diffs are folded; open one to read it.

replies: 7people: 5as markdown or json

Stephen R. van den Berg· Apr 27, 2008, 17:32 UTC · lore

When using git-cvsimport, the author is inferred from the cvs commit, e.g. cvs commit logname is foobaruser, then the author field in git results in:

Author: foobaruser <foobaruser>
Which is not perfect, but perfectly acceptable given the circumstances.
The default git-svn import however, results in:
Author: foobaruser <foobaruser@acf43c95-373e-0410-b603-e72c3f656dc1>

When using mixes of imports, from CVS and SVN into the same git repository, you'd like to harmonise the imports to the format cvsimport uses. git-svn supports an experimental option --use-log-author which currently results in:

Author: foobaruser <unknown>

This patches harmonises the result with cvsimport, and makes git-svn --use-log-author produce:

Author: foobaruser <foobaruser>
Signed-off-by: Stephen R. van den Berg <srb@cuci.nl>
---
 git-svn.perl |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Show changes to git-svn.perl +3 −0
diff --git a/git-svn.perl b/git-svn.perl
index b151049..846e739 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -2434,6 +2434,9 @@ sub make_log_entry {
 		} else {
 			($name, $email) = ($name_field, 'unknown');
 		}
+	        if (!defined $email) {
+		    $email = $name;
+	        }
 	}
 	if (defined $headrev && $self->use_svm_props) {
 		if ($self->rewrite_root) {
Junio C Hamano· Apr 27, 2008, 20:47 UTC · re: Stephen R. van den Berg · lore

Re: [updated PATCH] Same default as cvsimport when using --use-log-author

"Stephen R. van den Berg" <srb@cuci.nl> writes:
> git-svn supports an experimental option --use-log-author which currently
> results in:
>
> Author: foobaruser <unknown>
I have a question about this.  Is the "<unknown> coming from...
Show 13 quoted lines
> This patches harmonises the result with cvsimport, and makes
> git-svn --use-log-author produce:
>
> Author: foobaruser <foobaruser>
> ...
> diff --git a/git-svn.perl b/git-svn.perl
> index b151049..846e739 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -2434,6 +2434,9 @@ sub make_log_entry {
>  		} else {
>  			($name, $email) = ($name_field, 'unknown');
>  		}
... this 'unknown' we see here?
> +	        if (!defined $email) {
> +		    $email = $name;
> +	        }
>  	}

I would think not -- if that is the case, the codepath you added as a fix would not trigger. Which means in some other cases, the 'unknown' we see above in the context also still happens. Is it a good thing? Maybe we would also want to make it consistently do "somebody <somebody>" instead, by doing...

	} else {
		$name = $name_field;
	}
        if (!defined $email) {
	    $email = $name;
        }
Eric Wong· Apr 29, 2008, 06:18 UTC · re: Junio C Hamano · lore

Re: [updated PATCH] Same default as cvsimport when using --use-log-author

Junio C Hamano <gitster@pobox.com> wrote:
Show 43 quoted lines
> "Stephen R. van den Berg" <srb@cuci.nl> writes:
> 
> > git-svn supports an experimental option --use-log-author which currently
> > results in:
> >
> > Author: foobaruser <unknown>
> 
> I have a question about this.  Is the "<unknown> coming from...
> 
> > This patches harmonises the result with cvsimport, and makes
> > git-svn --use-log-author produce:
> >
> > Author: foobaruser <foobaruser>
> > ...
> > diff --git a/git-svn.perl b/git-svn.perl
> > index b151049..846e739 100755
> > --- a/git-svn.perl
> > +++ b/git-svn.perl
> > @@ -2434,6 +2434,9 @@ sub make_log_entry {
> >  		} else {
> >  			($name, $email) = ($name_field, 'unknown');
> >  		}
> 
> ... this 'unknown' we see here?
> 
> > +	        if (!defined $email) {
> > +		    $email = $name;
> > +	        }
> >  	}
> 
> I would think not -- if that is the case, the codepath you added as a fix
> would not trigger.  Which means in some other cases, the 'unknown' we see
> above in the context also still happens.  Is it a good thing?  Maybe we
> would also want to make it consistently do "somebody <somebody>" instead,
> by doing...
> 
> 	} else {
> 		$name = $name_field;
> 	}
>         if (!defined $email) {
> 	    $email = $name;
>         }
> 
I don't think Stephen's patch ever gets triggered, either.

This section of code was done by Andy, so I can't tell his motivations for using 'unknown' the way he did.

$email does appear to get set correctly for the first two elsifs cases here in the existing code:

		if (!defined $name_field) {
			#
		} elsif ($name_field =~ /(.*?)\s+<(.*)>/) {
			($name, $email) = ($1, $2);
		} elsif ($name_field =~ /(.*)@/) {
			($name, $email) = ($1, $name_field);
		} else {
			($name, $email) = ($name_field, $name_field);
So I propose the following one-line change instead of Stephen's:
Show changes to git-svn.perl +1 −1
diff --git a/git-svn.perl b/git-svn.perl
index b151049..301a5b4 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -2432,7 +2432,7 @@ sub make_log_entry {
 		} elsif ($name_field =~ /(.*)@/) {
 			($name, $email) = ($1, $name_field);
 		} else {
-			($name, $email) = ($name_field, 'unknown');
+			($name, $email) = ($name_field, $name_field);
 		}
 	}
 	if (defined $headrev && $self->use_svm_props) {
-- 
Eric Wong
Andy Whitcroft· Apr 29, 2008, 09:52 UTC · re: Eric Wong · lore

Re: [updated PATCH] Same default as cvsimport when using --use-log-author

On Mon, Apr 28, 2008 at 11:18:23PM -0700, Eric Wong wrote:
Show 49 quoted lines
> Junio C Hamano <gitster@pobox.com> wrote:
> > "Stephen R. van den Berg" <srb@cuci.nl> writes:
> > 
> > > git-svn supports an experimental option --use-log-author which currently
> > > results in:
> > >
> > > Author: foobaruser <unknown>
> > 
> > I have a question about this.  Is the "<unknown> coming from...
> > 
> > > This patches harmonises the result with cvsimport, and makes
> > > git-svn --use-log-author produce:
> > >
> > > Author: foobaruser <foobaruser>
> > > ...
> > > diff --git a/git-svn.perl b/git-svn.perl
> > > index b151049..846e739 100755
> > > --- a/git-svn.perl
> > > +++ b/git-svn.perl
> > > @@ -2434,6 +2434,9 @@ sub make_log_entry {
> > >  		} else {
> > >  			($name, $email) = ($name_field, 'unknown');
> > >  		}
> > 
> > ... this 'unknown' we see here?
> > 
> > > +	        if (!defined $email) {
> > > +		    $email = $name;
> > > +	        }
> > >  	}
> > 
> > I would think not -- if that is the case, the codepath you added as a fix
> > would not trigger.  Which means in some other cases, the 'unknown' we see
> > above in the context also still happens.  Is it a good thing?  Maybe we
> > would also want to make it consistently do "somebody <somebody>" instead,
> > by doing...
> > 
> > 	} else {
> > 		$name = $name_field;
> > 	}
> >         if (!defined $email) {
> > 	    $email = $name;
> >         }
> > 
> 
> I don't think Stephen's patch ever gets triggered, either.
> 
> This section of code was done by Andy, so I can't tell his motivations
> for using 'unknown' the way he did.

My motivation was that we had picked up a field which is supposed to be in RFC822 From: format, ie Name <email>, and dispite trying pretty hard we had not been able to find something that looked like an email to put in the email field of the git author et al. So we didn't really know, hence 'unknown'.

That said it is not at all clear that putting 'unknown' in this field to avoid putting an invalid email in this field makes much sense as it of itself is just as invalid. So I would probabally be just as happy with your option here.

Show 30 quoted lines
> $email does appear to get set correctly for the first two elsifs cases
> here in the existing code:
> 
> 		if (!defined $name_field) {
> 			#
> 		} elsif ($name_field =~ /(.*?)\s+<(.*)>/) {
> 			($name, $email) = ($1, $2);
> 		} elsif ($name_field =~ /(.*)@/) {
> 			($name, $email) = ($1, $name_field);
> 		} else {
> 			($name, $email) = ($name_field, $name_field);
> 
> So I propose the following one-line change instead of Stephen's:
> 
> diff --git a/git-svn.perl b/git-svn.perl
> index b151049..301a5b4 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -2432,7 +2432,7 @@ sub make_log_entry {
>  		} elsif ($name_field =~ /(.*)@/) {
>  			($name, $email) = ($1, $name_field);
>  		} else {
> -			($name, $email) = ($name_field, 'unknown');
> +			($name, $email) = ($name_field, $name_field);
>  		}
>  	}
>  	if (defined $headrev && $self->use_svm_props) {
> 
> -- 
> Eric Wong
-apw
Stephen R. van den Berg· Apr 29, 2008, 21:13 UTC · re: Eric Wong · lore

Re: [updated PATCH] Same default as cvsimport when using --use-log-author

Eric Wong wrote:
>Junio C Hamano <gitster@pobox.com> wrote:
>> "Stephen R. van den Berg" <srb@cuci.nl> writes:
>> > git-svn supports an experimental option --use-log-author which currently
>> > results in:
>> > Author: foobaruser <unknown>
>> I have a question about this.  Is the "<unknown> coming from...

I have to correct myself here. What happens is that if in the commit message there is no From: or Signed-off-by: to be found to parse, that results in an empty $name_field, and causes $email to stay undefined, which eventually results in the same silly generated UUID-domain I'm trying to get rid of.

So it's not triggering the 'unknown' above.
Show 5 quoted lines
>> I would think not -- if that is the case, the codepath you added as a fix
>> would not trigger.  Which means in some other cases, the 'unknown' we see
>> above in the context also still happens.  Is it a good thing?  Maybe we
>> would also want to make it consistently do "somebody <somebody>" instead,
>> by doing...
>I don't think Stephen's patch ever gets triggered, either.

Well, it is triggered, but rather because $name_field is empty, and consequently $email is never set.

>$email does appear to get set correctly for the first two elsifs cases
>here in the existing code:
>So I propose the following one-line change instead of Stephen's:
>diff --git a/git-svn.perl b/git-svn.perl
>@@ -2432,7 +2432,7 @@ sub make_log_entry {
>-			($name, $email) = ($name_field, 'unknown');
>+			($name, $email) = ($name_field, $name_field);

That is a good change (IMO), but I still need my patch (or something similar) to cover the undefined $name_field case. Proposed new patch follows.

-- 
Sincerely,                                                          srb@cuci.nl
           Stephen R. van den Berg.

"There's a lot to be said for not saying a lot."
Stephen R. van den Berg· Apr 29, 2008, 21:20 UTC · re: Stephen R. van den Berg · lore

[updated2 PATCH] git-svn: Same default as cvsimport when using --use-log-author

When using git-cvsimport, the author is inferred from the cvs commit, e.g. cvs commit logname is foobaruser, then the author field in git results in:

Author: foobaruser <foobaruser>
Which is not perfect, but perfectly acceptable given the circumstances.
The default git-svn import however, results in:
Author: foobaruser <foobaruser@acf43c95-373e-0410-b603-e72c3f656dc1>
When using mixes of imports, from CVS and SVN into the same git
repository, you'd like to harmonise the imports to the format cvsimport
uses.
git-svn supports an experimental option --use-log-author which currently
results in the same logentry as without that option when no From: or
Signed-off-by: is found in the logentry ($email currently ends up empty,
and hence is generated again).

This patches harmonises the result with cvsimport, and makes git-svn --use-log-author produce:

Author: foobaruser <foobaruser>
Signed-off-by: Stephen R. van den Berg <srb@cuci.nl>
---
 git-svn.perl |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
Show changes to git-svn.perl +4 −2
diff --git a/git-svn.perl b/git-svn.perl
index b151049..67726c1 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -2426,13 +2426,15 @@ sub make_log_entry {
 			$name_field = $1;
 		}
 		if (!defined $name_field) {
-			#
+			if (!defined $email) {
+				$email = $name;
+			}
 		} elsif ($name_field =~ /(.*?)\s+<(.*)>/) {
 			($name, $email) = ($1, $2);
 		} elsif ($name_field =~ /(.*)@/) {
 			($name, $email) = ($1, $name_field);
 		} else {
-			($name, $email) = ($name_field, 'unknown');
+			($name, $email) = ($name_field, $name_field);
 		}
 	}
 	if (defined $headrev && $self->use_svm_props) {
Eric Wong· May 1, 2008, 03:47 UTC · re: Stephen R. van den Berg · lore

Re: [updated2 PATCH] git-svn: Same default as cvsimport when using --use-log-author

"Stephen R. van den Berg" <srb@cuci.nl> wrote:
Show 24 quoted lines
> When using git-cvsimport, the author is inferred from the cvs commit,
> e.g. cvs commit logname is foobaruser, then the author field in git
> results in:
> 
> Author: foobaruser <foobaruser>
> 
> Which is not perfect, but perfectly acceptable given the circumstances.
> 
> The default git-svn import however, results in:
> 
> Author: foobaruser <foobaruser@acf43c95-373e-0410-b603-e72c3f656dc1>
> 
> When using mixes of imports, from CVS and SVN into the same git
> repository, you'd like to harmonise the imports to the format cvsimport
> uses.
> git-svn supports an experimental option --use-log-author which currently
> results in the same logentry as without that option when no From: or
> Signed-off-by: is found in the logentry ($email currently ends up empty,
> and hence is generated again).
> 
> This patches harmonises the result with cvsimport, and makes
> git-svn --use-log-author produce:
> 
> Author: foobaruser <foobaruser>
> Signed-off-by: Stephen R. van den Berg <srb@cuci.nl>
Thanks Stephen,
Acked-by: Eric Wong <normalperson@yhbt.net>
Show 31 quoted lines
> ---
> 
>  git-svn.perl |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> 
> diff --git a/git-svn.perl b/git-svn.perl
> index b151049..67726c1 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -2426,13 +2426,15 @@ sub make_log_entry {
>  			$name_field = $1;
>  		}
>  		if (!defined $name_field) {
> -			#
> +			if (!defined $email) {
> +				$email = $name;
> +			}
>  		} elsif ($name_field =~ /(.*?)\s+<(.*)>/) {
>  			($name, $email) = ($1, $2);
>  		} elsif ($name_field =~ /(.*)@/) {
>  			($name, $email) = ($1, $name_field);
>  		} else {
> -			($name, $email) = ($name_field, 'unknown');
> +			($name, $email) = ($name_field, $name_field);
>  		}
>  	}
>  	if (defined $headrev && $self->use_svm_props) {
> 
> 
> --

← back to recent threads