Fossil SCM

On the "fossil info" command with no arguments and outside of an open checkout, or with the -v option, show the location of the fossil executable and the version number.

drh 2020-04-19 14:34 trunk
Commit 1da8afdf876efbbd07a9334e8f260b6fc6862dd138e6b9fa271e4c2e88ecf5cd
2 files changed +17 -1 +3 -3
+17 -1
--- src/info.c
+++ src/info.c
@@ -229,11 +229,13 @@
229229
}
230230
if( g.localOpen ){
231231
fossil_print("repository: %s\n", db_repository_filename());
232232
fossil_print("local-root: %s\n", g.zLocalRoot);
233233
}
234
- if( verboseFlag && g.repositoryOpen ) extraRepoInfo();
234
+ if( verboseFlag && g.repositoryOpen ){
235
+ extraRepoInfo();
236
+ }
235237
if( g.zConfigDbName ){
236238
fossil_print("config-db: %s\n", g.zConfigDbName);
237239
}
238240
if( g.repositoryOpen ){
239241
fossil_print("project-code: %s\n", db_get("project-code", ""));
@@ -242,10 +244,24 @@
242244
if( vid ){
243245
show_common_info(vid, "checkout:", 1, 1);
244246
}
245247
fossil_print("check-ins: %d\n",
246248
db_int(-1, "SELECT count(*) FROM event WHERE type='ci' /*scan*/"));
249
+ }
250
+ if( verboseFlag || !g.repositoryOpen ){
251
+ Blob vx;
252
+ char *z;
253
+ fossil_version_blob(&vx, 0);
254
+ z = strstr(blob_str(&vx), "version");
255
+ if( z ){
256
+ z += 8;
257
+ }else{
258
+ z = blob_str(&vx);
259
+ }
260
+ fossil_print("fossil: %s\n", g.nameOfExe);
261
+ fossil_print("version: %s", z);
262
+ blob_reset(&vx);
247263
}
248264
}else{
249265
int rid;
250266
rid = name_to_rid(g.argv[2]);
251267
if( rid==0 ){
252268
--- src/info.c
+++ src/info.c
@@ -229,11 +229,13 @@
229 }
230 if( g.localOpen ){
231 fossil_print("repository: %s\n", db_repository_filename());
232 fossil_print("local-root: %s\n", g.zLocalRoot);
233 }
234 if( verboseFlag && g.repositoryOpen ) extraRepoInfo();
 
 
235 if( g.zConfigDbName ){
236 fossil_print("config-db: %s\n", g.zConfigDbName);
237 }
238 if( g.repositoryOpen ){
239 fossil_print("project-code: %s\n", db_get("project-code", ""));
@@ -242,10 +244,24 @@
242 if( vid ){
243 show_common_info(vid, "checkout:", 1, 1);
244 }
245 fossil_print("check-ins: %d\n",
246 db_int(-1, "SELECT count(*) FROM event WHERE type='ci' /*scan*/"));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247 }
248 }else{
249 int rid;
250 rid = name_to_rid(g.argv[2]);
251 if( rid==0 ){
252
--- src/info.c
+++ src/info.c
@@ -229,11 +229,13 @@
229 }
230 if( g.localOpen ){
231 fossil_print("repository: %s\n", db_repository_filename());
232 fossil_print("local-root: %s\n", g.zLocalRoot);
233 }
234 if( verboseFlag && g.repositoryOpen ){
235 extraRepoInfo();
236 }
237 if( g.zConfigDbName ){
238 fossil_print("config-db: %s\n", g.zConfigDbName);
239 }
240 if( g.repositoryOpen ){
241 fossil_print("project-code: %s\n", db_get("project-code", ""));
@@ -242,10 +244,24 @@
244 if( vid ){
245 show_common_info(vid, "checkout:", 1, 1);
246 }
247 fossil_print("check-ins: %d\n",
248 db_int(-1, "SELECT count(*) FROM event WHERE type='ci' /*scan*/"));
249 }
250 if( verboseFlag || !g.repositoryOpen ){
251 Blob vx;
252 char *z;
253 fossil_version_blob(&vx, 0);
254 z = strstr(blob_str(&vx), "version");
255 if( z ){
256 z += 8;
257 }else{
258 z = blob_str(&vx);
259 }
260 fossil_print("fossil: %s\n", g.nameOfExe);
261 fossil_print("version: %s", z);
262 blob_reset(&vx);
263 }
264 }else{
265 int rid;
266 rid = name_to_rid(g.argv[2]);
267 if( rid==0 ){
268
+3 -3
--- src/main.c
+++ src/main.c
@@ -1116,11 +1116,11 @@
11161116
/*
11171117
** This function populates a blob with version information. It is used by
11181118
** the "version" command and "test-version" web page. It assumes the blob
11191119
** passed to it is uninitialized; otherwise, it will leak memory.
11201120
*/
1121
-static void get_version_blob(
1121
+void fossil_version_blob(
11221122
Blob *pOut, /* Write the manifest here */
11231123
int bVerbose /* Non-zero for full information. */
11241124
){
11251125
#if defined(FOSSIL_ENABLE_TCL)
11261126
int rc;
@@ -1251,11 +1251,11 @@
12511251
Blob versionInfo;
12521252
int verboseFlag = find_option("verbose","v",0)!=0;
12531253
12541254
/* We should be done with options.. */
12551255
verify_all_options();
1256
- get_version_blob(&versionInfo, verboseFlag);
1256
+ fossil_version_blob(&versionInfo, verboseFlag);
12571257
fossil_print("%s", blob_str(&versionInfo));
12581258
}
12591259
12601260
12611261
/*
@@ -1274,11 +1274,11 @@
12741274
login_check_credentials();
12751275
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
12761276
verboseFlag = PD("verbose", 0) != 0;
12771277
style_header("Version Information");
12781278
style_submenu_element("Stat", "stat");
1279
- get_version_blob(&versionInfo, verboseFlag);
1279
+ fossil_version_blob(&versionInfo, verboseFlag);
12801280
@ <pre>
12811281
@ %h(blob_str(&versionInfo))
12821282
@ </pre>
12831283
style_footer();
12841284
}
12851285
--- src/main.c
+++ src/main.c
@@ -1116,11 +1116,11 @@
1116 /*
1117 ** This function populates a blob with version information. It is used by
1118 ** the "version" command and "test-version" web page. It assumes the blob
1119 ** passed to it is uninitialized; otherwise, it will leak memory.
1120 */
1121 static void get_version_blob(
1122 Blob *pOut, /* Write the manifest here */
1123 int bVerbose /* Non-zero for full information. */
1124 ){
1125 #if defined(FOSSIL_ENABLE_TCL)
1126 int rc;
@@ -1251,11 +1251,11 @@
1251 Blob versionInfo;
1252 int verboseFlag = find_option("verbose","v",0)!=0;
1253
1254 /* We should be done with options.. */
1255 verify_all_options();
1256 get_version_blob(&versionInfo, verboseFlag);
1257 fossil_print("%s", blob_str(&versionInfo));
1258 }
1259
1260
1261 /*
@@ -1274,11 +1274,11 @@
1274 login_check_credentials();
1275 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
1276 verboseFlag = PD("verbose", 0) != 0;
1277 style_header("Version Information");
1278 style_submenu_element("Stat", "stat");
1279 get_version_blob(&versionInfo, verboseFlag);
1280 @ <pre>
1281 @ %h(blob_str(&versionInfo))
1282 @ </pre>
1283 style_footer();
1284 }
1285
--- src/main.c
+++ src/main.c
@@ -1116,11 +1116,11 @@
1116 /*
1117 ** This function populates a blob with version information. It is used by
1118 ** the "version" command and "test-version" web page. It assumes the blob
1119 ** passed to it is uninitialized; otherwise, it will leak memory.
1120 */
1121 void fossil_version_blob(
1122 Blob *pOut, /* Write the manifest here */
1123 int bVerbose /* Non-zero for full information. */
1124 ){
1125 #if defined(FOSSIL_ENABLE_TCL)
1126 int rc;
@@ -1251,11 +1251,11 @@
1251 Blob versionInfo;
1252 int verboseFlag = find_option("verbose","v",0)!=0;
1253
1254 /* We should be done with options.. */
1255 verify_all_options();
1256 fossil_version_blob(&versionInfo, verboseFlag);
1257 fossil_print("%s", blob_str(&versionInfo));
1258 }
1259
1260
1261 /*
@@ -1274,11 +1274,11 @@
1274 login_check_credentials();
1275 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
1276 verboseFlag = PD("verbose", 0) != 0;
1277 style_header("Version Information");
1278 style_submenu_element("Stat", "stat");
1279 fossil_version_blob(&versionInfo, verboseFlag);
1280 @ <pre>
1281 @ %h(blob_str(&versionInfo))
1282 @ </pre>
1283 style_footer();
1284 }
1285

Keyboard Shortcuts

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