+# usage
+# git debrebase launder
+
+sub get_commit ($) {
+ my ($objid) = @_;
+ my ($type,$data) = git_cat_file $objid;
+ die unless $type eq 'commit';
+ $data =~ m/(?<=\n)\n/;
+ return ($`,$');
+}
+
+memoize('get_commit');
+
+sub DDEB () { return 0x1; }
+sub DUPS () { return 0x2; }
+sub DPAT () { return 0x4; }
+
+sub launder () {
+ # go through commits backwards
+ # we generate two lists of commits to apply
+ my (@deb_cl, @ups_cl);
+ my $cur = git_rev_parse('HEAD');
+ for (;;) {
+ my ($h,$m) = get_commit $cur;
+ my ($t) = $h =~ m/^tree (\w+)$/m; defined $t or die $cur;
+ my (@p) = $h =~ m/^parent (\w+)$/m;
+ my (@d) = map { get_differs $t, $_ } @p;
+ if (@p == 1) {
+ my ($d) = $d[0];
+ if ($d == DPAT) {
+ # changes on debian/patches, discard it
+ $cur = $p[0];
+ next;
+ }
+ if ($d & DPAT) {
+
+}
+
+if ($ARGV[0] eq 'launder') {
+ launder();
+}
+