Skip to content

Improve Git LFS handling when creating source archives from Git - #5335

Open
pavelToman wants to merge 8 commits into
easybuilders:developfrom
pavelToman:patch-4
Open

pavelToman wants to merge 8 commits into
easybuilders:developfrom
pavelToman:patch-4

Conversation

@pavelToman

@pavelToman pavelToman commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Improve Git LFS handling in get_source_tarball_from_git() to ensure that Git LFS objects are downloaded when needed, without unnecessarily requiring git-lfs for repositories that only contain Git LFS attributes.

The previous implementation relied on detecting filter=lfs in .gitattributes, which could produce false positives. Git LFS filters could also be triggered during checkout before checking whether git-lfs was available.

This PR additionally improves source archive reproducibility, prevents silently incomplete LFS downloads, and reduces filesystem overhead when detecting LFS pointers.

Changes

  • Disable automatic Git LFS smudging during checkout and submodule initialization.
  • Detect actual Git LFS pointers using attribute-based Git file selection, avoiding unnecessary filesystem operations and individual git check-attr calls.
  • Support modern, legacy, and noncanonical Git LFS pointer formats.
  • Check Git LFS availability only once per source archive using git lfs version, and only when actual LFS pointers are detected.
  • Support Git LFS objects in recursively nested submodules.
  • Neutralize implicit lfs.fetchinclude and lfs.fetchexclude settings to prevent user-level and repository-level fetch filters from affecting source archives.
  • Preserve explicit LFS fetch filters specified via extra_config_params in the easyconfig.
  • Verify that selected LFS objects have been downloaded, while allowing intentionally excluded objects to remain as pointers.
  • Separate stderr from parsed Git command output.
  • Provide actionable error messages, including examples of detected LFS pointer files when git-lfs is unavailable.
  • Extend regression test coverage and introduce offline integration tests using real Git LFS objects and local repositories.
  • Reject invalid Git LFS pointer fields, extension priorities, and extension OIDs to avoid false-positive pointer detection.

Compatibility

  • Git >= 2.13 is required for attribute-based file selection.
  • Git LFS >= 3.2.0 is required when JSON-based verification of selective LFS downloads is needed.
  • Older unsupported versions produce actionable error messages suggesting an upgrade or loading a newer module.

Testing

Tested on the UGent donphan HPC cluster with Python 3.9.25 and Git 2.52.0.

Framework tests

  • All six Git-related framework tests pass with Git LFS 3.7.1.
  • Integration tests successfully tested with Git LFS 3.2.0 and 3.7.1.
  • Without Git LFS installed, all five applicable tests pass, with the integration test skipped.
  • Full test.framework.filetools suite: 81/82 tests pass, with the same pre-existing test_fake_vsc failure as before these changes.
  • No new regression failures.
  • Six additional regression cases for invalid Git LFS pointer fields and extensions pass.

Integration tests

Verified using real Git LFS objects and local repositories:

  • Successful LFS object retrieval.
  • Identical SHA256 archive checksums despite different global LFS fetch filters.
  • Explicit easyconfig fetch filters taking precedence over global configuration.
  • Preservation of intentionally excluded LFS pointers.
  • Prevention of archive creation when LFS objects are missing from the server.

Real-world source fetching

Successfully fetched sources from scratch using the following unmodified easyconfigs and the updated framework:

  • LINC-5.0-foss-2023b.eb
    • Successful fetching without git-lfs.
    • Git metadata preserved (keep_git_dir=True).
  • dorado-2.1.2-foss-2025a-CUDA-12.8.0.eb
    • Successful LFS fetching with recursive submodules.
    • 7,055 regular files inspected, no remaining LFS pointers detected.
  • Geneformer-0.1.0-20260526-foss-2024a-CUDA-12.6.0.eb
    • All eight required LFS objects downloaded.
    • 16 intentionally excluded LFS pointers preserved.
  • PySONIC-1.0-20250519-foss-2023a.eb
    • Successful LFS fetching.
    • 111 regular files inspected, no remaining LFS pointers detected.

The generated source archives were independently inspected to verify the expected LFS content.

Git LFS was not manually loaded before fetching, allowing verification of automatic module loading via source_deps.

Compatibility error handling for older Git and Git LFS versions was verified through simulated command failures.

Previous PRs

Done with help from ChatGPT6.2 and additional review by Claude Opus 5.5.

Add tests for Git LFS pointer detection and handling in various scenarios.
@pavelToman

pavelToman commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Found this problem during the work on easybuilders/easybuild-easyconfigs#27145

@boegel boegel added enhancement AI-assisted AI-assisted contributions labels Oct 19, 2026
@boegel boegel added this to the 5.x milestone Oct 19, 2026
Refactor Git LFS pointer handling and update deprecation warnings.
Refactor Git LFS pointer tests and improve isolation of Git configuration for testing. Update function names and add more comprehensive checks for valid and invalid LFS pointers.
Add various invalid pointer cases for testing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-assisted AI-assisted contributions enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants