This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch master in repository dpkg.
commit 599e3c1a9f3be8687c00b681f107e7b98bb454ae Author: Guillem Jover <[email protected]> Date: Mon Apr 9 02:04:15 2018 +0200 dpkg-divert: Warn when using --add or --remove w/o --rename or --no-rename Using --no-rename as the default optimizes for the wrong case, as that's the exception, and while the safest option, it is needed only by packages that are part of the pseudo-Essential set. It's also cumbersome for the --local case. We will emit a warning asking those to be explicit, so that we can switch the default to --rename during the 1.20.x cycle. Prompted-by: Paul Wise <[email protected]> --- debian/changelog | 1 + man/dpkg-divert.man | 4 +++- src/divertcmd.c | 16 +++++++++++++++- src/t/dpkg_divert.t | 9 +++++---- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index ff6e56b..f6ad3a5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -49,6 +49,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium descriptions, and to make them always present independent of NDEBUG. * Add a new --no-rename option to dpkg-divert. This is the current default behavior, but it will make it possible to do a default switch in 1.20.x. + * Warn when using dpkg-divert --add or --remove w/o --rename or --no-rename. * Architecture support: - Add support for riscv64 CPU. Closes: #822914 Thanks to Manuel A. Fernandez Montecelo <[email protected]> diff --git a/man/dpkg-divert.man b/man/dpkg-divert.man index 48fcc0c..8631c20 100644 --- a/man/dpkg-divert.man +++ b/man/dpkg-divert.man @@ -46,9 +46,11 @@ contains those files. .TP .RB [ \-\-add "] \fIfile\fP" Add a diversion for \fIfile\fP. +The file is currently not renamed, see \fB\-\-rename\fP. .TP .BI \-\-remove " file" Remove a diversion for \fIfile\fP. +The file is currently not renamed, see \fB\-\-rename\fP. .TP .BI \-\-list " glob-pattern" List diversions matching \fIglob-pattern\fP. @@ -97,7 +99,7 @@ diversion into the database (since dpkg 1.19.1). This is intended for diversions of files from the \fBEssential\fP package set, where the temporary disappearance of the original file is not acceptable, as it can render the system non-functional. -This is the default behavior. +This is the default behavior, but that will change in the dpkg 1.20.x cycle. .TP .B \-\-test Test mode, i.e. don't actually perform any changes, just demonstrate. diff --git a/src/divertcmd.c b/src/divertcmd.c index f5efb63..d46331f 100644 --- a/src/divertcmd.c +++ b/src/divertcmd.c @@ -60,7 +60,7 @@ static const char *opt_divertto = NULL; static int opt_verbose = 1; static int opt_test = 0; -static int opt_rename = 0; +static int opt_rename = -1; static void @@ -119,6 +119,17 @@ usage(const struct cmdinfo *cip, const char *value) exit(0); } +static void +opt_rename_setup(void) +{ + if (opt_rename >= 0) + return; + + opt_rename = 0; + warning(_("please specify --no-rename explicitly, the default " + "will change to --rename in 1.20.x")); +} + struct file { const char *name; enum { @@ -422,6 +433,7 @@ diversion_add(const char *const *argv) struct pkgset *pkgset; opt_pkgname_match_any = false; + opt_rename_setup(); /* Handle filename. */ if (!filename || argv[1]) @@ -552,6 +564,8 @@ diversion_remove(const char *const *argv) struct file file_from, file_to; struct pkgset *pkgset; + opt_rename_setup(); + if (!filename || argv[1]) badusage(_("--%s needs a single argument"), cipaction->olong); diff --git a/src/t/dpkg_divert.t b/src/t/dpkg_divert.t index 71e3b24..cf118e2 100644 --- a/src/t/dpkg_divert.t +++ b/src/t/dpkg_divert.t @@ -300,7 +300,7 @@ note('Adding diversion (2)'); install_diversions(''); system("touch $testdir/foo"); -call_divert(['--add', "$testdir/foo"], +call_divert(['--no-rename', '--add', "$testdir/foo"], expect_stdout_like => qr{ Adding.*local.*diversion.* \Q$testdir\E/foo.* @@ -461,8 +461,8 @@ note('Remove diversions'); install_diversions(''); -call_divert(['--remove', '/bin/sh'], expect_stdout_like => qr/No diversion/, expect_stderr => ''); -call_divert(['--remove', '--quiet', '/bin/sh'], expect_stdout => '', expect_stderr => ''); +call_divert(['--no-rename', '--remove', '/bin/sh'], expect_stdout_like => qr/No diversion/, expect_stderr => ''); +call_divert(['--no-rename', '--remove', '--quiet', '/bin/sh'], expect_stdout => '', expect_stderr => ''); cleanup(); @@ -522,7 +522,8 @@ call_divert(["$testdir/foo"]); call_divert(["$testdir/bar"]); call_divert(['--package', 'bash', "$testdir/baz"]); -call_divert(['--quiet', '--package', 'bash', '--remove', "$testdir/baz"], +call_divert(['--no-rename', '--quiet', '--package', 'bash', + '--remove', "$testdir/baz"], expect_stdout => '', expect_stderr => ''); diversions_eq(<<"EOF"); $testdir/foo -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/dpkg/dpkg.git

