X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=dgit;h=e10483894bb1084ae5693cf94c1347d959216c1a;hp=5754e45676393f15294a16cbc27e79512b8017ec;hb=0c244082ddb4b2443ccfbc1c438ead4fda1c33ca;hpb=52174c9a5976b18dc3d2ff020a962a84db35019c diff --git a/dgit b/dgit index 5754e456..e1048389 100755 --- a/dgit +++ b/dgit @@ -101,7 +101,11 @@ our %forceopts = map { $_=>0 } our %format_ok = map { $_=>1 } ("1.0","3.0 (native)","3.0 (quilt)"); our $suite_re = '[-+.0-9a-z]+'; -our $cleanmode_re = 'dpkg-source(?:-d)?|git|git-ff|check|none'; +our $cleanmode_re = qr{(?: dpkg-source (?: -d )? (?: ,no-check | ,all-check )? + | git | git-ff + | check (?: ,ignores )? + | none + )}x; our $git_authline_re = '^([^<>]+) \<(\S+)\> (\d+ [-+]\d+)$'; our $splitbraincache = 'dgit-intern/quilt-cache'; @@ -790,6 +794,9 @@ sub git_get_config ($) { @$l==1 or badcfg f_ "multiple values for %s (in %s git config)", $c, $src if @$l > 1; + $l->[0] =~ m/\n/ and badcfg f_ + "value for config option %s (in %s git config) contains newline(s)!", + $c, $src; return $l->[0]; } return undef; @@ -3818,12 +3825,24 @@ sub pull () { sub check_not_dirty () { my @forbid = qw(local-options local-patch-header); + @forbid = map { "debian/source/$_" } @forbid; foreach my $f (@forbid) { - if (stat_exists "debian/source/$f") { - fail f_ "git tree contains debian/source/%s", $f; + if (stat_exists $f) { + fail f_ "git tree contains %s", $f; } } + my @cmd = (@git, qw(status -uall --ignored --porcelain)); + push @cmd, qw(debian/source/format debian/source/options); + push @cmd, @forbid; + + my $bad = cmdoutput @cmd; + if (length $bad) { + fail +(__ + "you have uncommitted changes to critical files, cannot continue:\n"). + $bad; + } + return if $includedirty; git_check_unmodified(); @@ -6184,34 +6203,71 @@ sub maybe_unapply_patches_again () { #----- other building ----- -our $clean_using_builder; -# ^ tree is to be cleaned by dpkg-source's builtin idea that it should -# clean the tree before building (perhaps invoked indirectly by -# whatever we are using to run the build), rather than separately -# and explicitly by us. +sub clean_tree_check_git ($$) { + my ($honour_ignores, $message) = @_; + my @cmd = (@git, qw(clean -dn)); + push @cmd, qw(-x) unless $honour_ignores; + my $leftovers = cmdoutput @cmd; + if (length $leftovers) { + print STDERR $leftovers, "\n" or confess $!; + fail $message; + } +} + +sub clean_tree_check_git_wd ($) { + my ($message) = @_; + return if $cleanmode =~ m{no-check}; + return if $patches_applied_dirtily; # yuk + clean_tree_check_git +($cleanmode !~ m{all-check}), + (f_ <