Skip to content

Commit 0477637

Browse files
dschoGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
mingw: special-case index entries for symlinks with buggy size
In #2637, we fixed a bug where symbolic links' target path sizes were recorded incorrectly in the index. The downside of this fix was that every user with tracked symbolic links in their checkouts would see them as modified in `git status`, but not in `git diff`, and only a `git add <path>` (or `git add -u`) would "fix" this. Let's do better than that: we can detect that situation and simply pretend that a symbolic link with a known bad size (or a size that just happens to be that bad size, a _very_ unlikely scenario because it would overflow our buffers due to the trailing NUL byte) means that it needs to be re-checked as if we had just checked it out. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 9bcfa13 commit 0477637

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

read-cache.c

+11
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,17 @@ int ie_modified(struct index_state *istate,
471471
* then we know it is.
472472
*/
473473
if ((changed & DATA_CHANGED) &&
474+
#ifdef GIT_WINDOWS_NATIVE
475+
/*
476+
* Work around Git for Windows v2.27.0 fixing a bug where symlinks'
477+
* target path lengths were not read at all, and instead recorded
478+
* as 4096: now, all symlinks would appear as modified.
479+
*
480+
* So let's just special-case symlinks with a target path length
481+
* (i.e. `sd_size`) of 4096 and force them to be re-checked.
482+
*/
483+
(!S_ISLNK(st->st_mode) || ce->ce_stat_data.sd_size != MAX_LONG_PATH) &&
484+
#endif
474485
(S_ISGITLINK(ce->ce_mode) || ce->ce_stat_data.sd_size != 0))
475486
return changed;
476487

0 commit comments

Comments
 (0)