From c34a83286234ea1e876ebdf92a33744272bb6f4e Mon Sep 17 00:00:00 2001 From: "Eric Wong (Contractor, The Linux Foundation)" Date: Sun, 1 Apr 2018 23:15:04 +0000 Subject: v2: one file, really We need to ensure there is only one file in the top-level tree at any commit so the "add; remove; add;" sequence on the same message is detected properly. Otherwise, git will not detect the second "add" unless a second message is added to history. Deletes are now stored in "d" (and not "D" or "_/D") at the top-level, now. There's no need to have a "_" to reduce churn as "m" and "d" should never co-exist. It's now lowercased to make it easier-to-distinguish from "D" in git-log output. --- script/public-inbox-convert | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'script') diff --git a/script/public-inbox-convert b/script/public-inbox-convert index f58bf27b..56ac44f5 100755 --- a/script/public-inbox-convert +++ b/script/public-inbox-convert @@ -71,6 +71,7 @@ my $im = $v2w->importer; my ($r, $w) = $im->gfi_start; my $h = '[0-9a-f]'; my %D; +my $last; while (<$rd>) { if ($_ eq "blob\n") { $state = 'blob'; @@ -90,13 +91,21 @@ while (<$rd>) { if (m{^M 100644 :(\d+) (${h}{2}/${h}{38})}o) { my ($mark, $path) = ($1, $2); $D{$path} = $mark; + if ($last && $last ne 'm') { + $w->print("D $last\n") or $im->wfail; + } $w->print("M 100644 :$mark m\n") or $im->wfail; + $last = 'm'; next; } if (m{^D (${h}{2}/${h}{38})}o) { my $mark = delete $D{$1}; defined $mark or die "undeleted path: $1\n"; - $w->print("M 100644 :$mark _/D\n") or $im->wfail; + if ($last && $last ne 'd') { + $w->print("D $last\n") or $im->wfail; + } + $w->print("M 100644 :$mark d\n") or $im->wfail; + $last = 'd'; next; } if (m{^from (:\d+)}) { -- cgit v1.2.3-24-ge0c7