The following commit has been merged in the master branch:
commit d3d0d1275b32972e23d9b6476335486576dc7be2
Author: Guillem Jover <[email protected]>
Date: Sat Mar 31 20:04:48 2012 +0200
dpkg-divert: Only check for --divert being absolute when setting it
There's no point in checking it at --add time because even if it was
not specified and it got constructed from filename, it can never be
non-absolute as filename has already been checked for that.
diff --git a/src/divertcmd.c b/src/divertcmd.c
index 69602b5..2ce8a3a 100644
--- a/src/divertcmd.c
+++ b/src/divertcmd.c
@@ -409,8 +409,6 @@ diversion_add(const char *const *argv)
m_asprintf(&str, "%s.distrib", filename);
opt_divertto = str;
}
- if (opt_divertto[0] != '/')
- badusage(_("filename \"%s\" is not absolute"), opt_divertto);
if (strcmp(filename, opt_divertto) == 0)
badusage(_("cannot divert file '%s' to itself"), filename);
@@ -686,6 +684,8 @@ setdivertto(const struct cmdinfo *cip, const char *value)
{
opt_divertto = value;
+ if (opt_divertto[0] != '/')
+ badusage(_("filename \"%s\" is not absolute"), opt_divertto);
if (strchr(opt_divertto, '\n') != NULL)
badusage(_("divert-to may not contain newlines"));
}
diff --git a/src/t/100_dpkg_divert.t b/src/t/100_dpkg_divert.t
index a337b56..8d0e991 100644
--- a/src/t/100_dpkg_divert.t
+++ b/src/t/100_dpkg_divert.t
@@ -33,7 +33,7 @@ if (! -x "@dd") {
exit(0);
}
-plan tests => 235;
+plan tests => 237;
sub cleanup {
system("rm -rf $tmpdir && mkdir -p $testdir");
@@ -138,7 +138,8 @@ call_divert(['--version'], expect_stdout_like =>
qr/.*dpkg-divert.*free software
call_divert_badusage(['--jachsmitbju'], qr/unknown option/);
call_divert_badusage(['--add', '--remove'],
qr/(conflicting|two).*remove.*add.*/s);
call_divert_badusage(['--divert'], qr/(takes a value|needs.*argument)/);
-call_divert_badusage(['--divert', "foo\nbar"], qr/newline/);
+call_divert_badusage(['--divert', "foo"], qr/absolute/);
+call_divert_badusage(['--divert', "/foo\nbar"], qr/newline/);
call_divert_badusage(['--package'], qr/(takes a value|needs.*argument)/);
call_divert_badusage(['--package', "foo\nbar"], qr/newline/);
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]