Re: [PATCH 0/7] Final words

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Torvalds
Date: Saturday, March 22, 2008 - 11:28 am

On Sat, 22 Mar 2008, Linus Torvalds wrote:

git-add will want more than this, but this is an example of what we should 
do - if 'ignore_case' is set, we probably should disallow adding the same 
case-insensitive name twice to the index.

This does *not* guarantee that the index never would have aliases when 
core.ignorecase is set, since the index might have been populated from a 
tree that was generated on a sane filesystem, and we still allow that, but 
things like this are probably good things to do for projects that want to 
work case-insensitively.

So even if you have a case-sensitive filesystem, the goal (I think) should 
be that you can set core.ignorecase to true, and that should help you work 
with other people who may be stuck on case-insensitive crud.

Anyway, the reason "git add" didn't actually work with the simple change 
to dir_add_name() is that "git add" doesn't load the index until *after* 
it has done the directory traversal (because it actually *wants* to see 
files that are already in the index). 

Something like this at least disallows the dual add if the case has 
changed.

		Linus

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

diff --git a/read-cache.c b/read-cache.c
index 5dc998d..6aee6e0 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -476,6 +476,13 @@ int add_file_to_index(struct index_state *istate, const char *path, int verbose)
 		return 0;
 	}
 
+	if (ignore_case) {
+		struct cache_entry *alias;
+		alias = index_name_exists(istate, ce->name, ce_namelen(ce), 1);
+		if (alias)
+			die("Will not add file alias '%s' ('%s' already exists in index)", ce->name, alias->name);
+	}
+
 	if (index_path(ce->sha1, path, &st, 1))
 		die("unable to index file %s", path);
 	if (add_index_entry(istate, ce, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE))
--
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] 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)