git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] Save username -> Full Name <email@addr.es> map file

From
Karl Hasselström <kha@treskal.com>
Date
Feb 27, 2006, 23:08 UTC
Message-ID
<20060227230817.12298.79184.stgit@backpacker.hemma.treskal.com>
In-Reply-To
<440195D4.7080905@op5.se>

When the user specifies a username -> Full Name <email@addr.es> map file with the -A option, save a copy of that file as $git_dir/svn-authors. When running git-svnimport with an existing GIT directory, use $git_dir/svn-authors (if it exists) unless a file was explicitly specified with -A.

Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 Documentation/git-svnimport.txt |    5 +++++
 git-svnimport.perl              |   25 ++++++++++++++++++++-----
 2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/Documentation/git-svnimport.txt b/Documentation/git-svnimport.txt
index 912a808..a158813 100644
--- a/Documentation/git-svnimport.txt
+++ b/Documentation/git-svnimport.txt
@@ -82,6 +82,11 @@ When importing incrementally, you might 
 	"username". If encountering a commit made by a user not in the
 	list, abort.
 
+	For convenience, this data is saved to $GIT_DIR/svn-authors
+	each time the -A option is provided, and read from that same
+	file each time git-svnimport is run with an existing GIT
+	repository without -A.
+
 -m::
 	Attempt to detect merges based on the commit message. This option
 	will enable default regexes that try to capture the name source
diff --git a/git-svnimport.perl b/git-svnimport.perl
index 86837ed..639aa41 100755
--- a/git-svnimport.perl
+++ b/git-svnimport.perl
@@ -13,6 +13,7 @@
 use strict;
 use warnings;
 use Getopt::Std;
+use File::Copy;
 use File::Spec;
 use File::Temp qw(tempfile);
 use File::Path qw(mkpath);
@@ -68,10 +69,16 @@ if ($opt_M) {
 	push (@mergerx, qr/$opt_M/);
 }
 
+# Absolutize filename now, since we will have chdir'ed by the time we
+# get around to opening it.
+$opt_A = File::Spec->rel2abs($opt_A) if $opt_A;
+
 our %users = ();
-if ($opt_A) {
-	die "Cannot open $opt_A\n" unless -f $opt_A;
-	open(my $authors,$opt_A);
+our $users_file = undef;
+sub read_users($) {
+	$users_file = File::Spec->rel2abs(@_);
+	die "Cannot open $users_file\n" unless -f $users_file;
+	open(my $authors,$users_file);
 	while(<$authors>) {
 		chomp;
 		next unless /^(\S+?)\s*=\s*(.+?)\s*<(.+)>\s*$/;
@@ -302,6 +309,14 @@ EOM
 -d $git_dir
 	or die "Could not create git subdir ($git_dir).\n";
 
+my $default_authors = "$git_dir/svn-authors";
+if ($opt_A) {
+	read_users($opt_A);
+	copy($opt_A,$default_authors) or die "Copy failed: $!";
+} else {
+	read_users($default_authors) if -f $default_authors;
+}
+
 open BRANCHES,">>", "$git_dir/svn2git";
 
 sub node_kind($$$) {
@@ -498,8 +513,8 @@ sub commit {
 
 	if (not defined $author) {
 		$author_name = $author_email = "unknown";
-	} elsif ($opt_A) {
-		die "User $author is not listed in $opt_A\n"
+	} elsif (defined $users_file) {
+		die "User $author is not listed in $users_file\n"
 		    unless exists $users{$author};
 		($author_name,$author_email) = @{$users{$author}};
 	} elsif ($author =~ /^(.*?)\s+<(.*)>$/) {
Previous: Karl Hasselström
Message 12 of 12 in “some git-svnimport improvements”
  1. 0/4 some git-svnimport improvementsKarl Hasselström, Feb 26, 2006
  2. 1/4 Mention -r in usage summaryKarl Hasselström, Feb 26, 2006
  3. 2/4 Convert executable flagKarl Hasselström, Feb 26, 2006
  4. 3/4 Convert the svn:ignore propertyKarl Hasselström, Feb 26, 2006
  5. 4/4 Read author names and emails from a fileKarl Hasselström, Feb 26, 2006
  6. Andreas EricssonFeb 26, 2006
  7. Junio C HamanoFeb 27, 2006
  8. Karl HasselströmFeb 27, 2006
  9. 1/2 Let git-svnimport's author file use same syntax as git-cvsimport'sKarl Hasselström, Feb 27, 2006
  10. Jon LoeligerMar 1, 2006
  11. Karl HasselströmMar 2, 2006
  12. 2/2 Save username -> Full Name <email@addr.es> map fileKarl Hasselström, Feb 27, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.