All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fast-import.c: always honor the filename case
@ 2014-02-02 13:13 Reuben Hawkins
  2014-02-02 20:08 ` Torsten Bögershausen
  2014-02-02 23:00 ` Jeff King
  0 siblings, 2 replies; 9+ messages in thread
From: Reuben Hawkins @ 2014-02-02 13:13 UTC (permalink / raw)
  To: git; +Cc: dpotapov, tboegi, Reuben Hawkins

fast-import should not use strncmp_icase.  When it does, files with
similar names, but different case can be lost in the import.  For
example...

M 100644 :1 FileName.txt
D Filename.txt

...would end up deleting FileName from the index during the fast-
import when strncmp_icase is used and core.ignorecase=true.  The
intent in the above snippet is to rename the file, not delete it.

Replacing strncmp_icase with strncmp in fast-import.c fixes the
issue.

alternatives:
* check if the filesystem is case-preserving.  If it is, don't
  set core.ignorecase=true.  This, however, exposes another issue
  where git is tricked by stat into thinking that tracked files
  are untracked on case-preserving and case-insensitive filesystems.
---
 fast-import.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fast-import.c b/fast-import.c
index f4d9969..62e28c0 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1500,7 +1500,7 @@ static int tree_content_set(
 	t = root->tree;
 	for (i = 0; i < t->entry_count; i++) {
 		e = t->entries[i];
-		if (e->name->str_len == n && !strncmp_icase(p, e->name->str_dat, n)) {
+		if (e->name->str_len == n && !strncmp(p, e->name->str_dat, n)) {
 			if (!slash1) {
 				if (!S_ISDIR(mode)
 						&& e->versions[1].mode == mode
@@ -1593,7 +1593,7 @@ static int tree_content_remove(
 	t = root->tree;
 	for (i = 0; i < t->entry_count; i++) {
 		e = t->entries[i];
-		if (e->name->str_len == n && !strncmp_icase(p, e->name->str_dat, n)) {
+		if (e->name->str_len == n && !strncmp(p, e->name->str_dat, n)) {
 			if (slash1 && !S_ISDIR(e->versions[1].mode))
 				/*
 				 * If p names a file in some subdirectory, and a
@@ -1663,7 +1663,7 @@ static int tree_content_get(
 	t = root->tree;
 	for (i = 0; i < t->entry_count; i++) {
 		e = t->entries[i];
-		if (e->name->str_len == n && !strncmp_icase(p, e->name->str_dat, n)) {
+		if (e->name->str_len == n && !strncmp(p, e->name->str_dat, n)) {
 			if (!slash1)
 				goto found_entry;
 			if (!S_ISDIR(e->versions[1].mode))
-- 
1.8.5.3.1.gac93028.dirty

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-02-11 17:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-02 13:13 [PATCH] fast-import.c: always honor the filename case Reuben Hawkins
2014-02-02 20:08 ` Torsten Bögershausen
     [not found]   ` <CAD_8n+RZACW0380co75gWSwVmCJdcH4COsySTF3BFCyKEumXNA@mail.gmail.com>
2014-02-03 20:21     ` Torsten Bögershausen
2014-02-04  0:14       ` Junio C Hamano
     [not found]       ` <CAD_8n+RuwQEXJRCOr+B_PqA7z6LkFdbcRZkiiVJsEhJ=+YjRDg@mail.gmail.com>
2014-02-05 21:19         ` Torsten Bögershausen
     [not found]           ` <CAD_8n+Thn3tNTYxLK49mDOGdLpWRCFUCJo9b76UbAjnCdqXsRQ@mail.gmail.com>
2014-02-09 20:34             ` Torsten Bögershausen
     [not found]               ` <CAD_8n+ToUDbXrVuru7GV7toYKHXuQb8vL3B_-sfzQdXZFqzD2A@mail.gmail.com>
2014-02-11 17:29                 ` Torsten Bögershausen
2014-02-02 23:00 ` Jeff King
2014-02-03 17:21   ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.