From c33cd343b9709f9c765ed81ebf98d22813431663 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: May 28 2026 13:43:34 +0000 Subject: Fix SRPM import for files with a backslash in the name For packages like open-vm-tools, there are files containing a backslash in their names. In such cases, the standard 'git ls-files' output gets escaped and quoted, making it difficult to parse: $ git ls-files .gitignore changelog open-vm-tools-gcc16.patch open-vm-tools-sigc++3.patch open-vm-tools.conf open-vm-tools.spec "run-vmblock\\x2dfuse.mount" sources vgauthd.service vmtoolsd.pam vmtoolsd.service We'd have to strip double-quotes, and double back-slashes. It is easier to use the '-z' option, as Git doesn't escape backslashes when using null-byte delimiters. This also allows us to clean up the empty repository check. Signed-off-by: Pavel Raiskup --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index 46ca599..7e923d1 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -2069,17 +2069,14 @@ class Commands(object): '.fmf/*', '*.fmf', 'changelog'] # Get a list of files we're currently tracking - ourfiles = self.repo.git.ls_files().split('\n') - if ourfiles == ['']: - # Repository doesn't contain any files - ourfiles = [] - else: - # Trim out sources and .gitignore - for file in ('.gitignore', 'sources'): - try: - ourfiles.remove(file) - except ValueError: - pass + ourfiles = self.repo.git.ls_files('-z').rstrip('\0') + ourfiles = ourfiles.split('\0') if ourfiles else [] + # Trim out sources and .gitignore + for file in ('.gitignore', 'sources'): + try: + ourfiles.remove(file) + except ValueError: + pass # Things work better if we're in our repository directory oldpath = os.getcwd()