View Ticket
Not logged in
Ticket UUID: 36cb6b45fd9d31f6bc4bd4ad87f18aad50e5bce9
Title: in windows, fossil allows addition of the same file twice
Status: Open Type: Feature_Request
Severity: Minor Priority:
Subsystem: Resolution: Open
Last Modified: 2010-01-20 21:34:23
Version Found In: 076f7adff2
Description & Comments:
in windows, the file system is case insensitive. fossil allows the addition of the same file twice differing only by case. both files show up in the ui but technically they are versioned separately even though they are the same file on disk; it is unclear which artifact dominates on fossil open/update.
PS C:\fossil> fossil new test.f
project-id: 24ac0462f2082e82bcdf2de26ceb3c38aaffcfe4
server-id:  0b879e4b0baa36b4da40631bf54866f3ae825323
admin-user: rwilso20 (initial password is "ab6ad5")
PS C:\fossil> md test
PS C:\fossil> cd test
PS C:\fossil\test> fossil open ..\test.f
PS C:\fossil\test> notepad camelCase.txt
PS C:\fossil\test> fossil add camelCase.txt
ADDED  camelCase.txt
PS C:\fossil\test> fossil add camelcase.txt
ADDED  camelcase.txt
PS C:\fossil\test> fossil commit
notepad "C:/fossil/test/ci-comment-09044B4972BB.txt"
'gpg' is not recognized as an internal or external command,
operable program or batch file.
unable to sign manifest.  continue [y/N]? y
New_Version: b06866048f0a6cdf50573ef9e7767bb6fa4449db
PS C:\fossil\test> fossil ls
UNCHANGED camelCase.txt
UNCHANGED camelcase.txt
PS C:\fossil\test> fossil ver
This is fossil version [076f7adff2] 2009-10-13 16:25:41 UTC
PS C:\fossil\test>

drh added on 2009-10-16 14:36:30:
Case-folding is locale-dependent (See, for example, http://userguide.icu-project.org/transforms/casemappings) and is enormously complicated. We do not want to go there.

I suppose it does make sense to issue warnings if fossil detects possible conflicts in filenames. This can be done easily enough for ASCII. But because the problem is all but unsolvable for full unicode, the change should be to add warnings only, and then only for ASCII. Some users may actually want to store files whose names differ only in case and we don't want to have to go through all of the complication to try to figure out unicode case folding.

I am changing this ticket to a feature request.


jeremy_c added on 2010-01-05 14:09:04:
Missed that drh changed it to a feature request, opps.


anonymous claiming to be Jose F. Gimenez added on 2010-01-16 18:33:47:
Sorry to jump in...

I'm evaluating fossil to replace cvs for all my repositories, and I've stumbled in this problem.

Since fossil has no gui actualy (similar to tortoiseXXX), and it has to be used by typing commands from the command line, it's very very easy to add a file twice or more times accidentaly. Also, to manage any versioned file you must type its name exactly as it was added or it cannot be found. So it indeed become a very big problem for those of us that work in windows or any other case-insensitive os.

IMHO, a possible solution could be to allow configure the repository as case sensitive or insensitive. So, who works in a case-sensitive os don't have to renunce to the actual behaviour, while the windows (only) users will be happy.


anonymous added on 2010-01-16 18:39:58:
That is fine, except when you have a mixed-mode environment (as I have at work), where some use Linux or OS/X while others use Windows, all using the same repo.


anonymous added on 2010-01-20 05:21:49:
There's the added issue of "case" not making sense outside of the latin alphabet for the most part. Case collision detection is a scary-complicated problem once you poke your head outside of the parochial ASCII/ANSI shell and into the rest of the world. The code would be non-trivial, buggy and likely hugely bloated.


anonymous claiming to be ramsan added on 2010-01-20 12:38:01:
But I do not understand the problem. When doing:

  PS C:\fossil\test> notepad camelCase.txt
  PS C:\fossil\test> fossil add camelCase.txt
  ADDED  camelCase.txt
  PS C:\fossil\test> fossil add camelcase.txt
  ADDED  camelcase.txt
Command "fossil add ..." needs to ask the operating system if file 'camelcase.txt' exist. If it does not exist, the command fails. When doing this request, fossil can ask the operating system for the exact name of the file. In this case, the OS would answer "camelCase.txt". Then, it would be easy to detect that "camelCase.txt" has already been added and raise an error.

drh added on 2010-01-20 13:36:53:
I'm a unix programmer, not a windows programmer, so please tell me: How do you ask windows for the "exact" name of a file?


anonymous claiming to be ramsan added on 2010-01-20 15:10:26:
In TCL, you would do:

  file tail [file normalize camelcase.txt]
  --->  camelCase.txt
To do so in C, it is necessary to review the TCL C source code.

rwilson added on 2010-01-20 15:36:36:
microsoft has an article on this: http://msdn.microsoft.com/en-us/library/aa366789(VS.85).aspx?ppud=4

i just tested it myself and it works.


rwilson added on 2010-01-20 17:49:36:
if you want i can port the above solution to fossil and test it. fossil would have to link with psapi.lib. i'm not sure if it already does this or not.


drh added on 2010-01-20 18:38:34:
The psapi.lib fix might be technically better. But my (ancient) mingw-gcc doesn't know that library exists and won't link to it. So instead, I added code that disallows adding files that differ only in ASCII case under windows. See check-in [4b9455bf03c38546c1adc49f5a03bd2eba096969].


ron added on 2010-01-20 18:42:03:
I see drh just made a fix to prevent adding a file which difference only in case from a file in the repo. OS/X users will I think need a similar treatment.

What happens when the repo is shared between Linux and Windows users, and the Linux users add two files, say "makefile" and "Makefile"? When the Windows user does an 'update', she will get one of the files, since Windows doesn't distinguish case (neither does OS/X). So one file will be missing on Windows.

Perhaps it makes sense to issue a notice to the Windows user in that case?


anonymous claiming to be Jose F. Gimenez added on 2010-01-20 19:26:25:
rwilson, there is an easier way to get the real filename in windows. Check this C function:

   BOOL GetRealFilename( const char * szFilename, char * szRealFilename )
   {
      char szTempFilename[ MAX_PATH ];
      if( GetShortPathName( szFilename, szTempFilename, MAX_PATH ) )
         if( GetLongPathName( szTempFilename, szRealFilename, MAX_PATH ) )
            return TRUE;
      return FALSE;
   }
Also, it allows to check the existance of a file, since it returns FALSE if the file doesn't exist.

But that doesn't fix the problem at 100%. You could rename a file in your working directory, changing only case, and get again in a trouble. So, the check have to be done in the repository.

The drh fix solves the most cases, although it doesn't deal with non ascii chars. Thanks, however!


rwilson added on 2010-01-20 21:34:23:
jose - that is a clever solution; thanks. i just tried it and it works well.

drh - jose's solution only requires kernel32.lib, not psapi.lib.