This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=52427d9075b4b062fa0db16a70d2c2bda6407857

commit 52427d9075b4b062fa0db16a70d2c2bda6407857
Author: Guillem Jover <[email protected]>
AuthorDate: Wed Sep 12 00:46:32 2018 +0200

    dpkg: Switch to set the default force option from the forceinfos array
---
 debian/changelog |  1 +
 src/force.c      | 16 ++++++++++++++--
 src/force.h      |  2 ++
 src/main.c       |  1 +
 4 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 69799d8b9..6dfe1f6f8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -19,6 +19,7 @@ dpkg (1.19.5) UNRELEASED; urgency=medium
     - dpkg: Do not hardcode the program name in the --force-help output.
     - dpkg: Switch force options from individual variables to bit fields.
     - dpkg: Switch from a char to an enum to track the force options types.
+    - dpkg: Switch to set the default force option from the forceinfos array.
   * Build system:
     - Check whether this dist is a release, based only on the version format.
       This will avoid having to do a two staged release to get a proper perl
diff --git a/src/force.c b/src/force.c
index 7fabfb541..15895faf4 100644
--- a/src/force.c
+++ b/src/force.c
@@ -37,8 +37,8 @@
 
 #include "force.h"
 
-static int force_mask = FORCE_ALL;
-static int force_flags = FORCE_DOWNGRADE;
+static int force_mask;
+static int force_flags;
 
 enum forcetype {
        FORCETYPE_DISABLED,
@@ -321,6 +321,18 @@ parse_force(const char *value, bool set)
 }
 
 void
+set_force_default(int mask)
+{
+       const struct forceinfo *fip;
+
+       force_mask = mask;
+
+       for (fip = forceinfos; fip->name; fip++)
+               if (fip->type == FORCETYPE_ENABLED)
+                       set_force(fip->flag);
+}
+
+void
 set_force_option(const struct cmdinfo *cip, const char *value)
 {
        bool set = cip->arg_int;
diff --git a/src/force.h b/src/force.h
index 28776eefc..671b260a7 100644
--- a/src/force.h
+++ b/src/force.h
@@ -67,6 +67,8 @@ void
 parse_force(const char *value, bool set);
 
 void
+set_force_default(int mask);
+void
 set_force_option(const struct cmdinfo *cip, const char *value);
 void
 reset_force_option(const struct cmdinfo *cip, const char *value);
diff --git a/src/main.c b/src/main.c
index 35be30d20..6ba5c5090 100644
--- a/src/main.c
+++ b/src/main.c
@@ -743,6 +743,7 @@ int main(int argc, const char *const *argv) {
   dpkg_locales_init(PACKAGE);
   dpkg_program_init("dpkg");
   dpkg_options_load(DPKG, cmdinfos);
+  set_force_default(FORCE_ALL);
   dpkg_options_parse(&argv, cmdinfos, printforhelp);
 
   /* When running as root, make sure our primary group is also root, so

-- 
Dpkg.Org's dpkg

Reply via email to