X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=read-cache.c;h=4f2e890b01b0c27ef2e49080e1fd34bf67e969c7;hb=00e6ee724640701b32aca27cc930fd6409c87ae2;hp=1f42473e8070a05ada8c56b0d60537227a5223ec;hpb=8577def6fc1dda3f18a284162aba07819fbcbcd4;p=git.git diff --git a/read-cache.c b/read-cache.c index 1f42473e8..4f2e890b0 100644 --- a/read-cache.c +++ b/read-cache.c @@ -608,6 +608,29 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st, ce->ce_mode = ce_mode_from_stat(ent, st_mode); } + /* When core.ignorecase=true, determine if a directory of the same name but differing + * case already exists within the Git repository. If it does, ensure the directory + * case of the file being added to the repository matches (is folded into) the existing + * entry's directory case. + */ + if (ignore_case) { + const char *startPtr = ce->name; + const char *ptr = startPtr; + while (*ptr) { + while (*ptr && *ptr != '/') + ++ptr; + if (*ptr == '/') { + struct cache_entry *foundce; + ++ptr; + foundce = index_name_exists(&the_index, ce->name, ptr - ce->name, ignore_case); + if (foundce) { + memcpy((void *)startPtr, foundce->name + (startPtr - ce->name), ptr - startPtr); + startPtr = ptr; + } + } + } + } + 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 */