[PATCH 8/7] When adding files to the index, add support for case-independent matches

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Torvalds
Date: Saturday, March 22, 2008 - 2:19 pm

From: Linus Torvalds <torvalds@woody.linux-foundation.org>
Date: Sat, 22 Mar 2008 13:19:49 -0700

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>
---

This is patch 1/2 to make "git add" act better. Discard the previous 
simplistic and overly die()-eager patch that I hadn't signed off on.

 read-cache.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index 5dc998d..8c57adf 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -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))
@@ -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;
 	}
 
-- 
1.5.5.rc0.31.gdcfd.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/7] Case-insensitive filesystem support, take 1, Linus Torvalds, (Sat Mar 22, 10:21 am)
[PATCH 5/7] Add 'core.ignorecase' option, Linus Torvalds, (Sat Mar 22, 10:33 am)
Re: [PATCH 1/7] Make unpack_trees_options bit flags actual ..., Johannes Schindelin, (Sat Mar 22, 10:36 am)
Re: [PATCH 1/7] Make unpack_trees_options bit flags actual ..., Johannes Schindelin, (Sat Mar 22, 10:57 am)
[PATCH 0/7] Final words, Linus Torvalds, (Sat Mar 22, 11:06 am)
Re: [PATCH 0/7] Final words, Linus Torvalds, (Sat Mar 22, 11:28 am)
[PATCH 8/7] When adding files to the index, add support fo ..., Linus Torvalds, (Sat Mar 22, 2:19 pm)
[PATCH] git-init: autodetect core.ignorecase, Dmitry Potapov, (Mon Mar 24, 11:57 pm)
Re: [PATCH] git-init: autodetect core.ignorecase, Johannes Schindelin, (Tue Mar 25, 2:59 am)
[PATCH v2] git-init: autodetect core.ignorecase, Dmitry Potapov, (Tue Mar 25, 3:49 am)
Re: [PATCH] git-init: autodetect core.ignorecase, Dmitry Potapov, (Tue Mar 25, 4:03 am)