Skip to content

Commit

Permalink
When adding files to the index, add support for case-independent matches
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Linus Torvalds authored and Junio C Hamano committed Apr 9, 2008
1 parent 1fa6ead commit 6835550
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions read-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,9 @@ static int index_name_pos_also_unmerged(struct index_state *istate,

int add_file_to_index(struct index_state *istate, const char *path, int verbose)
{
int size, namelen, pos;
int size, namelen;
struct stat st;
struct cache_entry *ce;
struct cache_entry *ce, *alias;
unsigned ce_option = CE_MATCH_IGNORE_VALID|CE_MATCH_RACY_IS_DIRTY;

if (lstat(path, &st))
Expand Down Expand Up @@ -466,13 +466,11 @@ int add_file_to_index(struct index_state *istate, const char *path, int verbose)
ce->ce_mode = ce_mode_from_stat(ent, st.st_mode);
}

pos = index_name_pos(istate, ce->name, namelen);
if (0 <= pos &&
!ce_stage(istate->cache[pos]) &&
!ie_match_stat(istate, istate->cache[pos], &st, ce_option)) {
alias = index_name_exists(istate, ce->name, ce_namelen(ce), ignore_case);
if (alias && !ce_stage(alias) && !ie_match_stat(istate, alias, &st, ce_option)) {
/* Nothing changed, really */
free(ce);
ce_mark_uptodate(istate->cache[pos]);
ce_mark_uptodate(alias);
return 0;
}

Expand Down

0 comments on commit 6835550

Please sign in to comment.