Fossil SCM
Add '--reset' option to the file test commands. Other minor improvements.
Commit
996ebab71bd93ef9eca356283303b1017f8afec9
Parent
7972e19f77094b6…
2 files changed
+25
-5
+1
+25
-5
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -105,10 +105,18 @@ | ||
| 105 | 105 | rc = win32_stat(zMbcs, buf, isWd); |
| 106 | 106 | #endif |
| 107 | 107 | fossil_path_free(zMbcs); |
| 108 | 108 | return rc; |
| 109 | 109 | } |
| 110 | + | |
| 111 | +/* | |
| 112 | +** Clears the fileStat variable and its associated validity flag. | |
| 113 | +*/ | |
| 114 | +static void resetStat(){ | |
| 115 | + fileStatValid = 0; | |
| 116 | + memset(&fileStat, 0, sizeof(struct fossilStat)); | |
| 117 | +} | |
| 110 | 118 | |
| 111 | 119 | /* |
| 112 | 120 | ** Fill in the fileStat variable for the file named zFilename. |
| 113 | 121 | ** If zFilename==0, then use the previous value of fileStat if |
| 114 | 122 | ** there is a previous value. |
| @@ -958,13 +966,19 @@ | ||
| 958 | 966 | blob_size(pOut), slash)); |
| 959 | 967 | } |
| 960 | 968 | |
| 961 | 969 | /* |
| 962 | 970 | ** Emits the effective or raw stat() information for the specified |
| 963 | -** file or directory. | |
| 971 | +** file or directory, optionally preserving the trailing slash and | |
| 972 | +** resetting the cached stat() information. | |
| 964 | 973 | */ |
| 965 | -static void emitFileStat(const char *zPath, int raw, int slash){ | |
| 974 | +static void emitFileStat( | |
| 975 | + const char *zPath, | |
| 976 | + int raw, | |
| 977 | + int slash, | |
| 978 | + int reset | |
| 979 | +){ | |
| 966 | 980 | char zBuf[100]; |
| 967 | 981 | Blob x; |
| 968 | 982 | memset(zBuf, 0, sizeof(zBuf)); |
| 969 | 983 | blob_zero(&x); |
| 970 | 984 | file_canonical_name(zPath, &x, slash); |
| @@ -988,10 +1002,11 @@ | ||
| 988 | 1002 | fossil_print(" l_stat_size = %s\n", zBuf); |
| 989 | 1003 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_mtime); |
| 990 | 1004 | fossil_print(" l_stat_mtime = %s\n", zBuf); |
| 991 | 1005 | fossil_print(" l_stat_mode = %d\n", testFileStat.st_mode); |
| 992 | 1006 | }else{ |
| 1007 | + if( reset ) resetStat(); | |
| 993 | 1008 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_size(zPath)); |
| 994 | 1009 | fossil_print(" file_size = %s\n", zBuf); |
| 995 | 1010 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_mtime(zPath)); |
| 996 | 1011 | fossil_print(" file_mtime = %s\n", zBuf); |
| 997 | 1012 | fossil_print(" file_mode = %d\n", file_wd_mode(zPath)); |
| @@ -1013,28 +1028,31 @@ | ||
| 1013 | 1028 | ** |
| 1014 | 1029 | ** Options: |
| 1015 | 1030 | ** |
| 1016 | 1031 | ** --open-config Open the configuration database first. |
| 1017 | 1032 | ** --slash Trailing slashes, if any, are retained. |
| 1033 | +** --reset Reset cached stat() info for each file. | |
| 1018 | 1034 | */ |
| 1019 | 1035 | void cmd_test_file_environment(void){ |
| 1020 | 1036 | int i; |
| 1021 | 1037 | int slashFlag = find_option("slash",0,0)!=0; |
| 1038 | + int resetFlag = find_option("reset",0,0)!=0; | |
| 1022 | 1039 | if( find_option("open-config", 0, 0)!=0 ){ |
| 1023 | 1040 | Th_OpenConfig(1); |
| 1024 | 1041 | } |
| 1042 | + fossil_print("Th_IsLocalOpen() = %d\n", Th_IsLocalOpen()); | |
| 1025 | 1043 | fossil_print("Th_IsRepositoryOpen() = %d\n", Th_IsRepositoryOpen()); |
| 1026 | 1044 | fossil_print("Th_IsConfigOpen() = %d\n", Th_IsConfigOpen()); |
| 1027 | 1045 | fossil_print("filenames_are_case_sensitive() = %d\n", |
| 1028 | 1046 | filenames_are_case_sensitive()); |
| 1029 | 1047 | fossil_print("db_allow_symlinks_by_default() = %d\n", |
| 1030 | 1048 | db_allow_symlinks_by_default()); |
| 1031 | 1049 | fossil_print("db_allow_symlinks(0) = %d\n", db_allow_symlinks(0)); |
| 1032 | 1050 | fossil_print("db_allow_symlinks(1) = %d\n", db_allow_symlinks(1)); |
| 1033 | 1051 | for(i=2; i<g.argc; i++){ |
| 1034 | - emitFileStat(g.argv[i], 1, slashFlag); | |
| 1035 | - emitFileStat(g.argv[i], 0, slashFlag); | |
| 1052 | + emitFileStat(g.argv[i], 1, slashFlag, resetFlag); | |
| 1053 | + emitFileStat(g.argv[i], 0, slashFlag, resetFlag); | |
| 1036 | 1054 | } |
| 1037 | 1055 | } |
| 1038 | 1056 | |
| 1039 | 1057 | /* |
| 1040 | 1058 | ** COMMAND: test-canonical-name |
| @@ -1046,19 +1064,21 @@ | ||
| 1046 | 1064 | ** |
| 1047 | 1065 | ** Options: |
| 1048 | 1066 | ** |
| 1049 | 1067 | ** --open-config Open the configuration database first. |
| 1050 | 1068 | ** --slash Trailing slashes, if any, are retained. |
| 1069 | +** --reset Reset cached stat() info for each file. | |
| 1051 | 1070 | */ |
| 1052 | 1071 | void cmd_test_canonical_name(void){ |
| 1053 | 1072 | int i; |
| 1054 | 1073 | int slashFlag = find_option("slash",0,0)!=0; |
| 1074 | + int resetFlag = find_option("reset",0,0)!=0; | |
| 1055 | 1075 | if( find_option("open-config", 0, 0)!=0 ){ |
| 1056 | 1076 | Th_OpenConfig(1); |
| 1057 | 1077 | } |
| 1058 | 1078 | for(i=2; i<g.argc; i++){ |
| 1059 | - emitFileStat(g.argv[i], 0, slashFlag); | |
| 1079 | + emitFileStat(g.argv[i], 0, slashFlag, resetFlag); | |
| 1060 | 1080 | } |
| 1061 | 1081 | } |
| 1062 | 1082 | |
| 1063 | 1083 | /* |
| 1064 | 1084 | ** Return TRUE if the given filename is canonical. |
| 1065 | 1085 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -105,10 +105,18 @@ | |
| 105 | rc = win32_stat(zMbcs, buf, isWd); |
| 106 | #endif |
| 107 | fossil_path_free(zMbcs); |
| 108 | return rc; |
| 109 | } |
| 110 | |
| 111 | /* |
| 112 | ** Fill in the fileStat variable for the file named zFilename. |
| 113 | ** If zFilename==0, then use the previous value of fileStat if |
| 114 | ** there is a previous value. |
| @@ -958,13 +966,19 @@ | |
| 958 | blob_size(pOut), slash)); |
| 959 | } |
| 960 | |
| 961 | /* |
| 962 | ** Emits the effective or raw stat() information for the specified |
| 963 | ** file or directory. |
| 964 | */ |
| 965 | static void emitFileStat(const char *zPath, int raw, int slash){ |
| 966 | char zBuf[100]; |
| 967 | Blob x; |
| 968 | memset(zBuf, 0, sizeof(zBuf)); |
| 969 | blob_zero(&x); |
| 970 | file_canonical_name(zPath, &x, slash); |
| @@ -988,10 +1002,11 @@ | |
| 988 | fossil_print(" l_stat_size = %s\n", zBuf); |
| 989 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_mtime); |
| 990 | fossil_print(" l_stat_mtime = %s\n", zBuf); |
| 991 | fossil_print(" l_stat_mode = %d\n", testFileStat.st_mode); |
| 992 | }else{ |
| 993 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_size(zPath)); |
| 994 | fossil_print(" file_size = %s\n", zBuf); |
| 995 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_mtime(zPath)); |
| 996 | fossil_print(" file_mtime = %s\n", zBuf); |
| 997 | fossil_print(" file_mode = %d\n", file_wd_mode(zPath)); |
| @@ -1013,28 +1028,31 @@ | |
| 1013 | ** |
| 1014 | ** Options: |
| 1015 | ** |
| 1016 | ** --open-config Open the configuration database first. |
| 1017 | ** --slash Trailing slashes, if any, are retained. |
| 1018 | */ |
| 1019 | void cmd_test_file_environment(void){ |
| 1020 | int i; |
| 1021 | int slashFlag = find_option("slash",0,0)!=0; |
| 1022 | if( find_option("open-config", 0, 0)!=0 ){ |
| 1023 | Th_OpenConfig(1); |
| 1024 | } |
| 1025 | fossil_print("Th_IsRepositoryOpen() = %d\n", Th_IsRepositoryOpen()); |
| 1026 | fossil_print("Th_IsConfigOpen() = %d\n", Th_IsConfigOpen()); |
| 1027 | fossil_print("filenames_are_case_sensitive() = %d\n", |
| 1028 | filenames_are_case_sensitive()); |
| 1029 | fossil_print("db_allow_symlinks_by_default() = %d\n", |
| 1030 | db_allow_symlinks_by_default()); |
| 1031 | fossil_print("db_allow_symlinks(0) = %d\n", db_allow_symlinks(0)); |
| 1032 | fossil_print("db_allow_symlinks(1) = %d\n", db_allow_symlinks(1)); |
| 1033 | for(i=2; i<g.argc; i++){ |
| 1034 | emitFileStat(g.argv[i], 1, slashFlag); |
| 1035 | emitFileStat(g.argv[i], 0, slashFlag); |
| 1036 | } |
| 1037 | } |
| 1038 | |
| 1039 | /* |
| 1040 | ** COMMAND: test-canonical-name |
| @@ -1046,19 +1064,21 @@ | |
| 1046 | ** |
| 1047 | ** Options: |
| 1048 | ** |
| 1049 | ** --open-config Open the configuration database first. |
| 1050 | ** --slash Trailing slashes, if any, are retained. |
| 1051 | */ |
| 1052 | void cmd_test_canonical_name(void){ |
| 1053 | int i; |
| 1054 | int slashFlag = find_option("slash",0,0)!=0; |
| 1055 | if( find_option("open-config", 0, 0)!=0 ){ |
| 1056 | Th_OpenConfig(1); |
| 1057 | } |
| 1058 | for(i=2; i<g.argc; i++){ |
| 1059 | emitFileStat(g.argv[i], 0, slashFlag); |
| 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | /* |
| 1064 | ** Return TRUE if the given filename is canonical. |
| 1065 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -105,10 +105,18 @@ | |
| 105 | rc = win32_stat(zMbcs, buf, isWd); |
| 106 | #endif |
| 107 | fossil_path_free(zMbcs); |
| 108 | return rc; |
| 109 | } |
| 110 | |
| 111 | /* |
| 112 | ** Clears the fileStat variable and its associated validity flag. |
| 113 | */ |
| 114 | static void resetStat(){ |
| 115 | fileStatValid = 0; |
| 116 | memset(&fileStat, 0, sizeof(struct fossilStat)); |
| 117 | } |
| 118 | |
| 119 | /* |
| 120 | ** Fill in the fileStat variable for the file named zFilename. |
| 121 | ** If zFilename==0, then use the previous value of fileStat if |
| 122 | ** there is a previous value. |
| @@ -958,13 +966,19 @@ | |
| 966 | blob_size(pOut), slash)); |
| 967 | } |
| 968 | |
| 969 | /* |
| 970 | ** Emits the effective or raw stat() information for the specified |
| 971 | ** file or directory, optionally preserving the trailing slash and |
| 972 | ** resetting the cached stat() information. |
| 973 | */ |
| 974 | static void emitFileStat( |
| 975 | const char *zPath, |
| 976 | int raw, |
| 977 | int slash, |
| 978 | int reset |
| 979 | ){ |
| 980 | char zBuf[100]; |
| 981 | Blob x; |
| 982 | memset(zBuf, 0, sizeof(zBuf)); |
| 983 | blob_zero(&x); |
| 984 | file_canonical_name(zPath, &x, slash); |
| @@ -988,10 +1002,11 @@ | |
| 1002 | fossil_print(" l_stat_size = %s\n", zBuf); |
| 1003 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_mtime); |
| 1004 | fossil_print(" l_stat_mtime = %s\n", zBuf); |
| 1005 | fossil_print(" l_stat_mode = %d\n", testFileStat.st_mode); |
| 1006 | }else{ |
| 1007 | if( reset ) resetStat(); |
| 1008 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_size(zPath)); |
| 1009 | fossil_print(" file_size = %s\n", zBuf); |
| 1010 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_mtime(zPath)); |
| 1011 | fossil_print(" file_mtime = %s\n", zBuf); |
| 1012 | fossil_print(" file_mode = %d\n", file_wd_mode(zPath)); |
| @@ -1013,28 +1028,31 @@ | |
| 1028 | ** |
| 1029 | ** Options: |
| 1030 | ** |
| 1031 | ** --open-config Open the configuration database first. |
| 1032 | ** --slash Trailing slashes, if any, are retained. |
| 1033 | ** --reset Reset cached stat() info for each file. |
| 1034 | */ |
| 1035 | void cmd_test_file_environment(void){ |
| 1036 | int i; |
| 1037 | int slashFlag = find_option("slash",0,0)!=0; |
| 1038 | int resetFlag = find_option("reset",0,0)!=0; |
| 1039 | if( find_option("open-config", 0, 0)!=0 ){ |
| 1040 | Th_OpenConfig(1); |
| 1041 | } |
| 1042 | fossil_print("Th_IsLocalOpen() = %d\n", Th_IsLocalOpen()); |
| 1043 | fossil_print("Th_IsRepositoryOpen() = %d\n", Th_IsRepositoryOpen()); |
| 1044 | fossil_print("Th_IsConfigOpen() = %d\n", Th_IsConfigOpen()); |
| 1045 | fossil_print("filenames_are_case_sensitive() = %d\n", |
| 1046 | filenames_are_case_sensitive()); |
| 1047 | fossil_print("db_allow_symlinks_by_default() = %d\n", |
| 1048 | db_allow_symlinks_by_default()); |
| 1049 | fossil_print("db_allow_symlinks(0) = %d\n", db_allow_symlinks(0)); |
| 1050 | fossil_print("db_allow_symlinks(1) = %d\n", db_allow_symlinks(1)); |
| 1051 | for(i=2; i<g.argc; i++){ |
| 1052 | emitFileStat(g.argv[i], 1, slashFlag, resetFlag); |
| 1053 | emitFileStat(g.argv[i], 0, slashFlag, resetFlag); |
| 1054 | } |
| 1055 | } |
| 1056 | |
| 1057 | /* |
| 1058 | ** COMMAND: test-canonical-name |
| @@ -1046,19 +1064,21 @@ | |
| 1064 | ** |
| 1065 | ** Options: |
| 1066 | ** |
| 1067 | ** --open-config Open the configuration database first. |
| 1068 | ** --slash Trailing slashes, if any, are retained. |
| 1069 | ** --reset Reset cached stat() info for each file. |
| 1070 | */ |
| 1071 | void cmd_test_canonical_name(void){ |
| 1072 | int i; |
| 1073 | int slashFlag = find_option("slash",0,0)!=0; |
| 1074 | int resetFlag = find_option("reset",0,0)!=0; |
| 1075 | if( find_option("open-config", 0, 0)!=0 ){ |
| 1076 | Th_OpenConfig(1); |
| 1077 | } |
| 1078 | for(i=2; i<g.argc; i++){ |
| 1079 | emitFileStat(g.argv[i], 0, slashFlag, resetFlag); |
| 1080 | } |
| 1081 | } |
| 1082 | |
| 1083 | /* |
| 1084 | ** Return TRUE if the given filename is canonical. |
| 1085 |
+1
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -25,10 +25,11 @@ | ||
| 25 | 25 | #if INTERFACE |
| 26 | 26 | /* |
| 27 | 27 | ** These macros are used within this file to detect if the repository and |
| 28 | 28 | ** configuration ("user") database are currently open. |
| 29 | 29 | */ |
| 30 | +#define Th_IsLocalOpen() (g.localOpen) | |
| 30 | 31 | #define Th_IsRepositoryOpen() (g.repositoryOpen) |
| 31 | 32 | #define Th_IsConfigOpen() (g.zConfigDbName!=0) |
| 32 | 33 | |
| 33 | 34 | /* |
| 34 | 35 | ** Flag parameters to the Th_FossilInit() routine used to control the |
| 35 | 36 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -25,10 +25,11 @@ | |
| 25 | #if INTERFACE |
| 26 | /* |
| 27 | ** These macros are used within this file to detect if the repository and |
| 28 | ** configuration ("user") database are currently open. |
| 29 | */ |
| 30 | #define Th_IsRepositoryOpen() (g.repositoryOpen) |
| 31 | #define Th_IsConfigOpen() (g.zConfigDbName!=0) |
| 32 | |
| 33 | /* |
| 34 | ** Flag parameters to the Th_FossilInit() routine used to control the |
| 35 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -25,10 +25,11 @@ | |
| 25 | #if INTERFACE |
| 26 | /* |
| 27 | ** These macros are used within this file to detect if the repository and |
| 28 | ** configuration ("user") database are currently open. |
| 29 | */ |
| 30 | #define Th_IsLocalOpen() (g.localOpen) |
| 31 | #define Th_IsRepositoryOpen() (g.repositoryOpen) |
| 32 | #define Th_IsConfigOpen() (g.zConfigDbName!=0) |
| 33 | |
| 34 | /* |
| 35 | ** Flag parameters to the Th_FossilInit() routine used to control the |
| 36 |