git-svn: File was not found in commit

8 messages, 3 authors, 2016-06-15 · open the first message on its own page

git-svn: File was not found in commit

From: Morgan Christiansson <hidden>
Date: 2016-06-15 22:45:55

Hi, i'm trying to "git svn fetch" my repository from a local file:///
repo and i'm running into this problem:

$ git svn init -t tags -b branches -T trunk file:///path/to/svn/repo
$ git svn fetch
branches/rails/rails/vendor/plugins/acts_as_xapian/.git/refs/heads/master
was not found in commit a643e882c557593f36bb9fd0966490010b9dba61 (r10576)


I found another report that seems to describe the same error:
http://marc.info/?l=git&m=121537767308135&w=2
Investigating the the history it's committed in r10577 and it's looking
for it in r10576, so it seems to be off by one revision number. Exactly
like the other report.
I've tried the latest git version of git-svn.perl and the problem is not
fixed there.


$ svn log file:///path/to/repo -r10576:10577 -v
------------------------------------------------------------------------
r10576 | morgan | 2008-11-28 14:35:53 +0000 (Fri, 28 Nov 2008) | 3 lines
Changed paths:
   A /branches/rails/rails/app/controllers/browse_sheetmusic_controller.rb
   M /branches/rails/rails/app/controllers/scores_controller.rb
   M /branches/rails/rails/app/models/composer.rb
   M /branches/rails/rails/app/models/score.rb
   M /branches/rails/rails/config/routes.rb

Commit message.

------------------------------------------------------------------------
r10577 | morgan | 2008-11-28 18:31:00 +0000 (Fri, 28 Nov 2008) | 3 lines
Changed paths:
   A /branches/rails/rails/vendor/plugins/acts_as_xapian/.git/FETCH_HEAD
   M /branches/rails/rails/vendor/plugins/acts_as_xapian/.git/config
   M /branches/rails/rails/vendor/plugins/acts_as_xapian/.git/index
   M /branches/rails/rails/vendor/plugins/acts_as_xapian/.git/logs/HEAD
   M
/branches/rails/rails/vendor/plugins/acts_as_xapian/.git/logs/refs/heads/master 

# <-- THIS FILE
   M
/branches/rails/rails/vendor/plugins/acts_as_xapian/.git/logs/refs/remotes/origin/HEAD
   M
/branches/rails/rails/vendor/plugins/acts_as_xapian/.git/logs/refs/remotes/origin/master
   A
/branches/rails/rails/vendor/plugins/acts_as_xapian/.git/objects/pack/pack-41ebdff27c581340ac7a71850e2e3a7d1cfea138.idx
   A
/branches/rails/rails/vendor/plugins/acts_as_xapian/.git/objects/pack/pack-41ebdff27c581340ac7a71850e2e3a7d1cfea138.pack
   M
/branches/rails/rails/vendor/plugins/acts_as_xapian/.git/refs/heads/master
   M
/branches/rails/rails/vendor/plugins/acts_as_xapian/.git/refs/remotes/origin/master
   A /branches/rails/rails/vendor/plugins/acts_as_xapian/README.textile
   M
/branches/rails/rails/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb

Switched repo to git://github.com/Overbryd/acts_as_xapian.git

------------------------------------------------------------------------




I did some digging in the perl script and managed to generate this stack
trace, it shows that gs_do_update is called with $rev_a=10576 and
$rev_b=10577, the file is in $rev_b but it complains it's not found in
$rev_a.

SVN::Git::Fetcher::open_file('SVN::Git::Fetcher=HASH(0x25faf38)',
'branches/rails/rails/vendor/plugins/acts_as_xapian/.git/refs/heads/master', 

'HASH(0x25fdb00)', 10576, '_p_apr_pool_t=SCALAR(0x24f8978)') called at
/usr/lib/perl5/SVN/Ra.pm line 623
SVN::Ra::Reporter::AUTOLOAD('SVN::Ra::Reporter=ARRAY(0x24f8948)',
'SVN::Pool=REF(0x24f8528)') called at ../git-svn.perl line 4087
Git::SVN::Ra::gs_do_update('Git::SVN::Ra=HASH(0x24beac8)', 10576, 10577,
'Git::SVN=HASH(0x24f7d18)', 'SVN::Git::Fetcher=HASH(0x25faf38)') called
at ../git-svn.perl line 2481
Git::SVN::do_fetch('Git::SVN=HASH(0x24f7d18)', 'HASH(0x24c01f0)', 10577)
called at ../git-svn.perl line 4227
Git::SVN::Ra::gs_fetch_loop_common('Git::SVN::Ra=HASH(0x24beac8)',
10575, 10724, 'ARRAY(0x1da1c20)', 'ARRAY(0x1da1c50)') called at
../git-svn.perl line 1506
Git::SVN::fetch_all('svn', 'HASH(0x21d6440)') called at ../git-svn.perl
line 387
main::cmd_fetch at ../git-svn.perl line 268
eval {...} at ../git-svn.perl line 266
branches/rails/rails/vendor/plugins/acts_as_xapian/.git/refs/heads/master
was not found in commit a643e882c557593f36bb9fd0966490010b9dba61
(r10576) at ../git-svn.perl line 3271.


I'm not sure whether this is correct behavior or not and I'm not
familiar with SVN::Ra::Reporter... so some help would be appreciated.

Thanks,
Morgan

Re: git-svn: File was not found in commit

From: Morgan Christiansson <hidden>
Date: 2016-06-15 22:45:55

Bump. Can anyone give any pointers or ideas for workarounds on this?

Searching the list archives i have found 2 others reporting similair 
problems with git-svn, both which were left unreplied:
http://marc.info/?t=122118776000001&r=1&w=2
http://marc.info/?t=121537770800003&r=1&w=2

I'm stuck at this point - if i can't migrate this repository i cannot 
use git for my work.

Morgan Christiansson wrote:
Hi, i'm trying to "git svn fetch" my repository from a local file:///
repo and i'm running into this problem:

$ git svn init -t tags -b branches -T trunk file:///path/to/svn/repo
$ git svn fetch
branches/rails/rails/vendor/plugins/acts_as_xapian/.git/refs/heads/master
was not found in commit a643e882c557593f36bb9fd0966490010b9dba61 (r10576)


I found another report that seems to describe the same error:
http://marc.info/?l=git&m=121537767308135&w=2
Investigating the the history it's committed in r10577 and it's looking
for it in r10576, so it seems to be off by one revision number. Exactly
like the other report.
I've tried the latest git version of git-svn.perl and the problem is not
fixed there.


$ svn log file:///path/to/repo -r10576:10577 -v
------------------------------------------------------------------------
r10576 | morgan | 2008-11-28 14:35:53 +0000 (Fri, 28 Nov 2008) | 3 lines
Changed paths:
  A /branches/rails/rails/app/controllers/browse_sheetmusic_controller.rb
  M /branches/rails/rails/app/controllers/scores_controller.rb
  M /branches/rails/rails/app/models/composer.rb
  M /branches/rails/rails/app/models/score.rb
  M /branches/rails/rails/config/routes.rb

Commit message.

------------------------------------------------------------------------
r10577 | morgan | 2008-11-28 18:31:00 +0000 (Fri, 28 Nov 2008) | 3 lines
Changed paths:
  A /branches/rails/rails/vendor/plugins/acts_as_xapian/.git/FETCH_HEAD
  M /branches/rails/rails/vendor/plugins/acts_as_xapian/.git/config
  M /branches/rails/rails/vendor/plugins/acts_as_xapian/.git/index
  M /branches/rails/rails/vendor/plugins/acts_as_xapian/.git/logs/HEAD
  M
/branches/rails/rails/vendor/plugins/acts_as_xapian/.git/logs/refs/heads/master 

# <-- THIS FILE
  M
/branches/rails/rails/vendor/plugins/acts_as_xapian/.git/logs/refs/remotes/origin/HEAD 

  M
/branches/rails/rails/vendor/plugins/acts_as_xapian/.git/logs/refs/remotes/origin/master 

  A
/branches/rails/rails/vendor/plugins/acts_as_xapian/.git/objects/pack/pack-41ebdff27c581340ac7a71850e2e3a7d1cfea138.idx 

  A
/branches/rails/rails/vendor/plugins/acts_as_xapian/.git/objects/pack/pack-41ebdff27c581340ac7a71850e2e3a7d1cfea138.pack 

  M
/branches/rails/rails/vendor/plugins/acts_as_xapian/.git/refs/heads/master 

  M
/branches/rails/rails/vendor/plugins/acts_as_xapian/.git/refs/remotes/origin/master 

  A /branches/rails/rails/vendor/plugins/acts_as_xapian/README.textile
  M
/branches/rails/rails/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb

Switched repo to git://github.com/Overbryd/acts_as_xapian.git

------------------------------------------------------------------------




I did some digging in the perl script and managed to generate this stack
trace, it shows that gs_do_update is called with $rev_a=10576 and
$rev_b=10577, the file is in $rev_b but it complains it's not found in
$rev_a.

SVN::Git::Fetcher::open_file('SVN::Git::Fetcher=HASH(0x25faf38)',
'branches/rails/rails/vendor/plugins/acts_as_xapian/.git/refs/heads/master', 

'HASH(0x25fdb00)', 10576, '_p_apr_pool_t=SCALAR(0x24f8978)') called at
/usr/lib/perl5/SVN/Ra.pm line 623
SVN::Ra::Reporter::AUTOLOAD('SVN::Ra::Reporter=ARRAY(0x24f8948)',
'SVN::Pool=REF(0x24f8528)') called at ../git-svn.perl line 4087
Git::SVN::Ra::gs_do_update('Git::SVN::Ra=HASH(0x24beac8)', 10576, 10577,
'Git::SVN=HASH(0x24f7d18)', 'SVN::Git::Fetcher=HASH(0x25faf38)') called
at ../git-svn.perl line 2481
Git::SVN::do_fetch('Git::SVN=HASH(0x24f7d18)', 'HASH(0x24c01f0)', 10577)
called at ../git-svn.perl line 4227
Git::SVN::Ra::gs_fetch_loop_common('Git::SVN::Ra=HASH(0x24beac8)',
10575, 10724, 'ARRAY(0x1da1c20)', 'ARRAY(0x1da1c50)') called at
../git-svn.perl line 1506
Git::SVN::fetch_all('svn', 'HASH(0x21d6440)') called at ../git-svn.perl
line 387
main::cmd_fetch at ../git-svn.perl line 268
eval {...} at ../git-svn.perl line 266
branches/rails/rails/vendor/plugins/acts_as_xapian/.git/refs/heads/master
was not found in commit a643e882c557593f36bb9fd0966490010b9dba61
(r10576) at ../git-svn.perl line 3271.


I'm not sure whether this is correct behavior or not and I'm not
familiar with SVN::Ra::Reporter... so some help would be appreciated.

Thanks,
Morgan

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

Re: git-svn: File was not found in commit

From: Björn Steinbrink <hidden>
Date: 2016-06-15 22:45:55

On 2009.01.09 18:19:01 +0100, Morgan Christiansson wrote:
Hi, i'm trying to "git svn fetch" my repository from a local file:///
repo and i'm running into this problem:

$ git svn init -t tags -b branches -T trunk file:///path/to/svn/repo
$ git svn fetch
branches/rails/rails/vendor/plugins/acts_as_xapian/.git/refs/heads/master
was not found in commit a643e882c557593f36bb9fd0966490010b9dba61 (r10576)


I found another report that seems to describe the same error:
http://marc.info/?l=git&m=121537767308135&w=2
Investigating the the history it's committed in r10577 and it's looking
for it in r10576, so it seems to be off by one revision number. Exactly
like the other report.
I've tried the latest git version of git-svn.perl and the problem is not
fixed there.


$ svn log file:///path/to/repo -r10576:10577 -v
------------------------------------------------------------------------
r10576 | morgan | 2008-11-28 14:35:53 +0000 (Fri, 28 Nov 2008) | 3 lines
Changed paths:
  A /branches/rails/rails/app/controllers/browse_sheetmusic_controller.rb
  M /branches/rails/rails/app/controllers/scores_controller.rb
  M /branches/rails/rails/app/models/composer.rb
  M /branches/rails/rails/app/models/score.rb
  M /branches/rails/rails/config/routes.rb

Commit message.

------------------------------------------------------------------------
r10577 | morgan | 2008-11-28 18:31:00 +0000 (Fri, 28 Nov 2008) | 3 lines
Changed paths:
  A /branches/rails/rails/vendor/plugins/acts_as_xapian/.git/FETCH_HEAD
  M /branches/rails/rails/vendor/plugins/acts_as_xapian/.git/config
  M /branches/rails/rails/vendor/plugins/acts_as_xapian/.git/index
  M /branches/rails/rails/vendor/plugins/acts_as_xapian/.git/logs/HEAD
  M
 
/branches/rails/rails/vendor/plugins/acts_as_xapian/.git/logs/refs/heads/master 


# <-- THIS FILE
Unless I totally misread that line, SVN reports that the file was
_modified_, not added. For the file to be modified, it seems reasonable
to expect that it existed in the previous commit.

Is there anything "special" about how that file came into existence in
that branch? Without further knowledge, that looks like a svn bug, but
hey, it's svn, it might do funny stuff on purpose ;-)

Maybe you could provide a small test case/repo?

Björn

Re: git-svn: File was not found in commit

From: Morgan Christiansson <hidden>
Date: 2016-06-15 22:45:55

Björn Steinbrink wrote:
On 2009.01.09 18:19:01 +0100, Morgan Christiansson wrote:
  
quoted
------------------------------------------------------------------------
r10577 | morgan | 2008-11-28 18:31:00 +0000 (Fri, 28 Nov 2008) | 3 lines
Changed paths:
  A /branches/rails/rails/vendor/plugins/acts_as_xapian/.git/FETCH_HEAD
  M /branches/rails/rails/vendor/plugins/acts_as_xapian/.git/config
  M /branches/rails/rails/vendor/plugins/acts_as_xapian/.git/index
  M /branches/rails/rails/vendor/plugins/acts_as_xapian/.git/logs/HEAD
  M /branches/rails/rails/vendor/plugins/acts_as_xapian/.git/logs/refs/heads/master 
# -- THIS FILE --
    
Unless I totally misread that line, SVN reports that the file was
_modified_, not added. For the file to be modified, it seems reasonable
to expect that it existed in the previous commit.

Is there anything "special" about how that file came into existence in
that branch? Without further knowledge, that looks like a svn bug, but
hey, it's svn, it might do funny stuff on purpose ;-)

Maybe you could provide a small test case/repo?

Björn
  
Something odd happened when "git svn fetch" was adding r10559 to git:

        A       rails/vendor/plugins/acts_as_xapian/README.txt
        A       rails/vendor/plugins/acts_as_xapian/.cvsignore
Ignoring path rails/vendor/plugins/acts_as_xapian/.git/refs/heads/master
Ignoring path 
rails/vendor/plugins/acts_as_xapian/.git/refs/remotes/origin/HEAD
Ignoring path 
rails/vendor/plugins/acts_as_xapian/.git/refs/remotes/origin/master
Ignoring path rails/vendor/plugins/acts_as_xapian/.git/HEAD
Ignoring path rails/vendor/plugins/acts_as_xapian/.git/description
Ignoring path rails/vendor/plugins/acts_as_xapian/.git/hooks/update
Ignoring path rails/vendor/plugins/acts_as_xapian/.git/hooks/post-receive
Ignoring path rails/vendor/plugins/acts_as_xapian/.git/hooks/post-update
Ignoring path rails/vendor/plugins/acts_as_xapian/.git/hooks/pre-rebase
Ignoring path 
rails/vendor/plugins/acts_as_xapian/.git/hooks/prepare-commit-msg
Ignoring path rails/vendor/plugins/acts_as_xapian/.git/hooks/applypatch-msg
Ignoring path rails/vendor/plugins/acts_as_xapian/.git/hooks/pre-applypatch
Ignoring path rails/vendor/plugins/acts_as_xapian/.git/hooks/post-commit
Ignoring path rails/vendor/plugins/acts_as_xapian/.git/hooks/commit-msg
Ignoring path rails/vendor/plugins/acts_as_xapian/.git/hooks/pre-commit
Ignoring path 
rails/vendor/plugins/acts_as_xapian/.git/logs/refs/heads/master
Ignoring path 
rails/vendor/plugins/acts_as_xapian/.git/logs/refs/remotes/origin/HEAD
Ignoring path 
rails/vendor/plugins/acts_as_xapian/.git/logs/refs/remotes/origin/master
Ignoring path rails/vendor/plugins/acts_as_xapian/.git/logs/HEAD
Ignoring path rails/vendor/plugins/acts_as_xapian/.git/config
Ignoring path rails/vendor/plugins/acts_as_xapian/.git/index
Ignoring path 
rails/vendor/plugins/acts_as_xapian/.git/objects/pack/pack-570449ffe8ce399eca81f286cf942e51ace03448.pack
Ignoring path 
rails/vendor/plugins/acts_as_xapian/.git/objects/pack/pack-570449ffe8ce399eca81f286cf942e51ace03448.idx
Ignoring path rails/vendor/plugins/acts_as_xapian/.git/info/exclude
W: +empty_dir: 
branches/rails/rails/vendor/plugins/acts_as_xapian/.git/branches
W: +empty_dir: 
branches/rails/rails/vendor/plugins/acts_as_xapian/.git/objects/info
W: +empty_dir: 
branches/rails/rails/vendor/plugins/acts_as_xapian/.git/refs/tags
r10559 = 4f33ee36a5d933a62081a76c7788fb46a9e6f0e8 (rails)


The "Ignoring path" message appears to be coming from git which is 
refusing to commit the .git directory. Which leads to git-svn being 
unaware of the files being ignored and giving an error when it can't 
find them.


#The following commands will create a repository that has this problem:
cd ~
rm -rf gittest*
svnadmin create gittest-repo
svn co file:///$HOME/gittest-repo gittest-checkout
cd gittest-checkout
mkdir -p .git
touch .git/file
svn add .git
svn commit -m "Create .git/file"
echo 1 > .git/file
svn commit -m "Modify .git/file"

# The following will try to import the repository, which fails.
cd ~
mkdir gittest
cd gittest
git svn init file:///$HOME/gittest-repo
git svn fetch

# Output:
$ git svn fetch
    A    .git/file
Ignoring path .git/file
r1 = ccc56451d54315bd253b65c514351e996fbe880e (git-svn)
.git/file was not found in commit 
ccc56451d54315bd253b65c514351e996fbe880e (r1)


# Cleanup
rm -rf gittest gittest-repo gittest-checkout



I'm personally fine with these files being ignored by git, but git-svn 
needs to be aware that they are not added to the repository.

Re: git-svn: File was not found in commit

From: Eric Wong <hidden>
Date: 2016-06-15 22:45:55

Morgan Christiansson [off-list ref] wrote:
The "Ignoring path" message appears to be coming from git which is  
refusing to commit the .git directory. Which leads to git-svn being  
unaware of the files being ignored and giving an error when it can't  
find them.
I'm personally fine with these files being ignored by git, but git-svn  
needs to be aware that they are not added to the repository.
Hi Morgan,
Can you try the following rough patch and see it it fixes things
for you?  Thanks!
From 559f4b673592f364e9773f2ba65caf09b138521b Mon Sep 17 00:00:00 2001
From: Eric Wong <redacted>
Date: Sun, 11 Jan 2009 18:23:38 -0800
Subject: [PATCH/RFC] git-svn: avoid importing nested repos

Some SVN repositories contain .git repositories within them
(hopefully accidentally checked in).  Since git refuses to
check in ".git" repositories, this can be a problem when
fetching updates from SVN.

This seems to repull the entire blob from SVN everytime a user
changes something inside the ".git" directory on the SVN side,
but hopefully this will be a rare case and the SVN users will
correct the error quickly.

The test could probably be expanded to be more thorough...

Signed-off-by: Eric Wong <redacted>
---
 git-svn.perl                       |    8 +++++
 t/t9133-git-svn-nested-git-repo.sh |   61 ++++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+), 0 deletions(-)
 create mode 100755 t/t9133-git-svn-nested-git-repo.sh
diff --git a/git-svn.perl b/git-svn.perl
index b0e3d7c..d34d967 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -3379,6 +3379,13 @@ sub apply_textdelta {
 	# (but $base does not,) so dup() it for reading in close_file
 	open my $dup, '<&', $fh or croak $!;
 	my $base = $::_repository->temp_acquire('git_blob');
+
+	# skip any .git directories that may have gone into SVN
+	# since update-index refuses to add anything under ".git"
+	if ($fb->{path} =~ m{(?:^|/)\.git(?:/|$)}) {
+		goto apply;
+	}
+
 	if ($fb->{blob}) {
 		my ($base_is_link, $size);
 
@@ -3412,6 +3419,7 @@ sub apply_textdelta {
 		}
 	}
 	seek $base, 0, 0 or croak $!;
+apply:
 	$fb->{fh} = $fh;
 	$fb->{base} = $base;
 	[ SVN::TxDelta::apply($base, $dup, undef, $fb->{path}, $fb->{pool}) ];
diff --git a/t/t9133-git-svn-nested-git-repo.sh b/t/t9133-git-svn-nested-git-repo.sh
new file mode 100755
index 0000000..85402f4
--- /dev/null
+++ b/t/t9133-git-svn-nested-git-repo.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+#
+# Copyright (c) 2009 Eric Wong
+#
+
+test_description='git svn property tests'
+. ./lib-git-svn.sh
+
+test_expect_success 'setup repo with a git repo inside it' '
+	svn co "$svnrepo" s &&
+	(
+		cd s &&
+		git init &&
+		test -f .git/HEAD &&
+		echo a > a &&
+		svn add .git a &&
+		test a = "`sed -ne 1p < a`" &&
+		svn commit -m "create a nested git repo"
+	)
+'
+
+test_expect_success 'clone an SVN repo containing a git repo' '
+	git svn clone "$svnrepo" g
+'
+
+test_expect_success 'SVN-side change outside of .git' '
+	(
+		cd s &&
+		echo b >> a &&
+		svn commit -m "SVN-side change outside of .git"
+	)
+'
+
+test_expect_success 'update git svn-cloned repo' '
+	(
+		cd g &&
+		git svn rebase &&
+		test a = "`sed -ne 1p < a`" &&
+		test b = "`sed -ne 2p < a`"
+	)
+'
+test_expect_success 'SVN-side change inside of .git' '
+	(
+		cd s &&
+		git add a &&
+		git commit -m "add a inside an SVN repo" &&
+		svn add .git &&
+		svn commit -m "SVN-side change inside of .git"
+	)
+'
+
+test_expect_success 'update git svn-cloned repo' '
+	(
+		cd g &&
+		git svn rebase &&
+		grep ^b a &&
+		git log --raw -r
+	)
+'
+
+test_done
-- 
Eric Wong

Re: git-svn: File was not found in commit

From: Eric Wong <hidden>
Date: 2016-06-15 22:45:56

Eric Wong [off-list ref] wrote:
Morgan Christiansson [off-list ref] wrote:
quoted
The "Ignoring path" message appears to be coming from git which is  
refusing to commit the .git directory. Which leads to git-svn being  
unaware of the files being ignored and giving an error when it can't  
find them.
quoted
I'm personally fine with these files being ignored by git, but git-svn  
needs to be aware that they are not added to the repository.
Hi Morgan,
Can you try the following rough patch and see it it fixes things
for you?  Thanks!
Actually, I think this patch is broken (my quickly put together test
case was insufficient)...
From 559f4b673592f364e9773f2ba65caf09b138521b Mon Sep 17 00:00:00 2001
From: Eric Wong <redacted>
Date: Sun, 11 Jan 2009 18:23:38 -0800
Subject: [PATCH/RFC] git-svn: avoid importing nested repos

Some SVN repositories contain .git repositories within them
(hopefully accidentally checked in).  Since git refuses to
check in ".git" repositories, this can be a problem when
fetching updates from SVN.

This seems to repull the entire blob from SVN everytime a user
changes something inside the ".git" directory on the SVN side,
but hopefully this will be a rare case and the SVN users will
correct the error quickly.

The test could probably be expanded to be more thorough...

Signed-off-by: Eric Wong <redacted>

Re: git-svn: File was not found in commit

From: Morgan Christiansson <hidden>
Date: 2016-06-15 22:45:56

Eric Wong wrote:
Eric Wong [off-list ref] wrote:
  
quoted
Morgan Christiansson [off-list ref] wrote:
    
quoted
The "Ignoring path" message appears to be coming from git which is  
refusing to commit the .git directory. Which leads to git-svn being  
unaware of the files being ignored and giving an error when it can't  
find them.
      
I'm personally fine with these files being ignored by git, but git-svn  
needs to be aware that they are not added to the repository.
      
Hi Morgan,
Can you try the following rough patch and see it it fixes things
for you?  Thanks!
    
Actually, I think this patch is broken (my quickly put together test
case was insufficient)...
  
Yes it was. apply_textdelta() is never called for my repo so it has no 
effect.

I've attached an updated and simplified version of the testcase you sent 
that correctly triggers the bug i reported.

I'm not a native perl coder though so I don't think I would be able to 
provide a clean fix for this. But I've traced through enough of the 
program to see that the .git directories should be filtered out as early 
as possible to mimick the behaviour of git.

get_log() has a callback as it's last argument which gets called once 
per commit, nesting this callback in a new callback which filters the 
illegal paths out would work.

Also in gs_do_fetch_loop_common() after get_log() and before 
do_git_commit() it's possible to filter them.

Regards,
Morgan

Re: git-svn: File was not found in commit

From: Eric Wong <hidden>
Date: 2016-06-15 22:45:59

Morgan Christiansson [off-list ref] wrote:
Eric Wong wrote:
quoted
Eric Wong [off-list ref] wrote:
  
quoted
Morgan Christiansson [off-list ref] wrote:
    
quoted
The "Ignoring path" message appears to be coming from git which is  
refusing to commit the .git directory. Which leads to git-svn being 
 unaware of the files being ignored and giving an error when it 
can't  find them.
      I'm personally fine with these files being ignored by git, 
but git-svn  needs to be aware that they are not added to the 
repository.
      
Hi Morgan,
Can you try the following rough patch and see it it fixes things
for you?  Thanks!
    
Actually, I think this patch is broken (my quickly put together test
case was insufficient)...
  
Yes it was. apply_textdelta() is never called for my repo so it has no  
effect.

I've attached an updated and simplified version of the testcase you sent  
that correctly triggers the bug i reported.

I'm not a native perl coder though so I don't think I would be able to  
provide a clean fix for this. But I've traced through enough of the  
program to see that the .git directories should be filtered out as early  
as possible to mimick the behaviour of git.
Hi Morgan, the following patch should fix your problem.
From b03a71a660d15d76b63d7d3c5205b896f89f34b5 Mon Sep 17 00:00:00 2001
From: Eric Wong <redacted>
Date: Sun, 11 Jan 2009 18:23:38 -0800
Subject: [PATCH] git-svn: avoid importing nested git repos

Some SVN repositories contain git repositories within them
(hopefully accidentally checked in).  Since git refuses to track
nested ".git" repositories, this can be a problem when fetching
updates from SVN.

Thanks to Morgan Christiansson for the report and testing.

Signed-off-by: Eric Wong <redacted>
---
 git-svn.perl                       |   34 +++++++++++--
 t/t9133-git-svn-nested-git-repo.sh |  101 ++++++++++++++++++++++++++++++++++++
 2 files changed, 131 insertions(+), 4 deletions(-)
 create mode 100755 t/t9133-git-svn-nested-git-repo.sh
diff --git a/git-svn.perl b/git-svn.perl
index 71b8ef4..55c4dfb 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -3291,6 +3291,11 @@ sub _mark_empty_symlinks {
 	\%ret;
 }
 
+# returns true if a given path is inside a ".git" directory
+sub in_dot_git {
+	$_[0] =~ m{(?:^|/)\.git(?:/|$)};
+}
+
 sub set_path_strip {
 	my ($self, $path) = @_;
 	$self->{path_strip} = qr/^\Q$path\E(\/|$)/ if length $path;
@@ -3316,6 +3321,7 @@ sub git_path {
 
 sub delete_entry {
 	my ($self, $path, $rev, $pb) = @_;
+	return undef if in_dot_git($path);
 
 	my $gpath = $self->git_path($path);
 	return undef if ($gpath eq '');
@@ -3343,8 +3349,12 @@ sub delete_entry {
 
 sub open_file {
 	my ($self, $path, $pb, $rev) = @_;
+	my ($mode, $blob);
+
+	goto out if in_dot_git($path);
+
 	my $gpath = $self->git_path($path);
-	my ($mode, $blob) = (command('ls-tree', $self->{c}, '--', $gpath)
+	($mode, $blob) = (command('ls-tree', $self->{c}, '--', $gpath)
 	                     =~ /^(\d{6}) blob ([a-f\d]{40})\t/);
 	unless (defined $mode && defined $blob) {
 		die "$path was not found in commit $self->{c} (r$rev)\n";
@@ -3352,20 +3362,27 @@ sub open_file {
 	if ($mode eq '100644' && $self->{empty_symlinks}->{$path}) {
 		$mode = '120000';
 	}
+out:
 	{ path => $path, mode_a => $mode, mode_b => $mode, blob => $blob,
 	  pool => SVN::Pool->new, action => 'M' };
 }
 
 sub add_file {
 	my ($self, $path, $pb, $cp_path, $cp_rev) = @_;
-	my ($dir, $file) = ($path =~ m#^(.*?)/?([^/]+)$#);
-	delete $self->{empty}->{$dir};
-	{ path => $path, mode_a => 100644, mode_b => 100644,
+	my $mode;
+
+	if (!in_dot_git($path)) {
+		my ($dir, $file) = ($path =~ m#^(.*?)/?([^/]+)$#);
+		delete $self->{empty}->{$dir};
+		$mode = '100644';
+	}
+	{ path => $path, mode_a => $mode, mode_b => $mode,
 	  pool => SVN::Pool->new, action => 'A' };
 }
 
 sub add_directory {
 	my ($self, $path, $cp_path, $cp_rev) = @_;
+	goto out if in_dot_git($path);
 	my $gpath = $self->git_path($path);
 	if ($gpath eq '') {
 		my ($ls, $ctx) = command_output_pipe(qw/ls-tree
@@ -3383,11 +3400,13 @@ sub add_directory {
 	my ($dir, $file) = ($path =~ m#^(.*?)/?([^/]+)$#);
 	delete $self->{empty}->{$dir};
 	$self->{empty}->{$path} = 1;
+out:
 	{ path => $path };
 }
 
 sub change_dir_prop {
 	my ($self, $db, $prop, $value) = @_;
+	return undef if in_dot_git($db->{path});
 	$self->{dir_prop}->{$db->{path}} ||= {};
 	$self->{dir_prop}->{$db->{path}}->{$prop} = $value;
 	undef;
@@ -3395,6 +3414,7 @@ sub change_dir_prop {
 
 sub absent_directory {
 	my ($self, $path, $pb) = @_;
+	return undef if in_dot_git($pb->{path});
 	$self->{absent_dir}->{$pb->{path}} ||= [];
 	push @{$self->{absent_dir}->{$pb->{path}}}, $path;
 	undef;
@@ -3402,6 +3422,7 @@ sub absent_directory {
 
 sub absent_file {
 	my ($self, $path, $pb) = @_;
+	return undef if in_dot_git($pb->{path});
 	$self->{absent_file}->{$pb->{path}} ||= [];
 	push @{$self->{absent_file}->{$pb->{path}}}, $path;
 	undef;
@@ -3409,6 +3430,7 @@ sub absent_file {
 
 sub change_file_prop {
 	my ($self, $fb, $prop, $value) = @_;
+	return undef if in_dot_git($fb->{path});
 	if ($prop eq 'svn:executable') {
 		if ($fb->{mode_b} != 120000) {
 			$fb->{mode_b} = defined $value ? 100755 : 100644;
@@ -3424,11 +3446,13 @@ sub change_file_prop {
 
 sub apply_textdelta {
 	my ($self, $fb, $exp) = @_;
+	return undef if (in_dot_git($fb->{path}));
 	my $fh = $::_repository->temp_acquire('svn_delta');
 	# $fh gets auto-closed() by SVN::TxDelta::apply(),
 	# (but $base does not,) so dup() it for reading in close_file
 	open my $dup, '<&', $fh or croak $!;
 	my $base = $::_repository->temp_acquire('git_blob');
+
 	if ($fb->{blob}) {
 		my ($base_is_link, $size);
 
@@ -3469,6 +3493,8 @@ sub apply_textdelta {
 
 sub close_file {
 	my ($self, $fb, $exp) = @_;
+	return undef if (in_dot_git($fb->{path}));
+
 	my $hash;
 	my $path = $self->git_path($fb->{path});
 	if (my $fh = $fb->{fh}) {
diff --git a/t/t9133-git-svn-nested-git-repo.sh b/t/t9133-git-svn-nested-git-repo.sh
new file mode 100755
index 0000000..893f57e
--- /dev/null
+++ b/t/t9133-git-svn-nested-git-repo.sh
@@ -0,0 +1,101 @@
+#!/bin/sh
+#
+# Copyright (c) 2009 Eric Wong
+#
+
+test_description='git svn property tests'
+. ./lib-git-svn.sh
+
+test_expect_success 'setup repo with a git repo inside it' '
+	svn co "$svnrepo" s &&
+	(
+		cd s &&
+		git init &&
+		test -f .git/HEAD &&
+		> .git/a &&
+		echo a > a &&
+		svn add .git a &&
+		svn commit -m "create a nested git repo" &&
+		svn up &&
+		echo hi >> .git/a &&
+		svn commit -m "modify .git/a" &&
+		svn up
+	)
+'
+
+test_expect_success 'clone an SVN repo containing a git repo' '
+	git svn clone "$svnrepo" g &&
+	echo a > expect &&
+	test_cmp expect g/a
+'
+
+test_expect_success 'SVN-side change outside of .git' '
+	(
+		cd s &&
+		echo b >> a &&
+		svn commit -m "SVN-side change outside of .git" &&
+		svn up &&
+		svn log -v | fgrep "SVN-side change outside of .git"
+	)
+'
+
+test_expect_success 'update git svn-cloned repo' '
+	(
+		cd g &&
+		git svn rebase &&
+		echo a > expect &&
+		echo b >> expect &&
+		test_cmp a expect &&
+		rm expect
+	)
+'
+
+test_expect_success 'SVN-side change inside of .git' '
+	(
+		cd s &&
+		git add a &&
+		git commit -m "add a inside an SVN repo" &&
+		git log &&
+		svn add --force .git &&
+		svn commit -m "SVN-side change inside of .git" &&
+		svn up &&
+		svn log -v | fgrep "SVN-side change inside of .git"
+	)
+'
+
+test_expect_success 'update git svn-cloned repo' '
+	(
+		cd g &&
+		git svn rebase &&
+		echo a > expect &&
+		echo b >> expect &&
+		test_cmp a expect &&
+		rm expect
+	)
+'
+
+test_expect_success 'SVN-side change in and out of .git' '
+	(
+		cd s &&
+		echo c >> a &&
+		git add a &&
+		git commit -m "add a inside an SVN repo" &&
+		svn commit -m "SVN-side change in and out of .git" &&
+		svn up &&
+		svn log -v | fgrep "SVN-side change in and out of .git"
+	)
+'
+
+test_expect_success 'update git svn-cloned repo again' '
+	(
+		cd g &&
+		git svn rebase &&
+		echo a > expect &&
+		echo b >> expect &&
+		echo c >> expect &&
+		test_cmp a expect &&
+		rm expect
+	)
+'
+
+test_done
-- 
Eric Wong
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help