tags 472873 + upstream
severity 472873 wishlist
thanks

Hi,

Teemu Ikonen wrote:

> git-cvsimport should respect the --bare option when doing an initial import
> to a new repository and it should detect if a repository is bare when doing
> an update. Currently, when run with the -C option pointing to a bare
> repository, git-cvsimport creates a new gitdir under the old repository,
> like this:
> 
> Initialized empty Git repository in <...>/bare.git/.git/

Thanks for the report.  Here’s a hint to a patch.  Details left to the
reader. ;-)

-- %< --
Subject: cvsimport: Allow bare repository

As the comments labelled NEEDSWORK suggest, there is still work to do
before this is safe to use.

Reported-by: Teemu Ikonen <tpiko...@gmail.com>
Helped-by: Joshua Kwan <jo...@triplehelix.org>
Signed-off-by: Jonathan Nieder <jrnie...@gmail.com>
---
 git-cvsimport.perl |   33 +++++++++++++++++++++++++++------
 1 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 9e03eee..bcfb65e 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -142,8 +142,24 @@ if ($opt_d) {
 $opt_s ||= "-";
 $opt_a ||= 0;
 
+sub set_git_dir {
+       my $git_dir = `git rev-parse --git-dir 2>/dev/null`;
+       if ($? != 0) {
+               return;
+       }
+       if (`git rev-parse --show-cdup` eq "") {
+               print STDERR "You need to run this command from the toplevel of 
the working tree.";
+               exit 1;
+       }
+       $ENV{"GIT_DIR"} = $git_dir;
+}
+
 my $git_tree = $opt_C;
-$git_tree ||= ".";
+my $git_dir;
+if (!defined($git_tree)) {
+       set_git_dir();
+       $git_dir = $ENV{"GIT_DIR"};
+}
 
 my $remote;
 if (defined $opt_r) {
@@ -587,12 +603,14 @@ sub munge_user_filename {
                $user_filename_prepend . $name;
 }
 
--d $git_tree
-       or mkdir($git_tree,0777)
-       or die "Could not create $git_tree: $!";
-if ($git_tree ne '.') {
+if (defined($git_tree)) {
+       -d $git_tree
+               or mkdir($git_tree,0777)
+               or die "Could not create $git_tree: $!";
        $user_filename_prepend = getwd() . '/';
        chdir($git_tree);
+} else {
+       $git_tree = ".";
 }
 
 my $last_branch = "";
@@ -600,7 +618,7 @@ my $orig_branch = "";
 my %branch_date;
 my $tip_at_start = undef;
 
-my $git_dir = $ENV{"GIT_DIR"} || ".git";
+$git_dir ||= ".git";
 $git_dir = getwd()."/".$git_dir unless $git_dir =~ m#^/#;
 $ENV{"GIT_DIR"} = $git_dir;
 my $orig_git_index;
@@ -1055,11 +1073,13 @@ if ($orig_branch) {
        if ($tip_at_start ne $tip_at_end) {
                for ($tip_at_start, $tip_at_end) { chomp; }
                print "Fetched into the current branch.\n" if $opt_v;
+               # NEEDSWORK. What about bare repositories?
                system(qw(git read-tree -u -m),
                       $tip_at_start, $tip_at_end);
                die "Fast-forward update failed: $?\n" if $?;
        }
        else {
+               # NEEDSWORK. What about bare repositories?
                system(qw(git merge cvsimport HEAD), "$remote/$opt_o");
                die "Could not merge $opt_o into the current branch.\n" if $?;
        }
@@ -1072,6 +1092,7 @@ if ($orig_branch) {
                if ($opt_r && $opt_o ne 'HEAD');
        system('git', 'update-ref', 'HEAD', "$orig_branch");
        unless ($opt_i) {
+               # NEEDSWORK. What about bare repositories?
                system(qw(git checkout -f));
                die "checkout failed: $?\n" if $?;
        }
-- 
1.7.0




-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to