forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dir.c: regression fix for add_excludes with fscache #1407
Merged
Merged
Conversation
This file contains 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
This was referenced Dec 19, 2017
dscho
reviewed
Dec 20, 2017
dir.c
Outdated
* If the .gitignore file is successfully opened and in the | ||
* rare case that it is a symlink, we fstat it to replace the | ||
* original lstat stat-data to complete our illusion. | ||
*/ | ||
if (lstat(fname, &st) < 0) { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
dscho
reviewed
Dec 20, 2017
@@ -257,7 +252,7 @@ static void fscache_clear(void) | |||
/* | |||
* Checks if the cache is enabled for the given path. | |||
*/ | |||
static inline int fscache_enabled(const char *path) | |||
int fscache_enabled(const char *path) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Make fscache_enabled() function public rather than static. Remove unneeded fscache_is_enabled() function. Change is_fscache_enabled() macro to call fscache_enabled(). is_fscache_enabled() now takes a pathname so that the answer is more precise and mean "is fscache enabled for this pathname", since fscache only stores repo-relative paths and not absolute paths, we can avoid attempting lookups for absolute paths. Signed-off-by: Jeff Hostetler <[email protected]>
Fix regression described in: git-for-windows#1392 which was introduced in: git-for-windows@b235337 Problem Symptoms ================ When the user has a .gitignore file that is a symlink, the fscache optimization introduced above caused the stat-data from the symlink, rather that of the target file, to be returned. Later when the ignore file was read, the buffer length did not match the stat.st_size field and we called die("cannot use <path> as an exclude file") Optimization Rationale ====================== The above optimization calls lstat() before open() primarily to ask fscache if the file exists. It gets the current stat-data as a side effect essentially for free (since we already have it in memory). If the file does not exist, it does not need to call open(). And since very few directories have .gitignore files, we can greatly reduce time spent in the filesystem. Discussion of Fix ================= The above optimization calls lstat() rather than stat() because the fscache only intercepts lstat() calls. Calls to stat() stay directed to the mingw_stat() completly bypassing fscache. Furthermore, calls to mingw_stat() always call {open, fstat, close} so that symlinks are properly dereferenced, which adds *additional* open/close calls on top of what the original code in dir.c is doing. Since the problem only manifests for symlinks, we add code to overwrite the stat-data when the path is a symlink. This preserves the effect of the performance gains provided by the fscache in the normal case. Signed-off-by: Jeff Hostetler <[email protected]>
jeffhostetler
force-pushed
the
regression_1392
branch
from
December 20, 2017 16:44
15599c0
to
1f10034
Compare
Thank you so much! |
dscho
added a commit
that referenced
this pull request
Jan 2, 2018
dir.c: regression fix for add_excludes with fscache
dscho
added a commit
that referenced
this pull request
Jan 18, 2018
dir.c: regression fix for add_excludes with fscache
git-for-windows-ci
pushed a commit
that referenced
this pull request
Jan 20, 2018
dir.c: regression fix for add_excludes with fscache
git-for-windows-ci
pushed a commit
that referenced
this pull request
Jan 22, 2018
dir.c: regression fix for add_excludes with fscache
git-for-windows-ci
pushed a commit
that referenced
this pull request
Jan 22, 2018
dir.c: regression fix for add_excludes with fscache
dscho
added a commit
that referenced
this pull request
Jan 22, 2018
dir.c: regression fix for add_excludes with fscache
dscho
added a commit
that referenced
this pull request
Feb 16, 2018
dir.c: regression fix for add_excludes with fscache
dscho
added a commit
that referenced
this pull request
Mar 23, 2018
dir.c: regression fix for add_excludes with fscache
dscho
added a commit
that referenced
this pull request
Apr 3, 2018
dir.c: regression fix for add_excludes with fscache
dscho
added a commit
that referenced
this pull request
May 29, 2018
dir.c: regression fix for add_excludes with fscache
dscho
added a commit
that referenced
this pull request
May 29, 2018
dir.c: regression fix for add_excludes with fscache
PKRoma
pushed a commit
to PKRoma/git-for-windows
that referenced
this pull request
Jun 22, 2018
…_1392 dir.c: regression fix for add_excludes with fscache
PKRoma
pushed a commit
to PKRoma/git-for-windows
that referenced
this pull request
Jun 22, 2018
…_1392 dir.c: regression fix for add_excludes with fscache
PKRoma
pushed a commit
to PKRoma/git-for-windows
that referenced
this pull request
Jun 22, 2018
…_1392 dir.c: regression fix for add_excludes with fscache
dscho
added a commit
that referenced
this pull request
Aug 22, 2018
dir.c: regression fix for add_excludes with fscache
dscho
added a commit
to dscho/git
that referenced
this pull request
Aug 22, 2018
…_1392 dir.c: regression fix for add_excludes with fscache
dscho
added a commit
that referenced
this pull request
Aug 23, 2018
dir.c: regression fix for add_excludes with fscache
dscho
added a commit
that referenced
this pull request
Aug 23, 2018
dir.c: regression fix for add_excludes with fscache
dscho
added a commit
that referenced
this pull request
Aug 23, 2018
dir.c: regression fix for add_excludes with fscache
jamill
pushed a commit
to jamill/git
that referenced
this pull request
Aug 28, 2018
…_1392 dir.c: regression fix for add_excludes with fscache
jamill
pushed a commit
to jamill/git
that referenced
this pull request
Sep 5, 2018
…_1392 dir.c: regression fix for add_excludes with fscache
git-for-windows-ci
pushed a commit
that referenced
this pull request
Sep 10, 2018
dir.c: regression fix for add_excludes with fscache
jamill
pushed a commit
to jamill/git
that referenced
this pull request
Sep 11, 2018
…_1392 dir.c: regression fix for add_excludes with fscache
git-for-windows-ci
pushed a commit
that referenced
this pull request
Sep 24, 2018
dir.c: regression fix for add_excludes with fscache
dscho
added a commit
that referenced
this pull request
Oct 10, 2018
dir.c: regression fix for add_excludes with fscache
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.
Fix regression described in:
#1392
which was introduced in:
b235337
When the user has a .gitignore file that is a symlink, the fscache
optimization introduced above caused the stat-data from the symlink,
rather that of the target file, to be returned. Later when the ignore
file was read, the buffer length did not match the stat.st_size field
and we called die("cannot use as an exclude file")
Added code to replace the stat-data when the path is a symlink. This
preserves the effect of the performance gains for the normal case where
it is not a symlink.
Signed-off-by: Jeff Hostetler [email protected]