View Ticket
Not logged in
Ticket UUID: 80d3ba8b0ff0098d33350f24a37982f396b45e15
Title: fossil add can't add two files whose names only differ by an underscore or dash
Status: Fixed Type: Code_Defect
Severity: Severe Priority:
Subsystem: Resolution: Fixed
Last Modified: 2010-03-02 18:20:53
Version Found In: 1efd09ed4f
Description & Comments:
the following steps reproduce this problem. in summary, when adding two files whose names differ only by a dash and underscore, e.g. a-1.txt and a_1.txt, only the file with the dash in its name will be added, even though fossil add reports that both were added. this test was conducted using powershell on windows 7 64 bit. i can test it on windows xp later this week. i don't have a non-windows box to test this on.
PS C:\rev\src> fossil new test.fossil
project-id: 9968296e3e87d77b514493152ecc682e94e015cc
server-id:  37ea13bc92c88ff92f41f5ec8c921a88eeca87a8
admin-user: rev (initial password is "4cabdf")
PS C:\rev\src> md test
PS C:\rev\src> cd test
PS C:\rev\src\test> fossil open ..\test.fossil
PS C:\rev\src\test> echo "hello" > a_1.txt
PS C:\rev\src\test> echo "goodbye" > a-1.txt
PS C:\rev\src\test> ls

Directory: C:\rev\src\test

Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 2/28/2010 6:23 PM 20 a-1.txt -a--- 2/28/2010 6:22 PM 16 a_1.txt -a--- 2/28/2010 6:22 PM 7168 _FOSSIL_

PS C:\rev\src\test> fossil add *.txt ADDED a-1.txt ADDED a_1.txt PS C:\rev\src\test> fossil extras a_1.txt PS C:\rev\src\test> fossil ls a-1.txt PS C:\rev\src\test> fossil commit -m "underscore omitted" New_Version: e6cb6574e973b8743701ec4e8f7cfaa61066c99a PS C:\rev\src\test> fossil extras a_1.txt PS C:\rev\src\test> fossil ls a-1.txt PS C:\rev\src\test>


rwilson added on 2010-03-02 17:17:01:
in the windows build, fossil uses the LIKE operator to compensate for the fact that windows has a case-insensitive file system.

from add.c:

#ifdef __MINGW32__
    if( db_exists("SELECT 1 FROM vfile WHERE pathname LIKE %Q", zPath) ){
      db_multi_exec("UPDATE vfile SET deleted=0 WHERE pathname LIKE %Q", zPath);
    }
#else
    if( db_exists("SELECT 1 FROM vfile WHERE pathname=%Q", zPath) ){
      db_multi_exec("UPDATE vfile SET deleted=0 WHERE pathname=%Q", zPath);
    }
#endif

the problem is that LIKE treats dash and underscore oddly:

PS C:\Documents and Settings\ma088024> sqlite3
SQLite version 3.6.22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table test (path);
sqlite> insert into test values("a-1.txt");
sqlite> insert into test values("a_1.txt");
sqlite> select * from test;
a-1.txt
a_1.txt
sqlite> select * from test where path like 'a-1.txt';
a-1.txt
sqlite> select * from test where path like 'a_1.txt';
a-1.txt
a_1.txt
sqlite> .quit

apparently, "-" is NOT LIKE "_", but "_" is LIKE "-". this latter condition results in the confusion that this ticket describes.


rwilson added on 2010-03-02 18:05:30:
sigh, '_' is a wildcard character in LIKE. using LIKE to compare files in fossil add proves problematic because underscores are valid characters in file names.