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

Re: fast-import should not care about core.ignorecase

From
Joshua Jensen <jjensen@workspacewhiz.com>
Date
Dec 9, 2014, 01:07 UTC
Message-ID
<54864B3D.6040503@workspacewhiz.com>
In-Reply-To
<20141209001211.GA13386@glandium.org>
Mike Hommey wrote on 12/8/2014 5:12 PM:
> While it makes sense for checkouts and local commits, it doesn't make
> sense to me that using git fast-import with the same import script would
> have a different behavior depending on whether the file system is
> case-sensitive or not.

I have used fast-import with Perforce inputs. When you run a Windows Perforce server, filenames can be submitted with ANY case, but given the case insensitive nature of the file system, a synced Perforce file will end up using whatever case happens to be on the file system at that point.

That may not be clear, so here goes:
Revision 1: abc/DEF/ghi/FILE.dat
Revision 2: ABC/def/GHI/file.dat

^^ Yes, Perforce stores the filename internally in that manner and does not fold the case.

If you happen to sync Revision 2 on an empty directory tree, you'll get ABC/def/GHI/file.dat. If you then sync Revision 1, the filename case remains ABC/def/GHI/file.dat.

Likewise, if you happen to sync Revision 1 into an empty directory tree, you'll get abc/DEF/ghi/FILE.dat. If you then sync Revision 2, the filename case remains as abc/DEF/ghi/FILE.dat.

I was the one who originally submitted the patch for this some 4 years ago. It was commit 50906e04e8f48215b0b09841686709b92a2ab2e4. 'git fast-import' with core.ignorecase=true will fold the case of the filename specified in Revision 2 to the case currently stored in the Git repository from Revision 1.

If it does not do this, then Git internally stores FILE.dat and file.dat, and bad things happen on case-insensitive file systems.

(Further, there are still a few paths into Git where core.ignorecase=true does not fold the case of the filename, and this can cause 'repository corruptions' on case-insensitive file systems. One such place is in 'git update-index' directly used by 'git gui'. I really need to get this submitted, as we've been beating on it for a long time now, but here is the partial patch for informational purposes only.

I think it has been discussed before, but maybe Git needs a core.casefold in addition to core.ignorecase.)

-Josh

---------------------------- builtin/update-index.c ---------------------------- index aaa6f78..4cfedc1 100644

@@ -99,6 +99,7 @@ static int add_one_path(const struct cache_entry *old, 
const char *path, int len
      memcpy(ce->name, path, len);
      ce->ce_flags = create_ce_flags(0);
      ce->ce_namelen = len;
+    fold_ce_name_case(&the_index, ce);
      fill_stat_cache_info(ce, st);
      ce->ce_mode = ce_mode_from_stat(old, st->st_mode);

@@ -234,6 +235,7 @@ static int add_cacheinfo(unsigned int mode, const 
unsigned char *sha1,
      memcpy(ce->name, path, len);
      ce->ce_flags = create_ce_flags(stage);
      ce->ce_namelen = len;
+    fold_ce_name_case(&the_index, ce);
      ce->ce_mode = create_ce_mode(mode);
      if (assume_unchanged)
          ce->ce_flags |= CE_VALID;
Previous: Mike HommeyNext: Jonathan Nieder
Message 3 of 12 in “fast-import should not care about core.ignorecase”
  1. Mike HommeyDec 9, 2014
  2. Mike HommeyDec 9, 2014
  3. Joshua JensenDec 9, 2014
  4. Jonathan NiederDec 9, 2014
  5. Joshua JensenDec 9, 2014
  6. Junio C HamanoDec 9, 2014
  7. fast-import: add options to enable/disable case foldingMike Hommey, Apr 17, 2015
  8. Torsten BögershausenApr 17, 2015
  9. Junio C HamanoApr 17, 2015
  10. Mike HommeyApr 18, 2015
  11. Luke DiamandApr 24, 2015
  12. Eric SunshineApr 17, 2015

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.