Fossil SCM

Add '--reset' option to the file test commands. Other minor improvements.

mistachkin 2017-02-14 00:59 UTC symlinks
Commit 996ebab71bd93ef9eca356283303b1017f8afec9
2 files changed +25 -5 +1
+25 -5
--- src/file.c
+++ src/file.c
@@ -105,10 +105,18 @@
105105
rc = win32_stat(zMbcs, buf, isWd);
106106
#endif
107107
fossil_path_free(zMbcs);
108108
return rc;
109109
}
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
+}
110118
111119
/*
112120
** Fill in the fileStat variable for the file named zFilename.
113121
** If zFilename==0, then use the previous value of fileStat if
114122
** there is a previous value.
@@ -958,13 +966,19 @@
958966
blob_size(pOut), slash));
959967
}
960968
961969
/*
962970
** 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.
964973
*/
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
+){
966980
char zBuf[100];
967981
Blob x;
968982
memset(zBuf, 0, sizeof(zBuf));
969983
blob_zero(&x);
970984
file_canonical_name(zPath, &x, slash);
@@ -988,10 +1002,11 @@
9881002
fossil_print(" l_stat_size = %s\n", zBuf);
9891003
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_mtime);
9901004
fossil_print(" l_stat_mtime = %s\n", zBuf);
9911005
fossil_print(" l_stat_mode = %d\n", testFileStat.st_mode);
9921006
}else{
1007
+ if( reset ) resetStat();
9931008
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_size(zPath));
9941009
fossil_print(" file_size = %s\n", zBuf);
9951010
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_mtime(zPath));
9961011
fossil_print(" file_mtime = %s\n", zBuf);
9971012
fossil_print(" file_mode = %d\n", file_wd_mode(zPath));
@@ -1013,28 +1028,31 @@
10131028
**
10141029
** Options:
10151030
**
10161031
** --open-config Open the configuration database first.
10171032
** --slash Trailing slashes, if any, are retained.
1033
+** --reset Reset cached stat() info for each file.
10181034
*/
10191035
void cmd_test_file_environment(void){
10201036
int i;
10211037
int slashFlag = find_option("slash",0,0)!=0;
1038
+ int resetFlag = find_option("reset",0,0)!=0;
10221039
if( find_option("open-config", 0, 0)!=0 ){
10231040
Th_OpenConfig(1);
10241041
}
1042
+ fossil_print("Th_IsLocalOpen() = %d\n", Th_IsLocalOpen());
10251043
fossil_print("Th_IsRepositoryOpen() = %d\n", Th_IsRepositoryOpen());
10261044
fossil_print("Th_IsConfigOpen() = %d\n", Th_IsConfigOpen());
10271045
fossil_print("filenames_are_case_sensitive() = %d\n",
10281046
filenames_are_case_sensitive());
10291047
fossil_print("db_allow_symlinks_by_default() = %d\n",
10301048
db_allow_symlinks_by_default());
10311049
fossil_print("db_allow_symlinks(0) = %d\n", db_allow_symlinks(0));
10321050
fossil_print("db_allow_symlinks(1) = %d\n", db_allow_symlinks(1));
10331051
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);
10361054
}
10371055
}
10381056
10391057
/*
10401058
** COMMAND: test-canonical-name
@@ -1046,19 +1064,21 @@
10461064
**
10471065
** Options:
10481066
**
10491067
** --open-config Open the configuration database first.
10501068
** --slash Trailing slashes, if any, are retained.
1069
+** --reset Reset cached stat() info for each file.
10511070
*/
10521071
void cmd_test_canonical_name(void){
10531072
int i;
10541073
int slashFlag = find_option("slash",0,0)!=0;
1074
+ int resetFlag = find_option("reset",0,0)!=0;
10551075
if( find_option("open-config", 0, 0)!=0 ){
10561076
Th_OpenConfig(1);
10571077
}
10581078
for(i=2; i<g.argc; i++){
1059
- emitFileStat(g.argv[i], 0, slashFlag);
1079
+ emitFileStat(g.argv[i], 0, slashFlag, resetFlag);
10601080
}
10611081
}
10621082
10631083
/*
10641084
** Return TRUE if the given filename is canonical.
10651085
--- 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
--- src/th_main.c
+++ src/th_main.c
@@ -25,10 +25,11 @@
2525
#if INTERFACE
2626
/*
2727
** These macros are used within this file to detect if the repository and
2828
** configuration ("user") database are currently open.
2929
*/
30
+#define Th_IsLocalOpen() (g.localOpen)
3031
#define Th_IsRepositoryOpen() (g.repositoryOpen)
3132
#define Th_IsConfigOpen() (g.zConfigDbName!=0)
3233
3334
/*
3435
** Flag parameters to the Th_FossilInit() routine used to control the
3536
--- 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

Keyboard Shortcuts

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