{"thread":{"id":"16148","subject":"[PATCH] git-cvsimport.perl: use human readable names for option values","startedAt":"2008-11-03T09:31:59Z","lastAt":"2008-11-03T10:32:20Z","messageCount":2,"participants":["Francis Galiegue"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"94735","messageId":"200811031031.59196.fg@one2team.net","threadId":"16148","inReplyTo":null,"subject":"[PATCH] git-cvsimport.perl: use human readable names for option values","fromName":"Francis Galiegue","fromEmail":"fg@one2team.net","sentAt":"2008-11-03T09:31:59Z","receivedAt":"2008-11-03T09:31:59Z","isPatch":true,"sender":{"key":"fg@one2team.net","avatar":null},"body":"Hello,\n\nAs I am keen to make my company use git eventually, but they have a really, \nreally messy CVS tree that git-cvs*.perl cannot handle right now, I've \ndecided to have a serious look at the code.\n\nBut if others want to have a look at the code, I think it should be made a \nlittle more readable first, hence this patch.\n\nComments? In particular, I'm thinking about the option names, maybe some are \nnot in sync with what git internal really are.\n\n---\ngit-cvsimport.perl: use human readable names for option values\n\nIt has reclaimed to rewrite the read_repo_config() function as well, but the\ngood thing is that \"no strcit 'refs'\" is gone too.\n---\n git-cvsimport.perl |  244 \n++++++++++++++++++++++++++++++++--------------------\n 1 files changed, 150 insertions(+), 94 deletions(-)\n\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex e439202..b9a552f 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -29,7 +29,51 @@ use IPC::Open2;\n $SIG{'PIPE'}=\"IGNORE\";\n $ENV{'TZ'}=\"UTC\";\n \n-our ($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,\n$opt_P, $opt_s,$opt_m,@opt_M,$opt_A,$opt_S,$opt_L, $opt_a, $opt_r);\n+#\n+# Option values\n+#\n+my $help = undef;\t\t # -h\n+my $branch_for_head = undef;\t # -o\n+my $verbose = undef;\t\t # -v\n+my $cvs_kill_keywords = undef;\t # -k\n+my $convert_underscores = undef; # -u\n+my $cvsroot = undef;\t\t # -d\n+my $cvsps_options = undef;\t # -p\n+my $git_repos_root = undef;\t # -C\n+my $cvsps_fuzz = undef;\t\t # -z\n+my $import_only = undef;\t # -i\n+my $cvsps_output_file = undef;\t # -P\n+my $branch_subst = undef,\t # -s\n+my $detect_merges = undef;\t # -m\n+my @more_merge_regexes = ();\t # -M\n+my $author_conv_file = undef;\t # -A\n+my $skip_paths = undef;\t\t # -S\n+my $commit_limits = undef;\t # -L\n+my $all_commits = undef;\t # -a\n+my $remote_path = undef;\t # -r\n+\n+my %options = (\n+\t\"h\" => \\$help,\n+\t\"o=s\" => \\$branch_for_head,\n+\t\"v\" => \\$verbose,\n+\t\"k\" => \\$cvs_kill_keywords,\n+\t\"u\" => \\$convert_underscores,\n+\t\"d=s\" => \\$cvsroot,\n+\t\"p=s\" => \\$cvsps_options,\n+\t\"C=s\" => \\$git_repos_root,\n+\t\"z=s\" => \\$cvsps_fuzz,\n+\t\"i\" => \\$import_only,\n+\t\"P=s\" => \\$cvsps_output_file,\n+\t\"s=s\" => \\$branch_subst,\n+\t\"m\" => \\$detect_merges,\n+\t\"M=s\" => \\@more_merge_regexes,\n+\t\"A=s\" => \\$author_conv_file,\n+\t\"S=s\" => \\$skip_paths,\n+\t\"L=s\" => \\$commit_limits,\n+\t\"a\" => \\$all_commits,\n+\t\"r=s\" => \\$remote_path\n+);\n+\n my (%conv_author_name, %conv_author_email);\n \n sub usage(;$) {\n@@ -88,37 +132,48 @@ sub write_author_info($) {\n \tclose ($f);\n }\n \n-# convert getopts specs for use by git config\n-sub read_repo_config {\n-    # Split the string between characters, unless there is a ':'\n-    # So \"abc:de\" becomes [\"a\", \"b\", \"c:\", \"d\", \"e\"]\n-\tmy @opts = split(/ *(?!:)/, shift);\n-\tforeach my $o (@opts) {\n-\t\tmy $key = $o;\n-\t\t$key =~ s/://g;\n-\t\tmy $arg = 'git config';\n-\t\t$arg .= ' --bool' if ($o !~ /:$/);\n-\n-        chomp(my $tmp = `$arg --get cvsimport.$key`);\n-\t\tif ($tmp && !($arg =~ /--bool/ && $tmp eq 'false')) {\n-            no strict 'refs';\n-            my $opt_name = \"opt_\" . $key;\n-            if (!$$opt_name) {\n-                $$opt_name = $tmp;\n-            }\n+sub read_repo_config ()\n+{\n+\tmy @option_keys = keys %options;\n+\n+\twhile (my ($opt, $ref) = each %options) {\n+\t\tmy $key = $opt;\n+\t\tmy $is_boolean = 0;\n+\t\tmy $cmd = \"git config\";\n+\t\tunless ($key =~ s/=s$//) {\n+\t\t\t$is_boolean = 1;\n+\t\t\t$cmd .= \" --bool\";\n+\t\t}\n+\t\t$cmd .= \" cvsimport.$key\";\n+\t\t\n+\t\tchomp(my $tmp = qx/$cmd/);\n+\t\t$tmp or next;\n+\n+\t\tif (ref($ref) eq \"ARRAY\") {\n+\t\t\t#\n+\t\t\t# FIXME: unhandled...\n+\t\t\t# However this could be handled by splitting $tmp with\n+\t\t\t# /\\s*,\\s*/ and pusing the result into @$ref (for the -M\n+\t\t\t# option)\n+\t\t\t#\n+\t\t\tnext;\n+\t\t}\n+\n+\t\tif ($is_boolean) {\n+\t\t\t$$ref = (\"$tmp\" eq \"true\") ? 1 : 0;\n+\t\t} else {\n+\t\t\t$$ref = \"$tmp\";\n \t\t}\n \t}\n }\n \n-my $opts = \"haivmkuo:d:p:r:C:z:s:M:P:A:S:L:\";\n-read_repo_config($opts);\n+\n+read_repo_config();\n Getopt::Long::Configure( 'no_ignore_case', 'bundling' );\n \n-# turn the Getopt::Std specification in a Getopt::Long one,\n-# with support for multiple -M options\n-GetOptions( map { s/:/=s/; /M/ ? \"$_\\@\" : $_ } split( /(?!:)/, $opts ) )\n-    or usage();\n-usage if $opt_h;\n+GetOptions(%options) or usage();\n+\n+usage() if $help;\n \n if (@ARGV == 0) {\n \t\tchomp(my $module = `git config --get cvsimport.module`);\n@@ -126,31 +181,32 @@ if (@ARGV == 0) {\n }\n @ARGV <= 1 or usage(\"You can't specify more than one CVS module\");\n \n-if ($opt_d) {\n-\t$ENV{\"CVSROOT\"} = $opt_d;\n+if ($cvsroot) {\n+\t$ENV{\"CVSROOT\"} = $cvsroot;\n } elsif (-f 'CVS/Root') {\n \topen my $f, '<', 'CVS/Root' or die 'Failed to open CVS/Root';\n-\t$opt_d = <$f>;\n-\tchomp $opt_d;\n+\t$cvsroot = <$f>;\n+\tchomp $cvsroot;\n \tclose $f;\n-\t$ENV{\"CVSROOT\"} = $opt_d;\n+\t$ENV{\"CVSROOT\"} = $cvsroot;\n } elsif ($ENV{\"CVSROOT\"}) {\n-\t$opt_d = $ENV{\"CVSROOT\"};\n+\t$cvsroot = $ENV{\"CVSROOT\"};\n } else {\n \tusage(\"CVSROOT needs to be set\");\n }\n-$opt_s ||= \"-\";\n-$opt_a ||= 0;\n+$branch_subst ||= \"-\";\n+$all_commits ||= 0;\n \n-my $git_tree = $opt_C;\n+my $git_tree = $git_repos_root;\n $git_tree ||= \".\";\n \n my $remote;\n-if (defined $opt_r) {\n-\t$remote = 'refs/remotes/' . $opt_r;\n-\t$opt_o ||= \"master\";\n+\n+if (defined $remote_path) {\n+\t$remote = 'refs/remotes/' . $remote_path;\n+\t$branch_for_head ||= \"master\";\n } else {\n-\t$opt_o ||= \"origin\";\n+\t$branch_for_head ||= \"origin\";\n \t$remote = 'refs/heads';\n }\n \n@@ -168,11 +224,11 @@ if ($#ARGV == 0) {\n }\n \n our @mergerx = ();\n-if ($opt_m) {\n+if ($detect_merges) {\n \t@mergerx = ( qr/\\b(?:from|of|merge|merging|merged) ([-\\w]+)/i );\n }\n-if (@opt_M) {\n-\tpush (@mergerx, map { qr/$_/ } @opt_M);\n+if (@more_merge_regexes) {\n+\tpush (@mergerx, map { qr/$_/ } @more_merge_regexes);\n }\n \n # Remember UTC of our starting time\n@@ -370,7 +426,7 @@ sub _file {\n \t$self->{'socketo'}->write(\"Argument -N\\n\") or return undef;\n \t$self->{'socketo'}->write(\"Argument -P\\n\") or return undef;\n \t# -kk: Linus' version doesn't use it - defaults to off\n-\tif ($opt_k) {\n+\tif ($cvs_kill_keywords) {\n \t    $self->{'socketo'}->write(\"Argument -kk\\n\") or return undef;\n \t}\n \t$self->{'socketo'}->write(\"Argument -r\\n\") or return undef;\n@@ -487,7 +543,7 @@ sub _fetchfile {\n \n package main;\n \n-my $cvs = CVSconn->new($opt_d, $cvs_tree);\n+my $cvs = CVSconn->new($cvsroot, $cvs_tree);\n \n \n sub pdate($) {\n@@ -565,7 +621,7 @@ unless (-d $git_dir) {\n \tsystem(\"git-read-tree\");\n \tdie \"Cannot init an empty tree: $?\\n\" if $?;\n \n-\t$last_branch = $opt_o;\n+\t$last_branch = $branch_for_head;\n \t$orig_branch = \"\";\n } else {\n \topen(F, \"git-symbolic-ref HEAD |\") or\n@@ -592,8 +648,8 @@ unless (-d $git_dir) {\n \t\t$branch_date{$head} = $1;\n \t}\n \tclose(H);\n-        if (!exists $branch_date{$opt_o}) {\n-\t\tdie \"Branch '$opt_o' does not exist.\\n\".\n+        if (!exists $branch_date{$branch_for_head}) {\n+\t\tdie \"Branch '$branch_for_head' does not exist.\\n\".\n \t\t       \"Either use the correct '-o branch' option,\\n\".\n \t\t       \"or import to a new repository.\\n\";\n         }\n@@ -605,31 +661,31 @@ unless (-d $git_dir) {\n # now we read (and possibly save) author-info as well\n -f \"$git_dir/cvs-authors\" and\n   read_author_info(\"$git_dir/cvs-authors\");\n-if ($opt_A) {\n-\tread_author_info($opt_A);\n+if ($author_conv_file) {\n+\tread_author_info($author_conv_file);\n \twrite_author_info(\"$git_dir/cvs-authors\");\n }\n \n \n #\n # run cvsps into a file unless we are getting\n-# it passed as a file via $opt_P\n+# it passed as a file via $cvsps_output_file\n #\n my $cvspsfile;\n-unless ($opt_P) {\n-\tprint \"Running cvsps...\\n\" if $opt_v;\n+unless ($cvsps_output_file) {\n+\tprint \"Running cvsps...\\n\" if $verbose;\n \tmy $pid = open(CVSPS,\"-|\");\n \tmy $cvspsfh;\n \tdie \"Cannot fork: $!\\n\" unless defined $pid;\n \tunless ($pid) {\n \t\tmy @opt;\n-\t\t@opt = split(/,/,$opt_p) if defined $opt_p;\n-\t\tunshift @opt, '-z', $opt_z if defined $opt_z;\n-\t\tunshift @opt, '-q'         unless defined $opt_v;\n-\t\tunless (defined($opt_p) && $opt_p =~ m/--no-cvs-direct/) {\n+\t\t@opt = split(/,/,$cvsps_options) if defined $cvsps_options;\n+\t\tunshift @opt, '-z', $cvsps_fuzz if defined $cvsps_fuzz;\n+\t\tunshift @opt, '-q'         unless defined $verbose;\n+\t\tunless (defined($cvsps_options) && $cvsps_options =~ m/--no-cvs-direct/) {\n \t\t\tpush @opt, '--cvs-direct';\n \t\t}\n-\t\texec(\"cvsps\",\"--norc\",@opt,\"-u\",\"-A\",'--root',$opt_d,$cvs_tree);\n+\t\texec(\"cvsps\",\"--norc\",@opt,\"-u\",\"-A\",'--root',$cvsroot,$cvs_tree);\n \t\tdie \"Could not start cvsps: $!\\n\";\n \t}\n \t($cvspsfh, $cvspsfile) = tempfile('gitXXXXXX', SUFFIX => '.cvsps',\n@@ -641,7 +697,7 @@ unless ($opt_P) {\n \t$? == 0 or die \"git-cvsimport: fatal: cvsps reported error\\n\";\n \tclose $cvspsfh;\n } else {\n-\t$cvspsfile = $opt_P;\n+\t$cvspsfile = $cvsps_output_file;\n }\n \n open(CVS, \"<$cvspsfile\") or die $!;\n@@ -688,7 +744,7 @@ sub write_tree () {\n \t\tor die \"Cannot get tree id ($tree): $!\";\n \tclose($fh)\n \t\tor die \"Error running git-write-tree: $?\\n\";\n-\tprint \"Tree ID $tree\\n\" if $opt_v;\n+\tprint \"Tree ID $tree\\n\" if $verbose;\n \treturn $tree;\n }\n \n@@ -699,7 +755,7 @@ my (@old,@new,@skipped,%ignorebranch);\n $ignorebranch{'#CVSPS_NO_BRANCH'} = 1;\n \n sub commit {\n-\tif ($branch eq $opt_o && !$index{branch} &&\n+\tif ($branch eq $branch_for_head && !$index{branch} &&\n \t\t!get_headref(\"$remote/$branch\")) {\n \t    # looks like an initial commit\n \t    # use the index primed by git-init\n@@ -725,7 +781,7 @@ sub commit {\n \t@old = @new = ();\n \tmy $tree = write_tree();\n \tmy $parent = get_headref(\"$remote/$last_branch\");\n-\tprint \"Parent ID \" . ($parent ? $parent : \"(empty)\") . \"\\n\" if $opt_v;\n+\tprint \"Parent ID \" . ($parent ? $parent : \"(empty)\") . \"\\n\" if $verbose;\n \n \tmy @commit_args;\n \tpush @commit_args, (\"-p\", $parent) if $parent;\n@@ -734,10 +790,10 @@ sub commit {\n \t# based on the commit msg\n \tforeach my $rx (@mergerx) {\n \t\tnext unless $logmsg =~ $rx && $1;\n-\t\tmy $mparent = $1 eq 'HEAD' ? $opt_o : $1;\n+\t\tmy $mparent = $1 eq 'HEAD' ? $branch_for_head : $1;\n \t\tif (my $sha1 = get_headref(\"$remote/$mparent\")) {\n \t\t\tpush @commit_args, '-p', \"$remote/$mparent\";\n-\t\t\tprint \"Merge parent branch: $mparent\\n\" if $opt_v;\n+\t\t\tprint \"Merge parent branch: $mparent\\n\" if $verbose;\n \t\t}\n \t}\n \n@@ -764,10 +820,10 @@ sub commit {\n \tprint($commit_write \"$logmsg\\n\") && close($commit_write)\n \t\tor die \"Error writing to git-commit-tree: $!\\n\";\n \n-\tprint \"Committed patch $patchset ($branch $commit_date)\\n\" if $opt_v;\n+\tprint \"Committed patch $patchset ($branch $commit_date)\\n\" if $verbose;\n \tchomp(my $cid = <$commit_read>);\n \tis_sha1($cid) or die \"Cannot get commit id ($cid): $!\\n\";\n-\tprint \"Commit ID $cid\\n\" if $opt_v;\n+\tprint \"Commit ID $cid\\n\" if $verbose;\n \tclose($commit_read);\n \n \twaitpid($pid,0);\n@@ -779,14 +835,14 @@ sub commit {\n \tif ($tag) {\n \t        my ($xtag) = $tag;\n \t\t$xtag =~ s/\\s+\\*\\*.*$//; # Remove stuff like ** INVALID ** and ** FUNKY **\n-\t\t$xtag =~ tr/_/\\./ if ( $opt_u );\n-\t\t$xtag =~ s/[\\/]/$opt_s/g;\n+\t\t$xtag =~ tr/_/\\./ if ( $convert_underscores );\n+\t\t$xtag =~ s/[\\/]/$branch_subst/g;\n \t\t$xtag =~ s/\\[//g;\n \n \t\tsystem('git-tag', '-f', $xtag, $cid) == 0\n \t\t\tor die \"Cannot create tag $xtag: $!\\n\";\n \n-\t\tprint \"Created tag '$xtag' on '$branch'\\n\" if $opt_v;\n+\t\tprint \"Created tag '$xtag' on '$branch'\\n\" if $verbose;\n \t}\n };\n \n@@ -822,14 +878,14 @@ while (<CVS>) {\n \t\t$state = 4;\n \t} elsif ($state == 4 and s/^Branch:\\s+//) {\n \t\ts/\\s+$//;\n-\t\ttr/_/\\./ if ( $opt_u );\n-\t\ts/[\\/]/$opt_s/g;\n+\t\ttr/_/\\./ if ( $convert_underscores );\n+\t\ts/[\\/]/$branch_subst/g;\n \t\t$branch = $_;\n \t\t$state = 5;\n \t} elsif ($state == 5 and s/^Ancestor branch:\\s+//) {\n \t\ts/\\s+$//;\n \t\t$ancestor = $_;\n-\t\t$ancestor = $opt_o if $ancestor eq \"HEAD\";\n+\t\t$ancestor = $branch_for_head if $ancestor eq \"HEAD\";\n \t\t$state = 6;\n \t} elsif ($state == 5) {\n \t\t$ancestor = undef;\n@@ -847,19 +903,19 @@ while (<CVS>) {\n \t\t$logmsg = \"\";\n \t\t$state = 8;\n \t} elsif ($state == 8 and /^Members:/) {\n-\t\t$branch = $opt_o if $branch eq \"HEAD\";\n+\t\t$branch = $branch_for_head if $branch eq \"HEAD\";\n \t\tif (defined $branch_date{$branch} and $branch_date{$branch} >= $date) {\n \t\t\t# skip\n-\t\t\tprint \"skip patchset $patchset: $date before $branch_date{$branch}\\n\" if \n$opt_v;\n+\t\t\tprint \"skip patchset $patchset: $date before $branch_date{$branch}\\n\" if \n$verbose;\n \t\t\t$state = 11;\n \t\t\tnext;\n \t\t}\n-\t\tif (!$opt_a && $starttime - 300 - (defined $opt_z ? $opt_z : 300) <= $date) \n{\n+\t\tif (!$all_commits && $starttime - 300 - (defined $cvsps_fuzz ? \n$cvsps_fuzz : 300) <= $date) {\n \t\t\t# skip if the commit is too recent\n \t\t\t# given that the cvsps default fuzz is 300s, we give ourselves another\n \t\t\t# 300s just in case -- this also prevents skipping commits\n \t\t\t# due to server clock drift\n-\t\t\tprint \"skip patchset $patchset: $date too recent\\n\" if $opt_v;\n+\t\t\tprint \"skip patchset $patchset: $date too recent\\n\" if $verbose;\n \t\t\t$state = 11;\n \t\t\tnext;\n \t\t}\n@@ -870,8 +926,8 @@ while (<CVS>) {\n \t\t}\n \t\tif ($ancestor) {\n \t\t\tif ($ancestor eq $branch) {\n-\t\t\t\tprint STDERR \"Branch $branch erroneously stems from itself -- changed \nancestor to $opt_o\\n\";\n-\t\t\t\t$ancestor = $opt_o;\n+\t\t\t\tprint STDERR \"Branch $branch erroneously stems from itself -- changed \nancestor to $branch_for_head\\n\";\n+\t\t\t\t$ancestor = $branch_for_head;\n \t\t\t}\n \t\t\tif (defined get_headref(\"$remote/$branch\")) {\n \t\t\t\tprint STDERR \"Branch $branch already exists!\\n\";\n@@ -905,18 +961,18 @@ while (<CVS>) {\n \t\tmy $fn = $1;\n \t\tmy $rev = $3;\n \t\t$fn =~ s#^/+##;\n-\t\tif ($opt_S && $fn =~ m/$opt_S/) {\n+\t\tif ($skip_paths && $fn =~ m/$skip_paths/) {\n \t\t    print \"SKIPPING $fn v $rev\\n\";\n \t\t    push(@skipped, $fn);\n \t\t    next;\n \t\t}\n-\t\tprint \"Fetching $fn   v $rev\\n\" if $opt_v;\n+\t\tprint \"Fetching $fn   v $rev\\n\" if $verbose;\n \t\tmy ($tmpname, $size) = $cvs->file($fn,$rev);\n \t\tif ($size == -1) {\n \t\t\tpush(@old,$fn);\n-\t\t\tprint \"Drop $fn\\n\" if $opt_v;\n+\t\t\tprint \"Drop $fn\\n\" if $verbose;\n \t\t} else {\n-\t\t\tprint \"\".($init ? \"New\" : \"Update\").\" $fn: $size bytes\\n\" if $opt_v;\n+\t\t\tprint \"\".($init ? \"New\" : \"Update\").\" $fn: $size bytes\\n\" if $verbose;\n \t\t\tmy $pid = open(my $F, '-|');\n \t\t\tdie $! unless defined $pid;\n \t\t\tif (!$pid) {\n@@ -934,12 +990,12 @@ while (<CVS>) {\n \t\tmy $fn = $1;\n \t\t$fn =~ s#^/+##;\n \t\tpush(@old,$fn);\n-\t\tprint \"Delete $fn\\n\" if $opt_v;\n+\t\tprint \"Delete $fn\\n\" if $verbose;\n \t} elsif ($state == 9 and /^\\s*$/) {\n \t\t$state = 10;\n \t} elsif (($state == 9 or $state == 10) and /^-+$/) {\n \t\t$commitcount++;\n-\t\tif ($opt_L && $commitcount > $opt_L) {\n+\t\tif ($commit_limits && $commitcount > $commit_limits) {\n \t\t\tlast;\n \t\t}\n \t\tcommit();\n@@ -957,7 +1013,7 @@ while (<CVS>) {\n }\n commit() if $branch and $state != 11;\n \n-unless ($opt_P) {\n+unless ($cvsps_output_file) {\n \tunlink($cvspsfile);\n }\n \n@@ -985,31 +1041,31 @@ if (defined $orig_git_index) {\n \n # Now switch back to the branch we were in before all of this happened\n if ($orig_branch) {\n-\tprint \"DONE.\\n\" if $opt_v;\n-\tif ($opt_i) {\n+\tprint \"DONE.\\n\" if $verbose;\n+\tif ($import_only) {\n \t\texit 0;\n \t}\n \tmy $tip_at_end = `git-rev-parse --verify HEAD`;\n \tif ($tip_at_start ne $tip_at_end) {\n \t\tfor ($tip_at_start, $tip_at_end) { chomp; }\n-\t\tprint \"Fetched into the current branch.\\n\" if $opt_v;\n+\t\tprint \"Fetched into the current branch.\\n\" if $verbose;\n \t\tsystem(qw(git-read-tree -u -m),\n \t\t       $tip_at_start, $tip_at_end);\n \t\tdie \"Fast-forward update failed: $?\\n\" if $?;\n \t}\n \telse {\n-\t\tsystem(qw(git-merge cvsimport HEAD), \"$remote/$opt_o\");\n-\t\tdie \"Could not merge $opt_o into the current branch.\\n\" if $?;\n+\t\tsystem(qw(git-merge cvsimport HEAD), \"$remote/$branch_for_head\");\n+\t\tdie \"Could not merge $branch_for_head into the current branch.\\n\" if $?;\n \t}\n } else {\n \t$orig_branch = \"master\";\n-\tprint \"DONE; creating $orig_branch branch\\n\" if $opt_v;\n-\tsystem(\"git-update-ref\", \"refs/heads/master\", \"$remote/$opt_o\")\n+\tprint \"DONE; creating $orig_branch branch\\n\" if $verbose;\n+\tsystem(\"git-update-ref\", \"refs/heads/master\", \"$remote/$branch_for_head\")\n \t\tunless defined get_headref('refs/heads/master');\n-\tsystem(\"git-symbolic-ref\", \"$remote/HEAD\", \"$remote/$opt_o\")\n-\t\tif ($opt_r && $opt_o ne 'HEAD');\n+\tsystem(\"git-symbolic-ref\", \"$remote/HEAD\", \"$remote/$branch_for_head\")\n+\t\tif ($remote_path && $branch_for_head ne 'HEAD');\n \tsystem('git-update-ref', 'HEAD', \"$orig_branch\");\n-\tunless ($opt_i) {\n+\tunless ($import_only) {\n \t\tsystem('git checkout -f');\n \t\tdie \"checkout failed: $?\\n\" if $?;\n \t}\n\n-- \nfge\n"},{"id":"94746","messageId":"200811031132.20590.fg@one2team.com","threadId":"16148","inReplyTo":"200811031031.59196.fg@one2team.net","subject":"Re: [PATCH] git-cvsimport.perl: use human readable names for option values","fromName":"Francis Galiegue","fromEmail":"fg@one2team.com","sentAt":"2008-11-03T10:32:20Z","receivedAt":"2008-11-03T10:32:20Z","isPatch":true,"sender":{"key":"fg@one2team.com","avatar":null},"body":"Le Monday 03 November 2008 10:31:59 Francis Galiegue, vous avez écrit :\n> Hello,\n>\n> As I am keen to make my company use git eventually, but they have a really,\n> really messy CVS tree that git-cvs*.perl cannot handle right now, I've\n> decided to have a serious look at the code.\n>\n\nAs stated in one mail I sent earlier on, the real problem is that \ngit-cvsimport won't detect empty branches for two reasons:\n\n* it relies on cvsps output, which doesn't tell about it either;\n* however, it doesn't make use of another file that cvsps generates in \n$HOME/.cvsps by default, which can help about giving this information.\n\nI'll try the following:\n\n* instead of capturing cvsps output directly, I'll use its -p option, which \nhas the advantage of generating one file per patchset;\n* I'll consolidate the information of the other generated file in a hash and \ncorrelate the information found in there with the individual patchset: my \nhope is that I'll be able to detect so-far undetected branches and create \nthem.\n\n-- \nFrancis Galiegue\nONE2TEAM\nIngénieur système\nMob : +33 (0) 6 83 87 78 75\nTel : +33 (0) 1 78 94 55 52\nfge@one2team.com\n40 avenue Raymond Poincaré\n75116 Paris\n"}]}