X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=git-debrebase;h=66167b2bafd501671885cbb7db43984d200d6aa5;hp=61507ea27ba6470f5b39b3c9583e8fd4c6984fdd;hb=6152f859fc4fa61b485362a6ff5613f436883db8;hpb=5d8dfa9c2c0be56eaf85d7ce60ed38182878babd diff --git a/git-debrebase b/git-debrebase index 61507ea2..66167b2b 100755 --- a/git-debrebase +++ b/git-debrebase @@ -183,23 +183,30 @@ sub run_deferred_updates ($) { @deferred_update_messages = (); } -sub get_tree ($) { +sub get_tree ($;$$) { # tree object name => ([ $name, $info ], ...) # where $name is the sort key, ie has / at end for subtrees # $info is the LHS from git-ls-tree ( ) - # will crash if $x does not exist, so don't do that; + # without $precheck, will crash if $x does not exist, so don't do that; # instead pass '' to get (). - my ($x) = @_; + my ($x, $precheck, $recurse) = @_; return () if !length $x; + if ($precheck) { + my ($type, $dummy) = git_cat_file $x, [qw(tree missing)]; + return () if $type eq 'missing'; + } + our (@get_tree_memo, %get_tree_memo); my $memo = $get_tree_memo{$x}; return @$memo if $memo; local $Debian::Dgit::debugcmd_when_debuglevel = 3; my @l; - my @cmd = (qw(git ls-tree -z --full-tree --), $x); + my @cmd = (qw(git ls-tree -z --full-tree)); + push @cmd, qw(-r) if $recurse; + push @cmd, qw(--), $x; my $o = cmdoutput @cmd; $o =~ s/\0$//s; my $last = ''; @@ -1672,7 +1679,7 @@ sub update_head_checkout ($$$) { sub update_head_postlaunder ($$$) { my ($old, $tip, $reflogmsg) = @_; - return if $tip eq $old; + return if $tip eq $old && !@deferred_updates; print "git-debrebase: laundered (head was $old)\n"; update_head $old, $tip, $reflogmsg; # no tree changes except debian/patches @@ -2275,7 +2282,10 @@ sub cmd_stitch () { badusage "no arguments allowed" if @ARGV; do_stitch $prose, 0; } -sub cmd_prepush () { cmd_stitch(); } +sub cmd_prepush () { + $opt_noop_ok = 1; + cmd_stitch(); +} sub cmd_quick () { badusage "no arguments allowed" if @ARGV; @@ -2380,6 +2390,24 @@ sub cmd_make_patches () { } } +sub check_series_has_all_patches ($) { + my ($head) = @_; + my $seriesfn = 'debian/patches/series'; + my ($dummy, $series) = git_cat_file "$head:$seriesfn", + [qw(blob missing)]; + $series //= ''; + my %series; + foreach my $f (grep /\S/, grep {!m/^\s\#/} split /\n/, $series) { + fail "patch $f repeated in $seriesfn !" if $series{$f}++; + } + foreach my $patchfile (get_tree "$head:debian/patches", 1,1) { + my ($f,$i) = @$patchfile; + next if $series{$f}; + next if $f eq 'series'; + snag 'unused-patches', "Unused patch file $f will be discarded"; + } +} + sub cmd_convert_from_gbp () { badusage "want only 1 optional argument, the upstream git commitish" unless @ARGV<=1; @@ -2427,6 +2455,8 @@ END "upstream ($upstream) contains debian/ directory"; } + check_series_has_all_patches $old_head; + my $previous_dgit_view = eval { my @clogcmd = qw(dpkg-parsechangelog --format rfc822 -n2); my ($lvsn, $suite); @@ -2577,6 +2607,8 @@ END } } + check_series_has_all_patches $head; + snags_maybe_bail_early(); my $version = upstreamversion $clogp->{Version};