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...)

mgagnon 2014-03-26 21:54 UTC trunk
Commit dc10f8d74cbdb150bd09c0f9fded8ce9a5d90952
+3
--- src/db.c
+++ src/db.c
@@ -1046,10 +1046,13 @@
10461046
**
10471047
** Error out if the repository cannot be opened.
10481048
*/
10491049
void db_find_and_open_repository(int bFlags, int nArgUsed){
10501050
const char *zRep = find_option("repository", "R", 1);
1051
+ if (zRep){
1052
+ g.useRepositoryFromCmdArg = 1;
1053
+ }
10511054
if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){
10521055
zRep = g.argv[nArgUsed];
10531056
}
10541057
if( zRep==0 ){
10551058
if( db_open_local(0)==0 ){
10561059
--- 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 @@
237237
Blob content, fname;
238238
const char *zRev;
239239
db_find_and_open_repository(0, 0);
240240
zRev = find_option("r","r",1);
241241
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
+ }
243255
blob_zero(&content);
244256
rc = historical_version_of_file(zRev, blob_str(&fname), &content, 0,0,0,0);
245257
if( rc==0 ){
246258
fossil_fatal("no such file: %s", g.argv[i]);
247259
}
248260
--- 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 @@
171171
int clockSkewSeen; /* True if clocks on client and server out of sync */
172172
int wikiFlags; /* Wiki conversion flags applied to %w and %W */
173173
char isHTTP; /* True if server/CGI modes, else assume CLI. */
174174
char javascriptHyperlink; /* If true, set href= using script, not HTML */
175175
Blob httpHeader; /* Complete text of the HTTP request header */
176
+ int useRepositoryFromCmdArg; /* -R <repository> specified on command line */
176177
177178
/*
178179
** NOTE: These members MUST be kept in sync with those in the "UrlData"
179180
** structure defined in "url.c".
180181
*/
181182
--- 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

Keyboard Shortcuts

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