X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=dgit;h=ed3f52622288e921b0c44d1ee31c9f34becbc221;hp=3f637f133bf9b2a7bd891f6e0c6e271f167e9c91;hb=b294deda313d2cbf29e2401aac585736cb2582f3;hpb=0a326d8f58678662e96a78ba843e64d320f74e2f diff --git a/dgit b/dgit index 3f637f13..ed3f5262 100755 --- a/dgit +++ b/dgit @@ -64,6 +64,7 @@ our $quilt_mode; our $quilt_modes_re = 'linear|smash|auto|nofix|nocheck|gbp|unapplied'; our $we_are_responder; our $initiator_tempdir; +our $patches_applied_dirtily = 00; our %format_ok = map { $_=>1 } ("1.0","3.0 (native)","3.0 (quilt)"); @@ -86,7 +87,7 @@ our (@dpkgbuildpackage) = qw(dpkg-buildpackage -i\.git/ -I.git); our (@dpkgsource) = qw(dpkg-source -i\.git/ -I.git); our (@dpkggenchanges) = qw(dpkg-genchanges); our (@mergechanges) = qw(mergechanges -f); -our (@gbppq) = qw(gbp-pq); +our (@gbp) = qw(gbp); our (@changesopts) = (''); our %opts_opt_map = ('dget' => \@dget, # accept for compatibility @@ -101,6 +102,7 @@ our %opts_opt_map = ('dget' => \@dget, # accept for compatibility 'dpkg-source' => \@dpkgsource, 'dpkg-buildpackage' => \@dpkgbuildpackage, 'dpkg-genchanges' => \@dpkggenchanges, + 'gbp' => \@gbp, 'ch' => \@changesopts, 'mergechanges' => \@mergechanges); @@ -2559,7 +2561,7 @@ sub quiltify_tree_sentinelfiles ($) { sub quiltify_splitbrain_needed () { if (!$split_brain) { - progress "creating dgit view"; + progress "dgit view: changes are required..."; runcmd @git, qw(checkout -q -b dgit-view); $split_brain = 1; } @@ -2578,21 +2580,31 @@ sub quiltify_splitbrain ($$$$$$) { local $ENV{GIT_COMMITTER_NAME} = $authline[0]; local $ENV{GIT_COMMITTER_EMAIL} = $authline[1]; local $ENV{GIT_COMMITTER_DATE} = $authline[2]; + if ($quilt_mode =~ m/gbp|unapplied/ && - ($diffbits->{O2A} & 01) && # some patches - !($diffbits->{H2O} & 01)) { # but HEAD is like orig + ($diffbits->{H2O} & 01)) { + my $msg = + "--quilt=$quilt_mode specified, implying patches-unapplied git tree\n". + " but git tree differs from orig in upstream files."; + if (!stat_exists "debian/patches") { + $msg .= + "\n ... debian/patches is missing; perhaps this is a patch queue branch?"; + } + fail $msg; + } + if ($quilt_mode =~ m/gbp|unapplied/ && + ($diffbits->{O2A} & 01)) { # some patches quiltify_splitbrain_needed(); - progress "creating patches-applied version using gbp-pq"; - open STDOUT, ">/dev/null" or die $!; - runcmd shell_cmd 'exec >/dev/null', @gbppq, qw(import); - # gbp-pq import creates a fresh branch; push back to dgit-view + progress "dgit view: creating patches-applied version using gbp pq"; + runcmd shell_cmd 'exec >/dev/null', @gbp, qw(pq import); + # gbp pq import creates a fresh branch; push back to dgit-view runcmd @git, qw(update-ref refs/heads/dgit-view HEAD); runcmd @git, qw(checkout -q dgit-view); } if (($diffbits->{H2O} & 02) && # user has modified .gitignore !($diffbits->{O2A} & 02)) { # patches do not change .gitignore quiltify_splitbrain_needed(); - progress "creating patch to represent .gitignore changes"; + progress "dgit view: creating patch to represent .gitignore changes"; ensuredir "debian/patches"; my $gipatch = "debian/patches/auto-gitignore"; open GIPATCH, ">>", "$gipatch" or die "$gipatch: $!"; @@ -2632,6 +2644,8 @@ END runcmd @git, qw(update-ref -m), $cachekey, "refs/$splitbraincache", $dgitview; + progress "dgit view: created (commit id $dgitview)"; + changedir '.git/dgit/unpack/work'; } @@ -2936,7 +2950,7 @@ sub quilt_fixup_singlepatch ($$$) { sub quilt_fixup_multipatch ($$$) { my ($clogp, $headref, $upstreamversion) = @_; - progress "starting quiltify (multiple patches, $quilt_mode mode)"; + progress "examining quilt state (multiple patches, $quilt_mode mode)"; # Our objective is: # - honour any existing .pc in case it has any strangeness @@ -3048,10 +3062,13 @@ END my $splitbrain_cachekey; if (quiltmode_splitbrain()) { + progress + "dgit: split brain (separate dgit view) may needed (--quilt=$quilt_mode)."; # we look in the reflog of dgit-intern/quilt-cache # we look for an entry whose message is the key for the cache lookup my @cachekey = (qw(dgit), $our_version); push @cachekey, $upstreamversion; + push @cachekey, $quilt_mode; push @cachekey, $headref; push @cachekey, hashfile('fake.dsc'); @@ -3088,13 +3105,12 @@ END my $cachehit = $1; quilt_fixup_mkwork($headref); if ($cachehit ne $headref) { - progress "quilt fixup ($quilt_mode mode) found cached tree"; + progress "dgit view: found cached (commit id $cachehit)"; runcmd @git, qw(checkout -q -b dgit-view), $cachehit; $split_brain = 1; return; } - progress "quilt fixup ($quilt_mode mode)". - " found cached indication that no changes needed"; + progress "dgit view: found cached, no changes required"; return; } die $! if GC->error; @@ -3189,6 +3205,7 @@ END return; } + progress "starting quiltify (multiple patches, $quilt_mode mode)"; quiltify($clogp,$headref,$oldtiptree,\@failsuggestion); if (!open P, '>>', ".pc/applied-patches") { @@ -3223,6 +3240,29 @@ sub quilt_fixup_editor () { exit 0; } +sub maybe_apply_patches_dirtily () { + return unless $quilt_mode =~ m/gbp|unapplied/; + print STDERR <