git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] fast-import.c: always honor the filename case

From
Reuben Hawkins <reubenhwk@gmail.com>
Date
Feb 2, 2014, 13:13 UTC
Message-ID
<1391346784-11891-1-git-send-email-reubenhwk@gmail.com>

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
Next: Torsten Bögershausen
Message 1 of 9 in “fast-import.c: always honor the filename case”
  1. fast-import.c: always honor the filename caseReuben Hawkins, Feb 2, 2014
  2. Torsten BögershausenFeb 2, 2014
  3. Jeff KingFeb 2, 2014
  4. Junio C HamanoFeb 3, 2014
  5. Torsten BögershausenFeb 3, 2014
  6. Junio C HamanoFeb 4, 2014
  7. Torsten BögershausenFeb 5, 2014
  8. Torsten BögershausenFeb 9, 2014
  9. Torsten BögershausenFeb 11, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.