MestreLion / git-tools

Assorted git tools, including git-restore-mtime
GNU General Public License v3.0
295 stars 74 forks source link

Sparse checkout excluded files & folders not ignored by -s flag #70

Open satmandu opened 8 months ago

satmandu commented 8 months ago

Reproducer steps:

git clone --depth=1 https://github.com/chromebrew/chromebrew.git test
cd test
git sparse-checkout set packages manifest/x86_64 lib commands bin crew tests tools
git-restore-mtime -s 

I get this output:

7,762 files to be processed in work dir
ERROR: [Errno 2] No such file or directory: .github/ISSUE_TEMPLATE/bug_report.md
ERROR: [Errno 2] No such file or directory: .github/ISSUE_TEMPLATE
ERROR: [Errno 2] No such file or directory: .github/ISSUE_TEMPLATE/config.yml
ERROR: [Errno 2] No such file or directory: .github/PULL_REQUEST_TEMPLATE.md
ERROR: [Errno 2] No such file or directory: .github
ERROR: [Errno 2] No such file or directory: .github/workflows/Handoff.yml
ERROR: [Errno 2] No such file or directory: .github/workflows
ERROR: [Errno 2] No such file or directory: .github/workflows/Markdown-lint.yml
ERROR: [Errno 2] No such file or directory: .github/workflows/Repology.yml
ERROR: [Errno 2] No such file or directory: .github/workflows/Rubocop.yml
ERROR: [Errno 2] No such file or directory: .github/workflows/ShellCheck.yml
ERROR: [Errno 2] No such file or directory: .github/workflows/Unit-Test.yml
ERROR: [Errno 2] No such file or directory: .github/workflows/YAMLlint.yml
ERROR: [Errno 2] No such file or directory: images/brew.png
ERROR: [Errno 2] No such file or directory: images
ERROR: [Errno 2] No such file or directory: images/discord.svg
ERROR: [Errno 2] No such file or directory: images/slack.svg
ERROR: [Errno 2] No such file or directory: manifest/armv7l/a/a2png.filelist
ERROR: [Errno 2] No such file or directory: manifest/armv7l/a
ERROR: [Errno 2] No such file or directory: manifest/armv7l/a/a2ps.filelist
ERROR: [Errno 2] No such file or directory: manifest/armv7l/a/aalib.filelist
ERROR: [Errno 2] No such file or directory: manifest/armv7l/a/abcde.filelist
ERROR: [Errno 2] No such file or directory: manifest/armv7l/a/abcl.filelist
ERROR: [Errno 2] No such file or directory: manifest/armv7l/a/abseil_cpp.filelist
...
ERROR: [Errno 2] No such file or directory: manifest/i686/z/zziplib.filelist
ERROR: [Errno 2] No such file or directory: manifest/i686/z/zzuf.filelist
Statistics:
         0.16 seconds
        7,764 log lines processed
            1 commits evaluated
           56 directory update errors
           35 directories updated
        7,762 files
        3,465 file update errors
        4,297 files updated

The errors are all from the sparse-checkout excluded files. Is there a way to avoid erroring on those files?

MestreLion commented 8 months ago

I'd have to take a closer look at git sparse-checkout to see if there's any support for/from git ls-files, which I currently use to get the list of files to update.

git sparse-checkout is a relatively new command, introduced in 2020, and still marked as experimental so its API can change, and it seems it has done so several times over the the last years.

If there's no way to adjust ls-files to deal with sparse checkouts (or find a replacement to retrieve the actual list of files), a workaround would be to create a new flag --ignore-missing-files to silence only those errors. That's feasible and quite easy, but I'd have to take a look on the performance impact of adding exception handling to the heart of touch() (possibly in yet another touch() variant)