This patch handles some issues with --vc-files/--no--vc-files.
gnulib-tool.py would always print this in the actioncmd message at the
top of files. The proper behavior would be to check if vc_files ==
None before treating it as a bool. In gnulib-tool.sh it is empty else
true/false.

The second issue is that gnulib-cache.m4 would have a Python boolean:

gl_VC_FILES([True])
# Or
gl_VC_FILES([False])

This fixes that as well.

It seems that --vc-files is still broken for '--add-import', see
./test-oath-toolkit-2.sh. From what I could tell, it seems that
GLImport.__init__ doesn't like picking it up from gnulib-cache.m4.
Somewhere around line 126 and onwards, starting here:

# Create regex object and keys.
pattern = re.compile('^(gl_.*?)\\((.*?)\\)$', re.S | re.M)

I'll hopefully get around to fixing that tomorrow.

Collin
From 8cf4f5f029ed478bf5499eaa94df96105df5baf3 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Sat, 23 Mar 2024 00:53:55 -0700
Subject: [PATCH 2/2] gnulib-tool.py: Don't use --[no]-vc-files unless
 explicitly given.

* pygnulib/GLImport.py (GLImport.actioncmd): Check that vc_files is not
None before treating it as a bool.
(GLImport.gnulib_cache): Convert Python bools to shell bools before
printing them to gnulib-cache.m4.
---
 ChangeLog            |  8 ++++++++
 pygnulib/GLImport.py | 13 ++++++++-----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a4bc9eda0b..f182b28a16 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-03-23  Collin Funk  <collin.fu...@gmail.com>
+
+	gnulib-tool.py: Don't use --[no]-vc-files unless explicitly given.
+	* pygnulib/GLImport.py (GLImport.actioncmd): Check that vc_files is not
+	None before treating it as a bool.
+	(GLImport.gnulib_cache): Convert Python bools to shell bools before
+	printing them to gnulib-cache.m4.
+
 2024-03-22  Collin Funk  <collin.fu...@gmail.com>
 
 	gnulib-tool.py: Follow gnulib-tool changes, part 69.
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index ca266242e2..c1893fc3dd 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -473,10 +473,12 @@ class GLImport(object):
             actioncmd += ' \\\n#  --po-domain=%s' % podomain
         if witness_c_macro:
             actioncmd += ' \\\n#  --witness-c-macro=%s' % witness_c_macro
-        if vc_files == True:
-            actioncmd += ' \\\n#  --vc-files'
-        elif vc_files == False:
-            actioncmd += ' \\\n#  --no-vc-files'
+        # Don't print --vc-files/--no-vc-files unless explicitly given.
+        if vc_files != None:
+            if vc_files:
+                actioncmd += ' \\\n#  --vc-files'
+            else:
+                actioncmd += ' \\\n#  --no-vc-files'
         if len(avoids) > 0:
             actioncmd += ''.join([f' \\\n#  --avoid={x}' for x in avoids])
         if len(modules) > 0:
@@ -601,7 +603,8 @@ class GLImport(object):
         emit += 'gl_PO_DOMAIN([%s])\n' % podomain
         emit += 'gl_WITNESS_C_MACRO([%s])\n' % witness_c_macro
         if vc_files != None:
-            emit += 'gl_VC_FILES([%s])\n' % vc_files
+            # Convert Python bools to shell (True -> true).
+            emit += 'gl_VC_FILES([%s])\n' % str(vc_files).lower()
         return constants.nlconvert(emit)
 
     def gnulib_comp(self, filetable, gentests):
-- 
2.44.0

Reply via email to