Thomas Rast <t...@thomasrast.ch> writes: > I spoke too soon; it breaks the test I wrote to cover this case, for a > reason that gives me a headache. > > When we hit the conditional > >>>> - if (!one->sha1_valid || >>>> - reuse_worktree_file(name, one->sha1, 1)) { >>>> + if (!S_ISGITLINK(one->mode) && >>>> + (!one->sha1_valid || >>>> + reuse_worktree_file(name, one->sha1, 1))) { > > sha1_valid=0 for the submodule on the worktree side of the diff. The > reason is that we start out with sha1_valid=0 and sha1=000..000 for the > worktree side of all dirty entries, which makes sense at that point. We > later set the sha1 by looking inside the submodule in > diff_fill_sha1_info(), but we never set sha1_valid. So the above > conditional will now trigger on the !one->sha1_valid arm, completely > defeating the change to reuse_worktree_file(). > > We can fix it like below, but it feels a bit wrong to me. Are > submodules the only case where it makes sense to set sha1_valid when we > fill the sha1?
The meaning of filespec->sha1_valid is "Is it known that the filespec->sha1 and filespec->mode field should be used?"; I agree that this feels wrong. Which means that the previous one was wrong, and your original was the right approach. I'll drop the update. Thanks. > > diff.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git i/diff.c w/diff.c > index dabf913..cf7281d 100644 > --- i/diff.c > +++ w/diff.c > @@ -3081,6 +3082,8 @@ static void diff_fill_sha1_info(struct diff_filespec > *one) > die_errno("stat '%s'", one->path); > if (index_path(one->sha1, one->path, &st, 0)) > die("cannot hash %s", one->path); > + if (S_ISGITLINK(one->mode)) > + one->sha1_valid = 1; > } > } > else -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html