Fossil SCM

Function file_tree_name() should respect case-sensitive setting. Add --case-sensitive option to test-tree-name.

jan.nijtmans 2013-05-14 14:15 trunk
Commit 0df0ce8025c6b883050783d00a164495fcb0ebbf
1 file changed +13 -2
+13 -2
--- src/file.c
+++ src/file.c
@@ -941,10 +941,11 @@
941941
int nLocalRoot;
942942
char *zLocalRoot;
943943
Blob full;
944944
int nFull;
945945
char *zFull;
946
+ int (*xCmp)(const char*,const char*,int);
946947
947948
blob_zero(pOut);
948949
db_must_be_within_tree();
949950
file_canonical_name(g.zLocalRoot, &localRoot, 1);
950951
nLocalRoot = blob_size(&localRoot);
@@ -951,20 +952,25 @@
951952
zLocalRoot = blob_buffer(&localRoot);
952953
assert( nLocalRoot>0 && zLocalRoot[nLocalRoot-1]=='/' );
953954
file_canonical_name(zOrigName, &full, 0);
954955
nFull = blob_size(&full);
955956
zFull = blob_buffer(&full);
957
+ if( filenames_are_case_sensitive() ){
958
+ xCmp = fossil_strncmp;
959
+ }else{
960
+ xCmp = fossil_strnicmp;
961
+ }
956962
957963
/* Special case. zOrigName refers to g.zLocalRoot directory. */
958
- if( nFull==nLocalRoot-1 && memcmp(zLocalRoot, zFull, nFull)==0 ){
964
+ if( nFull==nLocalRoot-1 && xCmp(zLocalRoot, zFull, nFull)==0 ){
959965
blob_append(pOut, ".", 1);
960966
blob_reset(&localRoot);
961967
blob_reset(&full);
962968
return 1;
963969
}
964970
965
- if( nFull<=nLocalRoot || memcmp(zLocalRoot, zFull, nLocalRoot) ){
971
+ if( nFull<=nLocalRoot || xCmp(zLocalRoot, zFull, nLocalRoot) ){
966972
blob_reset(&localRoot);
967973
blob_reset(&full);
968974
if( errFatal ){
969975
fossil_fatal("file outside of checkout tree: %s", zOrigName);
970976
}
@@ -978,15 +984,20 @@
978984
979985
/*
980986
** COMMAND: test-tree-name
981987
**
982988
** Test the operation of the tree name generator.
989
+**
990
+** Options:
991
+** --case-sensitive B Enable or disable case-sensitive filenames. B is
992
+** a boolean: "yes", "no", "true", "false", etc.
983993
*/
984994
void cmd_test_tree_name(void){
985995
int i;
986996
Blob x;
987997
blob_zero(&x);
998
+ capture_case_sensitive_option();
988999
for(i=2; i<g.argc; i++){
9891000
if( file_tree_name(g.argv[i], &x, 1) ){
9901001
fossil_print("%s\n", blob_buffer(&x));
9911002
blob_reset(&x);
9921003
}
9931004
--- src/file.c
+++ src/file.c
@@ -941,10 +941,11 @@
941 int nLocalRoot;
942 char *zLocalRoot;
943 Blob full;
944 int nFull;
945 char *zFull;
 
946
947 blob_zero(pOut);
948 db_must_be_within_tree();
949 file_canonical_name(g.zLocalRoot, &localRoot, 1);
950 nLocalRoot = blob_size(&localRoot);
@@ -951,20 +952,25 @@
951 zLocalRoot = blob_buffer(&localRoot);
952 assert( nLocalRoot>0 && zLocalRoot[nLocalRoot-1]=='/' );
953 file_canonical_name(zOrigName, &full, 0);
954 nFull = blob_size(&full);
955 zFull = blob_buffer(&full);
 
 
 
 
 
956
957 /* Special case. zOrigName refers to g.zLocalRoot directory. */
958 if( nFull==nLocalRoot-1 && memcmp(zLocalRoot, zFull, nFull)==0 ){
959 blob_append(pOut, ".", 1);
960 blob_reset(&localRoot);
961 blob_reset(&full);
962 return 1;
963 }
964
965 if( nFull<=nLocalRoot || memcmp(zLocalRoot, zFull, nLocalRoot) ){
966 blob_reset(&localRoot);
967 blob_reset(&full);
968 if( errFatal ){
969 fossil_fatal("file outside of checkout tree: %s", zOrigName);
970 }
@@ -978,15 +984,20 @@
978
979 /*
980 ** COMMAND: test-tree-name
981 **
982 ** Test the operation of the tree name generator.
 
 
 
 
983 */
984 void cmd_test_tree_name(void){
985 int i;
986 Blob x;
987 blob_zero(&x);
 
988 for(i=2; i<g.argc; i++){
989 if( file_tree_name(g.argv[i], &x, 1) ){
990 fossil_print("%s\n", blob_buffer(&x));
991 blob_reset(&x);
992 }
993
--- src/file.c
+++ src/file.c
@@ -941,10 +941,11 @@
941 int nLocalRoot;
942 char *zLocalRoot;
943 Blob full;
944 int nFull;
945 char *zFull;
946 int (*xCmp)(const char*,const char*,int);
947
948 blob_zero(pOut);
949 db_must_be_within_tree();
950 file_canonical_name(g.zLocalRoot, &localRoot, 1);
951 nLocalRoot = blob_size(&localRoot);
@@ -951,20 +952,25 @@
952 zLocalRoot = blob_buffer(&localRoot);
953 assert( nLocalRoot>0 && zLocalRoot[nLocalRoot-1]=='/' );
954 file_canonical_name(zOrigName, &full, 0);
955 nFull = blob_size(&full);
956 zFull = blob_buffer(&full);
957 if( filenames_are_case_sensitive() ){
958 xCmp = fossil_strncmp;
959 }else{
960 xCmp = fossil_strnicmp;
961 }
962
963 /* Special case. zOrigName refers to g.zLocalRoot directory. */
964 if( nFull==nLocalRoot-1 && xCmp(zLocalRoot, zFull, nFull)==0 ){
965 blob_append(pOut, ".", 1);
966 blob_reset(&localRoot);
967 blob_reset(&full);
968 return 1;
969 }
970
971 if( nFull<=nLocalRoot || xCmp(zLocalRoot, zFull, nLocalRoot) ){
972 blob_reset(&localRoot);
973 blob_reset(&full);
974 if( errFatal ){
975 fossil_fatal("file outside of checkout tree: %s", zOrigName);
976 }
@@ -978,15 +984,20 @@
984
985 /*
986 ** COMMAND: test-tree-name
987 **
988 ** Test the operation of the tree name generator.
989 **
990 ** Options:
991 ** --case-sensitive B Enable or disable case-sensitive filenames. B is
992 ** a boolean: "yes", "no", "true", "false", etc.
993 */
994 void cmd_test_tree_name(void){
995 int i;
996 Blob x;
997 blob_zero(&x);
998 capture_case_sensitive_option();
999 for(i=2; i<g.argc; i++){
1000 if( file_tree_name(g.argv[i], &x, 1) ){
1001 fossil_print("%s\n", blob_buffer(&x));
1002 blob_reset(&x);
1003 }
1004

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button