X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=dgit;h=4edf9827fe181a3c00eedf895b021f3aa316329e;hb=ba42f0850a5c10737136f67cf974bb9d2957530c;hp=08d07bec9190b600fac461f8ccb3bde037a593f2;hpb=bd5e99ad04dc4eda140aca37840628118d1fa94d;p=dgit.git diff --git a/dgit b/dgit index 08d07bec..4edf9827 100755 --- a/dgit +++ b/dgit @@ -70,6 +70,8 @@ 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 $git_authline_re = '^([^<>]+) \<(\S+)\> (\d+ [-+]\d+)$'; + our (@git) = qw(git); our (@dget) = qw(dget); our (@curl) = qw(curl -f); @@ -83,6 +85,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 (@changesopts) = (''); our %opts_opt_map = ('dget' => \@dget, # accept for compatibility @@ -114,6 +117,7 @@ autoflush STDOUT 1; our $supplementary_message = ''; our $need_split_build_invocation = 0; +our $split_brain = 0; END { local ($@, $?); @@ -1314,9 +1318,10 @@ sub clogp_authline ($) { $author =~ s#,.*##ms; my $date = cmdoutput qw(date), '+%s %z', qw(-d), getfield($clogp,'Date'); my $authline = "$author $date"; - $authline =~ m/^[^<>]+ \<\S+\> \d+ [-+]\d+$/ or + $authline =~ m/$git_authline_re/o or fail "unexpected commit author line format \`$authline'". " (was generated from changelog Maintainer field)"; + return ($1,$2,$3) if wantarray; return $authline; } @@ -2537,15 +2542,44 @@ sub quiltify_tree_sentinelfiles ($) { qw(-- debian/rules debian/control); $r =~ s/\n/,/g; return $r; -} - -sub quiltify_splitbrain ($) { - my ($diffbits) = @_; - # memoisation via git-reflog - my $may_apply = $quilt_mode =~ m/gbp|unapplied/; - die "xxx not yet implemented"; -# if ($may_apply && -# quiltify_trees_differ($userhead,)) {} + } + +sub quiltify_splitbrain_needed () { + if (!$split_brain) { + progress "creating dgit view"; + runcmd @git, qw(checkout -q -b dgit-view); + $split_brain = 1; + } +} + +sub quiltify_splitbrain ($$) { + my ($clogp, $diffbits) = @_; + if ($quilt_mode !~ m/gbp|dpm/) { + # treat .gitignore just like any other upstream file + $diffbits = { %$diffbits }; + $_ = !!$_ foreach values %$diffbits; + } + if ($quilt_mode =~ m/gbp|unapplied/ && + ($diffbits->{O2A} & 01) && # some patches + !($diffbits->{H2O} & 01)) { # but HEAD is like orig + quiltify_splitbrain_needed(); + progress "creating patches-applied version using gbp-pq"; + my @authline = clogp_authline($clogp); + local $ENV{GIT_COMMITTER_NAME} = $authline[0]; + local $ENV{GIT_COMMITTER_EMAIL} = $authline[1]; + local $ENV{GIT_COMMITTER_DATE} = $authline[2]; + open STDOUT, ">/dev/null" or die $!; + runcmd shell_cmd 'exec >/dev/null', @gbppq, qw(import); + } + 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"; + die 'xxx gitignore'; + + } + die 'xxx memoisation via git-reflog'; + die 'xxx fast forward (should not depend on quilt mode, but will always be needed if we did $split_brain)'; } sub quiltify ($$$$) { @@ -3034,8 +3068,8 @@ END push @failsuggestion, "Maybe you need to specify one of". " --quilt=gbp --quilt=dpm --quilt=unapplied ?"; - if ($quilt_mode =~ m/gbp|dpm|apply/) { - quiltify_splitbrain($diffbits); + if ($quilt_mode =~ m/gbp|dpm|unapplied/) { + quiltify_splitbrain($clogp, $diffbits); return; }