about summary refs log tree commit homepage
path: root/script
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-04-01 23:15:04 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-04-01 23:25:04 +0000
commitc34a83286234ea1e876ebdf92a33744272bb6f4e (patch)
treea04f43151284e6893e23780438773f9ea07c9fba /script
parent0321a1a9e7ae9c9d878d547ee67659ef8aa95689 (diff)
downloadpublic-inbox-c34a83286234ea1e876ebdf92a33744272bb6f4e.tar.gz
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.
Diffstat (limited to 'script')
-rwxr-xr-xscript/public-inbox-convert11
1 files changed, 10 insertions, 1 deletions
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+)}) {