Collin Funk wrote:
> The behavior of gnulib-tool.sh is that if --local-symlink or
> --local-hardlink are not specified, the default value would be the value
> of --symlink or --hardlink. If none were specified, it would use a
> normal copy.

Yes, the behaviour we want,
  - for backward compatibility,
  - so that passing --symlink alone or --hardlink alone has the desired effect.

> I pushed the attached patch to fix it.

Unfortunately, the default handling in the GLConfig methods update, default,
isdefault is broken now. These methods assume that every property has a default
value that is independent of the other properties.

I'm pushing this fix.


2026-03-06  Bruno Haible  <[email protected]>

        gnulib-tool.py: Fix default handling for --local-{symlink,hardlink}.
        * pygnulib/GLConfig.py (GLConfig.__init__): Allow lcopymode to remain
        None.
        (GLConfig.default): Change lcopymode's default to be None.
        (GLConfig.checkLCopyMode): Update signature.
        (GLConfig.resetLCopyMode): Change default value to None.
        * pygnulib/GLFileSystem.py (GLFileSystem.shouldLink): Update.

diff --git a/pygnulib/GLConfig.py b/pygnulib/GLConfig.py
index 528ff91106..5a409df4ce 100644
--- a/pygnulib/GLConfig.py
+++ b/pygnulib/GLConfig.py
@@ -208,10 +208,8 @@ def __init__(self,
         self.setCopyMode(copymode)
         # lcopymode (--local-symlink and --local-hardlink)
         self.resetLCopyMode()
-        if lcopymode == None:
-            # Default to the mode used for non-local modules.
-            lcopymode = copymode
-        self.setLCopyMode(lcopymode)
+        if lcopymode != None:
+            self.setLCopyMode(lcopymode)
         # configure_ac
         self.resetAutoconfFile()
         if configure_ac != None:
@@ -321,9 +319,9 @@ def default(self, key: str) -> Any:
                          'automake_subdir', 'automake_subdir_tests',
                          'libtests', 'dryrun']:
                 return False
-            elif key in ['copymode', 'lcopymode']:
+            elif key in ['copymode']:
                 return CopyAction.Copy
-            elif key in ['lgpl', 'gpl', 'libtool', 'conddeps', 'vc_files']:
+            elif key in ['lgpl', 'gpl', 'libtool', 'conddeps', 'vc_files', 
'lcopymode']:
                 return None
             elif key == 'errors':
                 return True
@@ -1113,7 +1111,7 @@ def resetCopyMode(self) -> None:
         self.table['copymode'] = CopyAction.Copy
 
     # Define lcopymode methods.
-    def checkLCopyMode(self) -> CopyAction:
+    def checkLCopyMode(self) -> CopyAction | None:
         '''Check if pygnulib will copy files, create symlinks, or create hard 
links,
         only for files from the local override directories.'''
         return self.table['lcopymode']
@@ -1128,9 +1126,9 @@ def setLCopyMode(self, value: CopyAction) -> None:
                             % type(value).__name__)
 
     def resetLCopyMode(self) -> None:
-        '''Reset the method used for creating files to copying instead of 
linking,
+        '''Reset the method used for creating files,
         only for files from the local override directories.'''
-        self.table['lcopymode'] = CopyAction.Copy
+        self.table['lcopymode'] = None
 
     # Define verbosity methods.
     def getVerbosity(self) -> int:
diff --git a/pygnulib/GLFileSystem.py b/pygnulib/GLFileSystem.py
index be2ab3e355..4f3c53b2d6 100644
--- a/pygnulib/GLFileSystem.py
+++ b/pygnulib/GLFileSystem.py
@@ -130,7 +130,7 @@ def shouldLink(self, original: str, lookedup: str) -> bool:
 
         # Don't bother checking the localpath's if we end up performing the 
same
         # action anyways.
-        if copymode != lcopymode:
+        if lcopymode != None and lcopymode != copymode:
             for localdir in localpath:
                 if lookedup == joinpath(localdir, original):
                     return lcopymode




Reply via email to