Skip to contentSkip to conversation

git svn: Don't create empty directories whose parents were deleted

PATCH In review Greg Price 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore

Greg Price

author
#0 lore raw

PATCH 1/1 git svn: Don't create empty directories whose parents were deleted

Commit 6111b93 "git svn: attempt to create empty dirs on clone+rebase" will create empty directories 'a/b' and 'a/c' if they were previously created in SVN, even if their parent directory 'a' was deleted.

For example, unhandled.log may contain lines like this:

r32
+empty_dir: packages/sipb-xen-remctl-auto/sipb-xen-remctl-auto/files/etc/remctl/sipb-xen-auto/acl +empty_dir: packages/sipb-xen-remctl-auto/sipb-xen-remctl-auto/files/etc/remctl/sipb-xen-auto/machine.d +empty_dir: packages/sipb-xen-remctl-auto/sipb-xen-remctl-auto/files/etc/remctl/sipb-xen-auto/moira-acl
[...]
r314
-empty_dir: packages/sipb-xen-remctl-auto

---

This is a regression in v1.6.6-rc0, so it would be good to fix before v1.6.6.

 git-svn.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
git-svn.perl +1 -1
index 957d44e..5c35494 100755
@@ -2748,7 +2748,7 @@ sub mkemptydirs {
 		} elsif (/^  \+empty_dir: (.+)$/) {
 			$empty_dirs{$1} = 1;
 		} elsif (/^  \-empty_dir: (.+)$/) {
-			delete $empty_dirs{$1};
+			delete @empty_dirs{grep {m[^\Q$1\E(/|$)]} (keys %empty_dirs)};
 		}
 	}
 	close $fh;
Signature · 1 line
1.6.4.4
#1 lore raw
Quoted 1 line · Greg Price

This is a regression in v1.6.6-rc0, so it would be good to fix before v1.6.6.

Thanks Greg,

I found another git svn bug (fixed in a patch below) while writing a test case for this.

Junio:

The following are pushed out to git://git.bogomips.org/git-svn and should be ready for v1.6.6:

Alex Vandiver (1):
git-svn: sort svk merge tickets to account for minimal parents

Eric Wong (1):
git svn: log removals of empty directories

Greg Price (1):
git svn: Don't create empty directories whose parents were deleted

Thanks all

Quoted 1 line

From f9ad77a739c0d012ee58b64eda2d7ec0d4e1df9d Mon Sep 17 00:00:00 2001

From: Eric Wong <[email protected]>
Date: Mon, 7 Dec 2009 20:49:38 -0800
Subject: [PATCH] git svn: log removals of empty directories

This also adds a test case for:
"git svn: Don't create empty directories whose parents were deleted"
which was the reason we found this bug in the first place.

---
 git-svn.perl                  |    2 +-
 t/t9146-git-svn-empty-dirs.sh |   10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletions(-)
git-svn.perl +1 -1
index bdd1f96..5a52068 100755
@@ -3891,11 +3891,11 @@ sub delete_entry {
 		}
 		print "\tD\t$gpath/\n" unless $::_q;
 		command_close_pipe($ls, $ctx);
-		$self->{empty}->{$path} = 0
 	} else {
 		$self->{gii}->remove($gpath);
 		print "\tD\t$gpath\n" unless $::_q;
 	}
+	$self->{empty}->{$path} = 0;
 	undef;
 }
 
t/t9146-git-svn-empty-dirs.sh +10 -0
index 70c52c1..9b8d046 100755
@@ -105,4 +105,14 @@ test_expect_success 'empty directories in trunk exist' '
 	)
 '
 
+test_expect_success 'remove a top-level directory from svn' '
+	svn_cmd rm -m "remove d" "$svnrepo"/d
+'
+
+test_expect_success 'removed top-level directory does not exist' '
+	git svn clone "$svnrepo" removed &&
+	test ! -e removed/d
+
+'
+
 test_done
Signature · 1 line
Eric Wong