Repository navigation
Find git-lfs in the user's PATH instead of hardcoding /usr/local/bin - #2835
Open
mluisbrown wants to merge 2 commits into
Open
mluisbrown wants to merge 2 commits into
mluisbrown wants to merge 2 commits into
Conversation
The LFS filter was only registered if git-lfs existed at /usr/local/bin/git-lfs, so with Homebrew on Apple Silicon (/opt/homebrew/bin) or MacPorts (/opt/local/bin) LFS files were silently left unfiltered (git-up#805). The filter is now always registered and git-lfs is resolved lazily, the first time a file with the lfs filter attribute is processed, from the login shell PATH with fallbacks to the common install locations. If git-lfs isn't found the filter passes through, preserving the previous behavior. git-lfs is also run with the login shell PATH so it uses the same git as the command line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[Medium impact] The PR appears safe to merge; no outstanding findings remain.
|
Extract the lookup into GCFindExecutableInPATH() so it can be tested with a controlled PATH and fake executables, independent of whether git-lfs is installed or present at /usr/local/bin. Also ignore directories named like the tool, which -isExecutableFileAtPath: would otherwise accept. The real git-lfs test remains as a smoke test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #805.
GitUp only registered its Git LFS filter if
git-lfsexisted at exactly/usr/local/bin/git-lfs. With Homebrew on Apple Silicon (/opt/homebrew/bin) or MacPorts (/opt/local/bin), the filter was never registered. LFS files were then checked out as pointer files and committed as raw content instead of LFS pointers, with no error.Changes
lfsfilter is now always registered.git-lfsis looked up the first time a file with thefilter=lfsattribute is processed, and the result is cached. The lookup searches the login shellPATH(the same approach hooks already use), then falls back to/opt/homebrew/bin,/usr/local/binand/opt/local/bin. Repositories that don't use LFS never run the lookup.checkcallback returnsGIT_PASSTHROUGHifgit-lfscan't be found, so LFS files are left as pointer files. This preserves the previous behavior when LFS isn't installed.git-lfsnow runs with the login shellPATH, so thegitit invokes is the same one the user gets on the command line.PATHlookup moved into a shared static function so the filter can call it without a repository instance.-getPATHUsingShell:error:now wraps it and behaves the same as before.Testing
testGitLFSCleanFilter. It checks that adding an LFS-tracked file to the index stores an LFS pointer, and it skips itself ifgit-lfsisn't installed. I confirmed that it fails against the old code when nothing exists at/usr/local/bin/git-lfs, and that it passes with this change.testDateFormatting("This Monday" vs "Last Monday"), which depends on the current date and fails without this change too.The wiki currently says
git-lfsmust be installed at/usr/local/bin/git-lfs, so it should be updated after this is merged.🤖 Generated with Claude Code