git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nazar Aziz" <mcnazar@gmail.com>
To: git@vger.kernel.org
Cc: mcnazar@gmail.com
Subject: git-svn dcommit fails in a repository with submodules
Date: Sun, 16 Mar 2008 10:50:22 +0000	[thread overview]
Message-ID: <60dc6b330803160350o3481b7b5vee1795919101cce2@mail.gmail.com> (raw)

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

                 reply	other threads:[~2008-03-16 10:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=60dc6b330803160350o3481b7b5vee1795919101cce2@mail.gmail.com \
    --to=mcnazar@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).