]> git.ipfire.org Git - thirdparty/git.git/blobdiff - git-cvsimport.perl
Fix an "implicit function definition" warning.
[thirdparty/git.git] / git-cvsimport.perl
index 1018f4f6fa42c16a11930283f8ddf2c2f87642d3..1a1ba7b1a6f779773702ae3c1efb56425c31beb4 100755 (executable)
@@ -85,7 +85,35 @@ sub write_author_info($) {
        close ($f);
 }
 
-getopts("hivmkuo:d:p:C:z:s:M:P:A:S:L:") or usage();
+# convert getopts specs for use by git-repo-config
+sub read_repo_config {
+    # Split the string between characters, unless there is a ':'
+    # So "abc:de" becomes ["a", "b", "c:", "d", "e"]
+       my @opts = split(/ *(?!:)/, shift);
+       foreach my $o (@opts) {
+               my $key = $o;
+               $key =~ s/://g;
+               my $arg = 'git-repo-config';
+               $arg .= ' --bool' if ($o !~ /:$/);
+
+        chomp(my $tmp = `$arg --get cvsimport.$key`);
+               if ($tmp && !($arg =~ /--bool/ && $tmp eq 'false')) {
+            no strict 'refs';
+            my $opt_name = "opt_" . $key;
+            if (!$$opt_name) {
+                $$opt_name = $tmp;
+            }
+               }
+       }
+    if (@ARGV == 0) {
+        chomp(my $module = `git-repo-config --get cvsimport.module`);
+        push(@ARGV, $module);
+    }
+}
+
+my $opts = "haivmkuo:d:p:C:z:s:M:P:A:S:L:";
+read_repo_config($opts);
+getopts($opts) or usage();
 usage if $opt_h;
 
 @ARGV <= 1 or usage();
@@ -520,7 +548,7 @@ $orig_git_index = $ENV{GIT_INDEX_FILE} if exists $ENV{GIT_INDEX_FILE};
 my %index; # holds filenames of one index per branch
 
 unless (-d $git_dir) {
-       system("git-init-db");
+       system("git-init");
        die "Cannot init the GIT db at $git_tree: $?\n" if $?;
        system("git-read-tree");
        die "Cannot init an empty tree: $?\n" if $?;
@@ -660,7 +688,7 @@ $ignorebranch{'#CVSPS_NO_BRANCH'} = 1;
 sub commit {
        if ($branch eq $opt_o && !$index{branch} && !get_headref($branch, $git_dir)) {
            # looks like an initial commit
-           # use the index primed by git-init-db
+           # use the index primed by git-init
            $ENV{GIT_INDEX_FILE} = '.git/index';
            $index{$branch} = '.git/index';
        } else {