@matheusbsbs / matheus-bagliano / commits / 6835550def
Fork 0

When adding files to the index, add support for case-independent matches

This simplifies the matching case of "I already have this file and it is up-to-date" and makes it do the right thing in the face of case-insensitive aliases. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Linus Torvalds committed Mar 22, 2008 at 13:19 UTC 6835550def046bfd52f3e65f248024956a6df62c
1 file changed +5 -7
read-cache.c
+5 -7
@@ -431,9 +431,9 @@ static int index_name_pos_also_unmerged(struct index_state *istate,
431
432 int add_file_to_index(struct index_state *istate, const char *path, int verbose)
433 {
434 - int size, namelen, pos;
434 + int size, namelen;
435 struct stat st;
436 - struct cache_entry *ce;
436 + struct cache_entry *ce, *alias;
437 unsigned ce_option = CE_MATCH_IGNORE_VALID|CE_MATCH_RACY_IS_DIRTY;
438
439 if (lstat(path, &st))
@@ -466,13 +466,11 @@ int add_file_to_index(struct index_state *istate, const char *path, int verbose)
466 ce->ce_mode = ce_mode_from_stat(ent, st.st_mode);
467 }
468
469 - pos = index_name_pos(istate, ce->name, namelen);
470 - if (0 <= pos &&
471 - !ce_stage(istate->cache[pos]) &&
472 - !ie_match_stat(istate, istate->cache[pos], &st, ce_option)) {
469 + alias = index_name_exists(istate, ce->name, ce_namelen(ce), ignore_case);
470 + if (alias && !ce_stage(alias) && !ie_match_stat(istate, alias, &st, ce_option)) {
471 /* Nothing changed, really */
472 free(ce);
475 - ce_mark_uptodate(istate->cache[pos]);
473 + ce_mark_uptodate(alias);
474 return 0;
475 }
476