git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] git-svn: fix svn fetch erroneously recreating empty dir placeholder deleted earlier, try #2

From
IBIlya Basin <basinilya@gmail.com>
Date
Apr 28, 2013, 20:11 UTC
Message-ID
<991177798.20130429001102@gmail.com>
The Fetcher accumulates deleted paths in an array and doesn't reset the
array on next commit. This causes different results when interrupting
and resuming the fetch.
When --preserve-empty-dirs flag is used, a path in the array can be
erroneously treated as just deleted (although it was deleted in the
previous commit) and cause the creation of an empty dir placeholder.
---
 perl/Git/SVN/Fetcher.pm                |  1 +
 t/t9160-git-svn-preserve-empty-dirs.sh | 18 ++++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm
index 4f96076..e658889 100644
--- a/perl/Git/SVN/Fetcher.pm
+++ b/perl/Git/SVN/Fetcher.pm
@@ -19,6 +19,7 @@ sub new {
 	my ($class, $git_svn, $switch_path) = @_;
 	my $self = SVN::Delta::Editor->new;
 	bless $self, $class;
+	@deleted_gpath = ();
 	if (exists $git_svn->{last_commit}) {
 		$self->{c} = $git_svn->{last_commit};
 		$self->{empty_symlinks} =
diff --git a/t/t9160-git-svn-preserve-empty-dirs.sh b/t/t9160-git-svn-preserve-empty-dirs.sh
index 43b1852..d50314d 100755
--- a/t/t9160-git-svn-preserve-empty-dirs.sh
+++ b/t/t9160-git-svn-preserve-empty-dirs.sh
@@ -15,18 +15,27 @@ say 'define NO_SVN_TESTS to skip git svn tests'
 GIT_REPO=git-svn-repo
 
 test_expect_success 'initialize source svn repo containing empty dirs' '
+	#exec 1>/dev/tty 2>&1
 	svn_cmd mkdir -m x "$svnrepo"/trunk &&
 	svn_cmd co "$svnrepo"/trunk "$SVN_TREE" &&
 	(
 		cd "$SVN_TREE" &&
-		mkdir -p 1 2 3/a 3/b 4 5 6 &&
+		mkdir -p 1 2 3/a 3/b 4 5 6 7 &&
 		echo "First non-empty file"  > 2/file1.txt &&
 		echo "Second non-empty file" > 2/file2.txt &&
 		echo "Third non-empty file"  > 3/a/file1.txt &&
 		echo "Fourth non-empty file" > 3/b/file1.txt &&
-		svn_cmd add 1 2 3 4 5 6 &&
+		echo "x" > 7/file.txt &&
+		svn_cmd add 1 2 3 4 5 6 7 &&
 		svn_cmd commit -m "initial commit" &&
 
+		svn_cmd del 7/file.txt &&
+		svn_cmd commit -m "delete last entry in directory" &&
+		svn_cmd up &&
+
+		svn_cmd del 7 &&
+		svn_cmd commit -m "delete empty dir that had files in it; subsequent commits should not recreate it" &&
+
 		mkdir 4/a &&
 		svn_cmd add 4/a &&
 		svn_cmd commit -m "nested empty directory" &&
@@ -60,6 +69,11 @@ test_expect_success 'clone svn repo with --preserve-empty-dirs --stdlayout' '
 	git svn clone "$svnrepo" --preserve-empty-dirs --stdlayout "$GIT_REPO"
 '
 
+# "$GIT_REPO"/7/ should not be recreated
+test_expect_success 'no recreating empty dir deleted earlier' '
+	test_must_fail test -d "$GIT_REPO"/7/
+'
+
 # "$GIT_REPO"/1 should only contain the placeholder file.
 test_expect_success 'directory empty from inception' '
 	test -f "$GIT_REPO"/1/.gitignore &&
-- 
1.8.1.5
Message 1 of 1 in “git-svn: fix svn fetch erroneously recreating empty dir placeholder deleted earlier, try #2”
  1. 3/3 git-svn: fix svn fetch erroneously recreating empty dir placeholder deleted earlier, try #2Ilya Basin, Apr 28, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.