Skip to content

Commit 890e2cc

Browse files
dschomjcheetham
authored andcommitted
mingw: special-case index entries for symlinks with buggy size
In git-for-windows#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 9fac53c commit 890e2cc

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

read-cache.c

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

0 commit comments

Comments
 (0)