git-svn dcommit fails in a repository with submodules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all.

I am struggling with a git repository which I sync with an SVN repos
using git-svn. git-svn dcommit fails with (dump from git-svn 1.5.4.1):

Committing to svn://epia/tmp/Trunc ...
         A       modules/akismet
fatal: git-cat-file 5f726f311613171310226d9bf040765
6ad4a82f4: bad file
 at /usr/bin/git-svn line 3537
        SVN::Git::Editor::chg_file('SVN::Git::Editor=HASH(0xd0c26c)',
'_p_void=SCALAR(0x9aee60)', 'HASH(0x9af340)') called at
/usr/bin/git-svn line 3461
         SVN::Git::Editor::A('SVN::Git::Editor=HASH(0xd0c26c)',
'HASH(0x9af340)') called at /usr/bin/git-svn line 3592
        SVN::Git::Editor::apply_diff('SVN::Git::Editor=HASH(0xd0c26c)')
called at /usr/bin/git-svn line 450
         main::cmd_dcommit() called at /usr/bin/git-svn line 246
        eval {...} called at /usr/bin/git-svn line 244
32768 at /usr/bin/git-svn line 450

Just to explain my setup. I've got an application that has shared
code. This shared code was previously accessed in SVN via an
svn:externals which pointed to a separate "shared code" svn
repository. This setup allowed me to share this code in several apps
whilst also giving me the ability to modify this shared code in any
single application and commit it to the "shared code" repos for use in
my other applications.

I've written an article on it here:
http://panthersoftware.com/articles/view/3/svn-s-svn-externals-to-git-s-submodule-for-rails-plugins

I've tried hacking git-svn but my Perl fu is weak. So I would
appreciate any pointers to help me solve this.

I've done the following hack:

sub valid_object {
  #check if git-cat can process this sha1..if not then return false
   my ($self, $sha1) = @_;
    my $fh = IO::File->new_tmpfile or croak $!;
    defined(my $pid = fork) or croak $!;
    if (!$pid) {
        open STDOUT, '>&', $fh or croak $!;
        exec qw/git-cat-file blob/, $sha1 or croak $!;
     }
    waitpid $pid, 0;
    if ($?) {
     return 0;
    } else {
      return 1;
    }
}

sub A {
    my ($self, $m) = @_;
    if ($self->valid_object($m->{sha1_b}) == 1) {
      my ($dir, $file) = split_path($m->{file_b});
       my $pbat = $self->ensure_path($dir);
      my $fbat = $self->add_file($self->repo_path($m->{file_b}), $pbat,
                    undef, -1);
      print "\tA\t$m->{file_b}\n" unless $::_q;
       $self->chg_file($fbat, $m);
      $self->close_file($fbat,undef,$self->{pool});
    }
}

I added sub valid_object to package SVN::Git::Editor. It is a brute
method to see if git-cat-file will choke on a particular sha1. I am
certain there is a more elegant method to check if a sha1 is actually
a submodule... I just haven't found it yet.

The above almost works but not quite:

$ git-svn2 dcommit
Committing to svn://epia/tmp/Trunc ...
fatal: git-cat-file 5f726f311613171310226d9bf0407656ad4a82f4: bad file
Committed r24
W: ea1efb48fb6e03454f9264dd63cd609884c4f780 and refs/remotes/git-svn
differ, using rebase:
 :040000 040000 2bd02aa0d14fd5e16f90d8b9c5322cc101d7f026
36fbd5e7d921cd5fabe32fe857455f7fec26f521 M      modules
Current branch master is up to date.
# of revisions changed
before:


after:
 ea1efb48fb6e03454f9264dd63cd609884c4f780
  If you are attempting to commit  merges, try running:
         git rebase --interactive --preserve-merges  refs/remotes/git-svn
Before dcommitting

"fatal: git-cat-file 5f726f311613171310226d9bf0407656ad4a82f4: bad
file" comes from sub valid_object and is for info only. I can see that
git-svn has bypassed the submodule as I was hoping.

Checking SVN's log I can see an empty commit (ie no files have been
uploaded). In Git, my Master branch is still ahead of of the
remotes/git-svn branch (ie not in synch with remotes/git-svn)

>From the above, I can see that I am so almost there... but just need
one final push to get me to the finishing line.

Is there anyway I can tell git-svn to ignore submodules?

Any hints, tips or help would be greatly appreciated.

Thank you in advance for any help.

Nazar
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux