Skip to contentSkip to conversation

git-svn: fix empty dir tracking in branches

PATCH In review Ilya Basin 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore

Ilya Basin

author
#0 lore raw

PATCH 5/5 git-svn: fix empty dir tracking in branches

- When creating a tag or branch from a subdir, a disjoint branch is created. Then git-svn re-imports the commits using this dir as strip path.

During this re-import the variable %added_placeholder is not up to date. Because the branch is disjoint, this variable should be empty in the beginning, but it's not. Because of that git-svn tries to delete non-existent .gitignore files and dies.

- When creating a tag or branch from a subdir, the strip path is e.g. "trunk/module", but change_dir_prop() can be called with just "trunk". This breaks tracking of placeholder files, because it relise on the hash {dir_prop}, filled in change_dir_prop().

- When creating a normal tag or branch, git-svn creates a normal branch without reimport, but the placeholder files in the new branch are not added to %added_placeholder.

This patch does 3 things:

- It makes git-svn store paths in %added_placeholder already translated from "trunk/subdir/" to "tags/subdir_1.0/" during reimport.

- When strip path is "trunk/subdir", don't add "trunk" to {dir_prop} in change_dir_prop().

- When a normal branch is created, it takes entries in %added_placeholder belonging to the source branch, translates them to target branch and adds them to %added_placeholder.

---
 perl/Git/SVN.pm                        |  2 +
 perl/Git/SVN/Fetcher.pm                | 72 ++++++++++++++++++++++++++++++----
 t/t9160-git-svn-preserve-empty-dirs.sh | 51 ++++++++++++++++++++++--
 3 files changed, 114 insertions(+), 11 deletions(-)
perl/Git/SVN.pm +2 -0
index 5273ee8..660921d 100644
@@ -1143,6 +1143,7 @@ sub find_parent_branch {
 		($r0, $parent) = $gs->find_rev_before($r, 1);
 	}
 	if (defined $r0 && defined $parent) {
+		Git::SVN::Fetcher::_end_reimport($self, $branch_from, $self->path);
 		print STDERR "Found branch parent: ($self->{ref_id}) $parent\n"
 		             unless $::_q > 1;
 		my $ed;
@@ -1395,6 +1396,7 @@ sub other_gs {
 			last if ($url eq $gs->metadata_url);
 			$ref_id .= '-';
 		}
+		Git::SVN::Fetcher::_begin_reimport($self->path);
 		print STDERR "Initializing parent: $ref_id\n" unless $::_q > 1;
 	}
 	$gs
perl/Git/SVN/Fetcher.pm +65 -7

122 lines not on this page · raw message

t/t9160-git-svn-preserve-empty-dirs.sh +47 -4

80 lines not on this page · raw message

Signature · 1 line
1.8.1.5
#1 lore raw
Quoted 9 lines · Ilya Basin

- When creating a tag or branch from a subdir, a disjoint branch is created. Then git-svn re-imports the commits using this dir as strip path.

During this re-import the variable %added_placeholder is not up to date. Because the branch is disjoint, this variable should be empty in the beginning, but it's not. Because of that git-svn tries to delete non-existent .gitignore files and dies.

Quoted 4 lines

- When creating a tag or branch from a subdir, the strip path is e.g. "trunk/module", but change_dir_prop() can be called with just "trunk". This breaks tracking of placeholder files, because it relise on the hash {dir_prop}, filled in change_dir_prop().

s/relise/relies/

Quoted 17 lines

- When creating a normal tag or branch, git-svn creates a normal branch without reimport, but the placeholder files in the new branch are not added to %added_placeholder.

This patch does 3 things:

- It makes git-svn store paths in %added_placeholder already translated from "trunk/subdir/" to "tags/subdir_1.0/" during reimport.

- When strip path is "trunk/subdir", don't add "trunk" to {dir_prop} in change_dir_prop().

- When a normal branch is created, it takes entries in %added_placeholder belonging to the source branch, translates them to target branch and adds them to %added_placeholder.