diff options
3 files changed, 35 insertions, 4 deletions
diff --git a/debian/changelog b/debian/changelog
index 4f2e64d..5724e02 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -82,6 +82,10 @@ dgit (0.23~) unstable; urgency=low
* Document that dgit repos are cloneable with git, in dgit(1)
section MODEL. [Andreas Barth.] Closes:#768470.
+ * --clean=git and --clean=none cause dgit to pass -nc to
+ dpkg-buildpackage, suppressing calls to the package's clean target.
+ Also, expand the documentation in this area slightly. Closes:#768590.
dgit (0.22.1) unstable; urgency=high
diff --git a/dgit b/dgit
index 19c0657..f0f1651 100755
--- a/dgit
+++ b/dgit
@@ -2628,17 +2628,35 @@ sub changesopts () {
return @opts;
+sub massage_dbp_args ($) {
+ my ($cmd) = @_;
+ return unless $cleanmode =~ m/git|none/;
+ debugcmd '#massaging#', @$cmd if $debuglevel>1;
+ my @newcmd = shift @$cmd;
+ # -nc has the side effect of specifying -b if nothing else specified
+ push @newcmd, '-nc';
+ # and some combinations of -S, -b, et al, are errors, rather than
+ # later simply overriding earlier
+ push @newcmd, '-F' unless grep { m/^-[bBASF]$/ } @$cmd;
+ push @newcmd, @$cmd;
+ @$cmd = @newcmd;
sub cmd_build {
- runcmd_ordryrun_local @dpkgbuildpackage, qw(-us -uc), changesopts(), @ARGV;
+ my @dbp = (@dpkgbuildpackage, qw(-us -uc), changesopts(), @ARGV);
+ massage_dbp_args \@dbp;
+ runcmd_ordryrun_local @dbp;
printdone "build successful\n";
sub cmd_git_build {
+ my @dbp = @dpkgbuildpackage;
+ massage_dbp_args \@dbp;
my @cmd =
(qw(git-buildpackage -us -uc --git-no-sign-tags),
- "--git-builder=@dpkgbuildpackage");
+ "--git-builder=@dbp");
unless (grep { m/^--git-debian-branch|^--git-ignore-branch/ } @ARGV) {
push @cmd, "--git-debian-branch=".lbranch();
diff --git a/dgit.1 b/dgit.1
index 9705f0a..f183e8e 100644
--- a/dgit.1
+++ b/dgit.1
@@ -248,11 +248,20 @@ Valid with dgit fetch and dgit pull, only.
The source tree should be cleaned, before building a source package
with one of the build options, using
.BR "git clean -xdf" .
-This will delete all files which are not tracked by git.
+This will delete all files which are not tracked by git. Also, -wg
+causes dgit to pass
+.B -nc
+to dpkg-buildpackage, which prevents the package's own clean target
+from being run.
+--clean=git is useful when the package's clean target is troublesome;
+the downside is simply that git clean may delete files you forgot to
+git add.
.BR --clean=none | -wn
Do not clean the tree before building a source package. If there are
-files which are not in git, a subsequent dgit push will fail.
+files which are not in git, or if the build creates such files, a
+subsequent dgit push will fail.
.BR --clean=dpkg-source | -wd
Use dpkg-buildpackage to do the clean, so that the source package