Fossil SCM
If launched with no command-line arguments, check for a repo appended to the end of the executable and open "ui" on that repo.
Commit
37b2eb99917e0b18170a412aba7745486ba373f158e5579dba6ee395ade8ecf5
Parent
a09b33d51e23fec…
2 files changed
+4
+20
-1
M
src/db.c
+4
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1092,10 +1092,14 @@ | ||
| 1092 | 1092 | LOCAL sqlite3 *db_open(const char *zDbName){ |
| 1093 | 1093 | int rc; |
| 1094 | 1094 | sqlite3 *db; |
| 1095 | 1095 | |
| 1096 | 1096 | if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName); |
| 1097 | + if( strcmp(zDbName, g.nameOfExe)==0 ){ | |
| 1098 | + sqlite3_appendvfs_init(0,0,0); | |
| 1099 | + g.zVfsName = "apndvfs"; | |
| 1100 | + } | |
| 1097 | 1101 | rc = sqlite3_open_v2( |
| 1098 | 1102 | zDbName, &db, |
| 1099 | 1103 | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
| 1100 | 1104 | g.zVfsName |
| 1101 | 1105 | ); |
| 1102 | 1106 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1092,10 +1092,14 @@ | |
| 1092 | LOCAL sqlite3 *db_open(const char *zDbName){ |
| 1093 | int rc; |
| 1094 | sqlite3 *db; |
| 1095 | |
| 1096 | if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName); |
| 1097 | rc = sqlite3_open_v2( |
| 1098 | zDbName, &db, |
| 1099 | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
| 1100 | g.zVfsName |
| 1101 | ); |
| 1102 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1092,10 +1092,14 @@ | |
| 1092 | LOCAL sqlite3 *db_open(const char *zDbName){ |
| 1093 | int rc; |
| 1094 | sqlite3 *db; |
| 1095 | |
| 1096 | if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName); |
| 1097 | if( strcmp(zDbName, g.nameOfExe)==0 ){ |
| 1098 | sqlite3_appendvfs_init(0,0,0); |
| 1099 | g.zVfsName = "apndvfs"; |
| 1100 | } |
| 1101 | rc = sqlite3_open_v2( |
| 1102 | zDbName, &db, |
| 1103 | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
| 1104 | g.zVfsName |
| 1105 | ); |
| 1106 |
+20
-1
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -534,10 +534,29 @@ | ||
| 534 | 534 | g.comFmtFlags = atoi(zValue); |
| 535 | 535 | }else{ |
| 536 | 536 | g.comFmtFlags = COMMENT_PRINT_DEFAULT; |
| 537 | 537 | } |
| 538 | 538 | } |
| 539 | + | |
| 540 | +/* | |
| 541 | +** Check to see if the Fossil binary contains an appended repository | |
| 542 | +** file using the appendvfs extension. If so, change command-line arguments | |
| 543 | +** to cause Fossil to launch with "fossil ui" on that repo. | |
| 544 | +*/ | |
| 545 | +static int fossilExeHasAppendedRepo(void){ | |
| 546 | + extern int deduceDatabaseType(const char*,int); | |
| 547 | + if( 2==deduceDatabaseType(g.nameOfExe,0) ){ | |
| 548 | + static char *azAltArgv[] = { 0, "ui", 0, 0 }; | |
| 549 | + azAltArgv[0] = g.nameOfExe; | |
| 550 | + azAltArgv[2] = g.nameOfExe; | |
| 551 | + g.argv = azAltArgv; | |
| 552 | + g.argc = 3; | |
| 553 | + return 1; | |
| 554 | + }else{ | |
| 555 | + return 0; | |
| 556 | + } | |
| 557 | +} | |
| 539 | 558 | |
| 540 | 559 | /* |
| 541 | 560 | ** This procedure runs first. |
| 542 | 561 | */ |
| 543 | 562 | #if defined(_WIN32) && !defined(BROKEN_MINGW_CMDLINE) |
| @@ -598,11 +617,11 @@ | ||
| 598 | 617 | } |
| 599 | 618 | } |
| 600 | 619 | if( fossil_getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){ |
| 601 | 620 | zCmdName = "cgi"; |
| 602 | 621 | g.isHTTP = 1; |
| 603 | - }else if( g.argc<2 ){ | |
| 622 | + }else if( g.argc<2 && !fossilExeHasAppendedRepo() ){ | |
| 604 | 623 | fossil_print( |
| 605 | 624 | "Usage: %s COMMAND ...\n" |
| 606 | 625 | " or: %s help -- for a list of common commands\n" |
| 607 | 626 | " or: %s help COMMAND -- for help with the named command\n", |
| 608 | 627 | g.argv[0], g.argv[0], g.argv[0]); |
| 609 | 628 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -534,10 +534,29 @@ | |
| 534 | g.comFmtFlags = atoi(zValue); |
| 535 | }else{ |
| 536 | g.comFmtFlags = COMMENT_PRINT_DEFAULT; |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | /* |
| 541 | ** This procedure runs first. |
| 542 | */ |
| 543 | #if defined(_WIN32) && !defined(BROKEN_MINGW_CMDLINE) |
| @@ -598,11 +617,11 @@ | |
| 598 | } |
| 599 | } |
| 600 | if( fossil_getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){ |
| 601 | zCmdName = "cgi"; |
| 602 | g.isHTTP = 1; |
| 603 | }else if( g.argc<2 ){ |
| 604 | fossil_print( |
| 605 | "Usage: %s COMMAND ...\n" |
| 606 | " or: %s help -- for a list of common commands\n" |
| 607 | " or: %s help COMMAND -- for help with the named command\n", |
| 608 | g.argv[0], g.argv[0], g.argv[0]); |
| 609 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -534,10 +534,29 @@ | |
| 534 | g.comFmtFlags = atoi(zValue); |
| 535 | }else{ |
| 536 | g.comFmtFlags = COMMENT_PRINT_DEFAULT; |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | /* |
| 541 | ** Check to see if the Fossil binary contains an appended repository |
| 542 | ** file using the appendvfs extension. If so, change command-line arguments |
| 543 | ** to cause Fossil to launch with "fossil ui" on that repo. |
| 544 | */ |
| 545 | static int fossilExeHasAppendedRepo(void){ |
| 546 | extern int deduceDatabaseType(const char*,int); |
| 547 | if( 2==deduceDatabaseType(g.nameOfExe,0) ){ |
| 548 | static char *azAltArgv[] = { 0, "ui", 0, 0 }; |
| 549 | azAltArgv[0] = g.nameOfExe; |
| 550 | azAltArgv[2] = g.nameOfExe; |
| 551 | g.argv = azAltArgv; |
| 552 | g.argc = 3; |
| 553 | return 1; |
| 554 | }else{ |
| 555 | return 0; |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | /* |
| 560 | ** This procedure runs first. |
| 561 | */ |
| 562 | #if defined(_WIN32) && !defined(BROKEN_MINGW_CMDLINE) |
| @@ -598,11 +617,11 @@ | |
| 617 | } |
| 618 | } |
| 619 | if( fossil_getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){ |
| 620 | zCmdName = "cgi"; |
| 621 | g.isHTTP = 1; |
| 622 | }else if( g.argc<2 && !fossilExeHasAppendedRepo() ){ |
| 623 | fossil_print( |
| 624 | "Usage: %s COMMAND ...\n" |
| 625 | " or: %s help -- for a list of common commands\n" |
| 626 | " or: %s help COMMAND -- for help with the named command\n", |
| 627 | g.argv[0], g.argv[0], g.argv[0]); |
| 628 |