Fossil SCM
Function file_tree_name() should respect case-sensitive setting. Add --case-sensitive option to test-tree-name.
Commit
0df0ce8025c6b883050783d00a164495fcb0ebbf
Parent
a38fa0b80bad23b…
1 file changed
+13
-2
+13
-2
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -941,10 +941,11 @@ | ||
| 941 | 941 | int nLocalRoot; |
| 942 | 942 | char *zLocalRoot; |
| 943 | 943 | Blob full; |
| 944 | 944 | int nFull; |
| 945 | 945 | char *zFull; |
| 946 | + int (*xCmp)(const char*,const char*,int); | |
| 946 | 947 | |
| 947 | 948 | blob_zero(pOut); |
| 948 | 949 | db_must_be_within_tree(); |
| 949 | 950 | file_canonical_name(g.zLocalRoot, &localRoot, 1); |
| 950 | 951 | nLocalRoot = blob_size(&localRoot); |
| @@ -951,20 +952,25 @@ | ||
| 951 | 952 | zLocalRoot = blob_buffer(&localRoot); |
| 952 | 953 | assert( nLocalRoot>0 && zLocalRoot[nLocalRoot-1]=='/' ); |
| 953 | 954 | file_canonical_name(zOrigName, &full, 0); |
| 954 | 955 | nFull = blob_size(&full); |
| 955 | 956 | zFull = blob_buffer(&full); |
| 957 | + if( filenames_are_case_sensitive() ){ | |
| 958 | + xCmp = fossil_strncmp; | |
| 959 | + }else{ | |
| 960 | + xCmp = fossil_strnicmp; | |
| 961 | + } | |
| 956 | 962 | |
| 957 | 963 | /* 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 ){ | |
| 959 | 965 | blob_append(pOut, ".", 1); |
| 960 | 966 | blob_reset(&localRoot); |
| 961 | 967 | blob_reset(&full); |
| 962 | 968 | return 1; |
| 963 | 969 | } |
| 964 | 970 | |
| 965 | - if( nFull<=nLocalRoot || memcmp(zLocalRoot, zFull, nLocalRoot) ){ | |
| 971 | + if( nFull<=nLocalRoot || xCmp(zLocalRoot, zFull, nLocalRoot) ){ | |
| 966 | 972 | blob_reset(&localRoot); |
| 967 | 973 | blob_reset(&full); |
| 968 | 974 | if( errFatal ){ |
| 969 | 975 | fossil_fatal("file outside of checkout tree: %s", zOrigName); |
| 970 | 976 | } |
| @@ -978,15 +984,20 @@ | ||
| 978 | 984 | |
| 979 | 985 | /* |
| 980 | 986 | ** COMMAND: test-tree-name |
| 981 | 987 | ** |
| 982 | 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. | |
| 983 | 993 | */ |
| 984 | 994 | void cmd_test_tree_name(void){ |
| 985 | 995 | int i; |
| 986 | 996 | Blob x; |
| 987 | 997 | blob_zero(&x); |
| 998 | + capture_case_sensitive_option(); | |
| 988 | 999 | for(i=2; i<g.argc; i++){ |
| 989 | 1000 | if( file_tree_name(g.argv[i], &x, 1) ){ |
| 990 | 1001 | fossil_print("%s\n", blob_buffer(&x)); |
| 991 | 1002 | blob_reset(&x); |
| 992 | 1003 | } |
| 993 | 1004 |
| --- 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 |