Fossil SCM
Fix problem when using "fossil cat" when specifying repository via command line argument (with -R) (reported on ML) Problem was the use of file_tree_name() which call db_must_be_within_tree(). Add a variable in the Global structure 'g' to remember if -R|--repository argument was specified and don't call file_tree_name() if it's the case (since user expect file relative to repository. (Pending review...)
Commit
dc10f8d74cbdb150bd09c0f9fded8ce9a5d90952
Parent
f46482a90534845…
3 files changed
+3
+13
-1
+1
M
src/db.c
+3
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1046,10 +1046,13 @@ | ||
| 1046 | 1046 | ** |
| 1047 | 1047 | ** Error out if the repository cannot be opened. |
| 1048 | 1048 | */ |
| 1049 | 1049 | void db_find_and_open_repository(int bFlags, int nArgUsed){ |
| 1050 | 1050 | const char *zRep = find_option("repository", "R", 1); |
| 1051 | + if (zRep){ | |
| 1052 | + g.useRepositoryFromCmdArg = 1; | |
| 1053 | + } | |
| 1051 | 1054 | if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){ |
| 1052 | 1055 | zRep = g.argv[nArgUsed]; |
| 1053 | 1056 | } |
| 1054 | 1057 | if( zRep==0 ){ |
| 1055 | 1058 | if( db_open_local(0)==0 ){ |
| 1056 | 1059 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1046,10 +1046,13 @@ | |
| 1046 | ** |
| 1047 | ** Error out if the repository cannot be opened. |
| 1048 | */ |
| 1049 | void db_find_and_open_repository(int bFlags, int nArgUsed){ |
| 1050 | const char *zRep = find_option("repository", "R", 1); |
| 1051 | if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){ |
| 1052 | zRep = g.argv[nArgUsed]; |
| 1053 | } |
| 1054 | if( zRep==0 ){ |
| 1055 | if( db_open_local(0)==0 ){ |
| 1056 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1046,10 +1046,13 @@ | |
| 1046 | ** |
| 1047 | ** Error out if the repository cannot be opened. |
| 1048 | */ |
| 1049 | void db_find_and_open_repository(int bFlags, int nArgUsed){ |
| 1050 | const char *zRep = find_option("repository", "R", 1); |
| 1051 | if (zRep){ |
| 1052 | g.useRepositoryFromCmdArg = 1; |
| 1053 | } |
| 1054 | if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){ |
| 1055 | zRep = g.argv[nArgUsed]; |
| 1056 | } |
| 1057 | if( zRep==0 ){ |
| 1058 | if( db_open_local(0)==0 ){ |
| 1059 |
+13
-1
| --- src/finfo.c | ||
| +++ src/finfo.c | ||
| @@ -237,11 +237,23 @@ | ||
| 237 | 237 | Blob content, fname; |
| 238 | 238 | const char *zRev; |
| 239 | 239 | db_find_and_open_repository(0, 0); |
| 240 | 240 | zRev = find_option("r","r",1); |
| 241 | 241 | for(i=2; i<g.argc; i++){ |
| 242 | - file_tree_name(g.argv[i], &fname, 1); | |
| 242 | + if( g.useRepositoryFromCmdArg ){ | |
| 243 | + /* If specify -R <repository>, arguments should already be the tree-name */ | |
| 244 | + blob_set(&fname, g.argv[i]); | |
| 245 | + /* | |
| 246 | + ** if no rev specified, default to main-branch to don't let | |
| 247 | + ** historical_version_of_file() get local checkout revision | |
| 248 | + */ | |
| 249 | + if( zRev==0 ){ | |
| 250 | + zRev=db_get("main-branch", "trunk"); | |
| 251 | + } | |
| 252 | + }else{ | |
| 253 | + file_tree_name(g.argv[i], &fname, 1); | |
| 254 | + } | |
| 243 | 255 | blob_zero(&content); |
| 244 | 256 | rc = historical_version_of_file(zRev, blob_str(&fname), &content, 0,0,0,0); |
| 245 | 257 | if( rc==0 ){ |
| 246 | 258 | fossil_fatal("no such file: %s", g.argv[i]); |
| 247 | 259 | } |
| 248 | 260 |
| --- src/finfo.c | |
| +++ src/finfo.c | |
| @@ -237,11 +237,23 @@ | |
| 237 | Blob content, fname; |
| 238 | const char *zRev; |
| 239 | db_find_and_open_repository(0, 0); |
| 240 | zRev = find_option("r","r",1); |
| 241 | for(i=2; i<g.argc; i++){ |
| 242 | file_tree_name(g.argv[i], &fname, 1); |
| 243 | blob_zero(&content); |
| 244 | rc = historical_version_of_file(zRev, blob_str(&fname), &content, 0,0,0,0); |
| 245 | if( rc==0 ){ |
| 246 | fossil_fatal("no such file: %s", g.argv[i]); |
| 247 | } |
| 248 |
| --- src/finfo.c | |
| +++ src/finfo.c | |
| @@ -237,11 +237,23 @@ | |
| 237 | Blob content, fname; |
| 238 | const char *zRev; |
| 239 | db_find_and_open_repository(0, 0); |
| 240 | zRev = find_option("r","r",1); |
| 241 | for(i=2; i<g.argc; i++){ |
| 242 | if( g.useRepositoryFromCmdArg ){ |
| 243 | /* If specify -R <repository>, arguments should already be the tree-name */ |
| 244 | blob_set(&fname, g.argv[i]); |
| 245 | /* |
| 246 | ** if no rev specified, default to main-branch to don't let |
| 247 | ** historical_version_of_file() get local checkout revision |
| 248 | */ |
| 249 | if( zRev==0 ){ |
| 250 | zRev=db_get("main-branch", "trunk"); |
| 251 | } |
| 252 | }else{ |
| 253 | file_tree_name(g.argv[i], &fname, 1); |
| 254 | } |
| 255 | blob_zero(&content); |
| 256 | rc = historical_version_of_file(zRev, blob_str(&fname), &content, 0,0,0,0); |
| 257 | if( rc==0 ){ |
| 258 | fossil_fatal("no such file: %s", g.argv[i]); |
| 259 | } |
| 260 |
+1
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -171,10 +171,11 @@ | ||
| 171 | 171 | int clockSkewSeen; /* True if clocks on client and server out of sync */ |
| 172 | 172 | int wikiFlags; /* Wiki conversion flags applied to %w and %W */ |
| 173 | 173 | char isHTTP; /* True if server/CGI modes, else assume CLI. */ |
| 174 | 174 | char javascriptHyperlink; /* If true, set href= using script, not HTML */ |
| 175 | 175 | Blob httpHeader; /* Complete text of the HTTP request header */ |
| 176 | + int useRepositoryFromCmdArg; /* -R <repository> specified on command line */ | |
| 176 | 177 | |
| 177 | 178 | /* |
| 178 | 179 | ** NOTE: These members MUST be kept in sync with those in the "UrlData" |
| 179 | 180 | ** structure defined in "url.c". |
| 180 | 181 | */ |
| 181 | 182 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -171,10 +171,11 @@ | |
| 171 | int clockSkewSeen; /* True if clocks on client and server out of sync */ |
| 172 | int wikiFlags; /* Wiki conversion flags applied to %w and %W */ |
| 173 | char isHTTP; /* True if server/CGI modes, else assume CLI. */ |
| 174 | char javascriptHyperlink; /* If true, set href= using script, not HTML */ |
| 175 | Blob httpHeader; /* Complete text of the HTTP request header */ |
| 176 | |
| 177 | /* |
| 178 | ** NOTE: These members MUST be kept in sync with those in the "UrlData" |
| 179 | ** structure defined in "url.c". |
| 180 | */ |
| 181 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -171,10 +171,11 @@ | |
| 171 | int clockSkewSeen; /* True if clocks on client and server out of sync */ |
| 172 | int wikiFlags; /* Wiki conversion flags applied to %w and %W */ |
| 173 | char isHTTP; /* True if server/CGI modes, else assume CLI. */ |
| 174 | char javascriptHyperlink; /* If true, set href= using script, not HTML */ |
| 175 | Blob httpHeader; /* Complete text of the HTTP request header */ |
| 176 | int useRepositoryFromCmdArg; /* -R <repository> specified on command line */ |
| 177 | |
| 178 | /* |
| 179 | ** NOTE: These members MUST be kept in sync with those in the "UrlData" |
| 180 | ** structure defined in "url.c". |
| 181 | */ |
| 182 |