summaryrefslogtreecommitdiff
path: root/dgit
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2013-10-22 14:53:11 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2013-10-22 14:53:11 +0100
commit59235957912b6f55e150d533749aad62b1647e8e (patch)
tree683ce460907b8eadc3e5efc4219336094e9b9348 /dgit
parent7b20daf717d8f5559908a794aab0425974934f47 (diff)
parentf5cc5221e5f7298d88c384af112b33a3287a2a1a (diff)
Merge branch 'master' into wip.remote
Conflicts: debian/changelog dgit
Diffstat (limited to 'dgit')
-rwxr-xr-xdgit68
1 files changed, 41 insertions, 27 deletions
diff --git a/dgit b/dgit
index f6c129a..e46da88 100755
--- a/dgit
+++ b/dgit
@@ -83,6 +83,8 @@ our $keyid;
our $debug = 0;
open DEBUG, ">/dev/null" or die $!;
+autoflush STDOUT 1;
+
our $remotename = 'dgit';
our @ourdscfield = qw(Dgit Vcs-Dgit-Master);
our $branchprefix = 'dgit';
@@ -376,6 +378,14 @@ sub runcmd_ordryrun {
}
}
+sub runcmd_ordryrun_local {
+ if ($dryrun <= 1) {
+ runcmd @_;
+ } else {
+ dryrun_report @_;
+ }
+}
+
sub shell_cmd {
my ($first_shell, @cmd) = @_;
return qw(sh -ec), $first_shell.'; exec "$@"', 'x', @cmd;
@@ -391,6 +401,7 @@ main usages:
important dgit options:
-k<keyid> sign tag and package with <keyid> instead of default
--dry-run -n do not change anything, but go through the motions
+ --damp-run -L like --dry-run but make local changes, without signing
--new -N allow introducing a new package
--debug -D increase debug level
-c<name>=<value> set git config option (used directly by dgit too)
@@ -865,7 +876,7 @@ sub ensure_we_have_orig () {
$origurl .= "/$f";
die "$f ?" unless $f =~ m/^${package}_/;
die "$f ?" if $f =~ m#/#;
- runcmd_ordryrun shell_cmd 'cd ..', @dget,'--',$origurl;
+ runcmd_ordryrun_local shell_cmd 'cd ..', @dget,'--',$origurl;
}
}
@@ -886,7 +897,7 @@ sub is_fast_fwd ($$) {
}
sub git_fetch_us () {
- runcmd_ordryrun @git, qw(fetch),access_giturl(),fetchspec();
+ runcmd_ordryrun_local @git, qw(fetch),access_giturl(),fetchspec();
}
sub fetch_from_archive () {
@@ -993,7 +1004,7 @@ END
}
if ($lastpush_hash ne $hash) {
my @upd_cmd = (@git, qw(update-ref -m), 'dgit fetch', lrref(), $hash);
- if (!$dryrun) {
+ if ($dryrun <= 1) {
cmdoutput @upd_cmd;
} else {
dryrun_report @upd_cmd;
@@ -1005,7 +1016,7 @@ END
sub clone ($) {
my ($dstdir) = @_;
canonicalise_suite();
- badusage "dry run makes no sense with clone" if $dryrun;
+ badusage "dry run makes no sense with clone" if $dryrun > 1;
mkdir $dstdir or die "$dstdir $!";
chdir "$dstdir" or die "$dstdir $!";
runcmd @git, qw(init -q);
@@ -1017,7 +1028,7 @@ sub clone ($) {
if (check_for_git()) {
progress "fetching existing git history";
git_fetch_us();
- runcmd_ordryrun @git, qw(fetch origin);
+ runcmd_ordryrun_local @git, qw(fetch origin);
} else {
progress "starting new git history";
}
@@ -1036,7 +1047,7 @@ sub fetch () {
sub pull () {
fetch();
- runcmd_ordryrun @git, qw(merge -m),"Merge from $csuite [dgit]",
+ runcmd_ordryrun_local @git, qw(merge -m),"Merge from $csuite [dgit]",
lrref();
printdone "fetched to ".lrref()." and merged into HEAD";
}
@@ -1057,25 +1068,20 @@ sub check_not_dirty () {
sub commit_quilty_patch () {
my $output = cmdoutput @git, qw(status --porcelain);
my %adds;
- my $bad=0;
foreach my $l (split /\n/, $output) {
next unless $l =~ m/\S/;
if ($l =~ m{^(?:\?\?| M) (.pc|debian/patches)}) {
$adds{$1}++;
- } else {
- print STDERR "git status: $l\n";
- $bad++;
}
}
- fail "unexpected output from git status (is tree clean?)" if $bad;
if (!%adds) {
progress "nothing quilty to commit, ok.";
return;
}
- runcmd_ordryrun @git, qw(add), sort keys %adds;
+ runcmd_ordryrun_local @git, qw(add), sort keys %adds;
my $m = "Commit Debian 3.0 (quilt) metadata";
progress "$m";
- runcmd_ordryrun @git, qw(commit -m), $m;
+ runcmd_ordryrun_local @git, qw(commit -m), $m;
}
sub madformat ($) {
@@ -1256,7 +1262,7 @@ sub dopush () {
my $tag_obj_hash = cmdoutput @git, qw(hash-object -w -t tag), $tagobjfn;
runcmd_ordryrun @git, qw(verify-tag), $tag_obj_hash;
- runcmd_ordryrun @git, qw(update-ref), "refs/tags/$tag", $tag_obj_hash;
+ runcmd_ordryrun_local @git, qw(update-ref), "refs/tags/$tag", $tag_obj_hash;
runcmd_ordryrun @git, qw(tag -v --), $tag;
if (!check_for_git()) {
@@ -1266,7 +1272,7 @@ sub dopush () {
runcmd_ordryrun @git, qw(update-ref -m), 'dgit push', lrref(), 'HEAD';
if (!$we_are_responder) {
- if (!$dryrun) {
+ if ($dryrun <= 1) {
rename "../$dscfn.tmp","../$dscfn" or die "$dscfn $!";
} else {
progress "[new .dsc left in $dscfn.tmp]";
@@ -1274,7 +1280,7 @@ sub dopush () {
}
if ($we_are_responder) {
- my $dryrunsuffix = $dryrun ? ".tmp" : "";
+ my $dryrunsuffix = $dryrun > 1 ? ".tmp" : "";
responder_receive_files('signed-dsc-changes',
"../$dscfn$dryrunsuffix",
"$changesfile$dryrunsuffix");
@@ -1577,7 +1583,7 @@ END
local $ENV{'EDITOR'} = cmdoutput qw(realpath --), $0;
local $ENV{'VISUAL'} = $ENV{'EDITOR'};
local $ENV{$fakeeditorenv} = cmdoutput qw(realpath --), $descfn;
- runcmd_ordryrun @dpkgsource, qw(--commit .), $patchname;
+ runcmd_ordryrun_local @dpkgsource, qw(--commit .), $patchname;
}
if (!open P, '>>', ".pc/applied-patches") {
@@ -1622,7 +1628,7 @@ sub cmd_build {
badusage "dgit build implies --clean=dpkg-source"
if $cleanmode ne 'dpkg-source';
build_prep();
- runcmd_ordryrun @dpkgbuildpackage, qw(-us -uc), changesopts(), @ARGV;
+ runcmd_ordryrun_local @dpkgbuildpackage, qw(-us -uc), changesopts(), @ARGV;
printdone "build successful\n";
}
@@ -1638,7 +1644,7 @@ sub cmd_git_build {
push @cmd, "--git-debian-branch=".lbranch();
}
push @cmd, changesopts();
- runcmd_ordryrun @cmd, @ARGV;
+ runcmd_ordryrun_local @cmd, @ARGV;
printdone "build successful\n";
}
@@ -1647,10 +1653,11 @@ sub build_source {
$sourcechanges = "${package}_".(stripepoch $version)."_source.changes";
$dscfn = dscfn($version);
if ($cleanmode eq 'dpkg-source') {
- runcmd_ordryrun (@dpkgbuildpackage, qw(-us -uc -S)), changesopts();
+ runcmd_ordryrun_local (@dpkgbuildpackage, qw(-us -uc -S)),
+ changesopts();
} else {
if ($cleanmode eq 'git') {
- runcmd_ordryrun @git, qw(clean -xdf);
+ runcmd_ordryrun_local @git, qw(clean -xdf);
} elsif ($cleanmode eq 'none') {
} else {
die "$cleanmode ?";
@@ -1658,9 +1665,9 @@ sub build_source {
my $pwd = cmdoutput qw(env - pwd);
my $leafdir = basename $pwd;
chdir ".." or die $!;
- runcmd_ordryrun @dpkgsource, qw(-b --), $leafdir;
+ runcmd_ordryrun_local @dpkgsource, qw(-b --), $leafdir;
chdir $pwd or die $!;
- runcmd_ordryrun qw(sh -ec),
+ runcmd_ordryrun_local qw(sh -ec),
'exec >$1; shift; exec "$@"','x',
"../$sourcechanges",
@dpkggenchanges, qw(-S), changesopts();
@@ -1677,7 +1684,7 @@ sub cmd_sbuild {
build_source();
chdir ".." or die $!;
my $pat = "${package}_".(stripepoch $version)."_*.changes";
- if (!$dryrun) {
+ if ($dryrun <= 1) {
stat $dscfn or fail "$dscfn (in parent directory): $!";
stat $sourcechanges or fail "$sourcechanges (in parent directory): $!";
foreach my $cf (glob $pat) {
@@ -1688,7 +1695,7 @@ sub cmd_sbuild {
runcmd_ordryrun @sbuild, @ARGV, qw(-d), $isuite, $dscfn;
runcmd_ordryrun @mergechanges, glob $pat;
my $multichanges = "${package}_".(stripepoch $version)."_multi.changes";
- if (!$dryrun) {
+ if ($dryrun <= 1) {
stat $multichanges or fail "$multichanges: $!";
}
printdone "build successful, results in $multichanges\n" or die $!;
@@ -1724,6 +1731,9 @@ sub parseopts () {
if (m/^--/) {
if (m/^--dry-run$/) {
push @ropts, $_;
+ $dryrun=2;
+ } elsif (m/^--damp-run$/) {
+ push @ropts, $_;
$dryrun=1;
} elsif (m/^--no-sign$/) {
push @ropts, $_;
@@ -1768,7 +1778,10 @@ sub parseopts () {
} else {
while (m/^-./s) {
if (s/^-n/-/) {
- push @ropts, $_;
+ push @ropts, $&;
+ $dryrun=2;
+ } elsif (s/^-L/-/) {
+ push @ropts, $&;
$dryrun=1;
} elsif (s/^-h/-/) {
cmd_help();
@@ -1819,7 +1832,8 @@ if ($ENV{$fakeeditorenv}) {
delete $ENV{'DGET_UNPACK'};
parseopts();
-print STDERR "DRY RUN ONLY\n" if $dryrun;
+print STDERR "DRY RUN ONLY\n" if $dryrun > 1;
+print STDERR "DAMP RUN - WILL MAKE LOCAL (UNSIGNED) CHANGES\n" if $dryrun == 1;
if (!@ARGV) {
print STDERR $helpmsg or die $!;
exit 8;