changeset 271:6fe88de236cb

treesum: Implement the --half/-H option: follow symlinks given on the command line but no other symlinks. This a sibling to -P, -L and -p.
author Franz Glasner <fzglas.hg@dom66.de>
date Tue, 18 Feb 2025 18:24:16 +0100
parents 42f4ca423ab3
children b4137ebd8e79
files cutils/treesum.py
diffstat 1 files changed, 16 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/cutils/treesum.py	Tue Feb 18 16:07:28 2025 +0100
+++ b/cutils/treesum.py	Tue Feb 18 18:24:16 2025 +0100
@@ -70,14 +70,13 @@
             default=FollowSymlinkConfig(False, False, True),
             dest="follow_symlinks",
             help="""Follow symbolic links to directories when walking a
-directory tree. Augments --physical and -p.""")
+directory tree. Augments --physical, --half and -p.""")
         gp.add_argument(
             "--follow-file-symlinks", action=SymlinkAction,
             const="follow-file-symlinks",
-            default=FollowSymlinkConfig(False, False, True),
             dest="follow_symlinks",
             help="""Follow symbolic links to files when walking a
-directory tree. Augments --physical.""")
+directory tree. Augments --physical and --half.""")
         gp.add_argument(
             "--full-mode", action="store_true", dest="metadata_full_mode",
             help="Consider all mode bits as returned from stat(2) when "
@@ -92,14 +91,21 @@
 `normal' prints just whether Python 2 or Python 3 is used, and `none'
 suppresses the output completely. The default is `normal'.""")
         gp.add_argument(
+            "--half", "-H", action=SymlinkAction, dest="follow_symlinks",
+            const=FollowSymlinkConfig(True, False, False),
+            help="""Follow symbolic links given on the command line but do
+not follow symlinks while traversing the directory tree.
+Overwrites any other symlink related options
+(--physical, --logical, -p, --no-follow-directory-symlinks,
+--no-follow-file-symlinks, et al.).""")
+        gp.add_argument(
             "--logical", "-L", action=SymlinkAction, dest="follow_symlinks",
             const=FollowSymlinkConfig(True, True, True),
             help="""Follow symbolic links everywhere: on command line
 arguments and -- while walking -- directory and file symbolic links.
 Overwrites any other symlink related options
-(--physical,-p,  no-follow-directory-symlinks, no-follow-file-symlinks,
-et al.).
-""")
+(--physical, --half, -p,  --no-follow-directory-symlinks,
+--no-follow-file-symlinks, et al.).""")
         gp.add_argument(
             "--minimal", nargs="?", const="", default=None, metavar="TAG",
             help="Produce minimal output only. If a TAG is given and not "
@@ -144,8 +150,8 @@
             help="""Do not follow any symbolic links whether they are given
 on the command line or when walking the directory tree.
 Overwrites any other symlink related options
-(--logical, -p, follow-directory-symlinks, follow-file-symlinks, et al.).
-This is the default.""")
+(--logical, --half, -p, --follow-directory-symlinks, --follow-file-symlinks,
+et al.).""")
         gp.add_argument(
             "-p", action=SymlinkAction, dest="follow_symlinks",
             const=FollowSymlinkConfig(False, False, True),
@@ -153,8 +159,8 @@
 whether they are given on the command line or when walking the directory tree,
 but follow symbolic links to files.
 Overwrites any other symlink related options
-(--logical, --physical, follow-directory-symlinks, no-follow-file-symlinks,
-et al.).
+(--logical, --half, --physical, --follow-directory-symlinks,
+--no-follow-file-symlinks, et al.).
 This is the default.""")
         gp.add_argument(
             "--print-size", action="store_true",