Index: src/doc.c =================================================================== --- src/doc.c +++ src/doc.c @@ -315,12 +315,13 @@ ** URL: /doc?name=BASELINE/PATH ** URL: /doc/BASELINE/PATH ** ** BASELINE can be either a baseline uuid prefix or magic words "tip" ** to me the most recently checked in baseline or "ckout" to mean the -** content of the local checkout, if any. PATH is the relative pathname -** of some file. This method returns the file content. +** content of the local checkout, if any. "idx" is the same as "ckout" +** but shows only files already added with "fossil add". PATH is the +** relative pathname of some file. This method returns the file content. ** ** If PATH matches the patterns *.wiki or *.txt then formatting content ** is added before returning the file. For all other names, the content ** is returned straight without any interpretation or processing. */ @@ -330,10 +331,11 @@ int vid = 0; /* Artifact of baseline */ int rid = 0; /* Artifact of file */ int i; /* Loop counter */ Blob filebody; /* Content of the documentation file */ char zBaseline[UUID_SIZE+1]; /* Baseline UUID */ + char * reason = "document not present in the repository"; login_check_credentials(); if( !g.okRead ){ login_needed(); return; } zName = PD("name", "tip/index.wiki"); for(i=0; zName[i] && zName[i]!='/'; i++){} @@ -343,24 +345,37 @@ memcpy(zBaseline, zName, i); zBaseline[i] = 0; zName += i; while( zName[0]=='/' ){ zName++; } if( !file_is_simple_pathname(zName) ){ + reason = "filename contains illegal characters"; goto doc_not_found; } - if( strcmp(zBaseline,"ckout")==0 && db_open_local()==0 ){ + if( ( strcmp(zBaseline,"ckout")==0 || strcmp(zBaseline,"idx")==0 ) && db_open_local()==0 ){ strcpy(zBaseline,"tip"); } - if( strcmp(zBaseline,"ckout")==0 ){ + if( strcmp(zBaseline,"ckout")==0 || strcmp(zBaseline,"idx")==0 ){ /* Read from the local checkout */ char *zFullpath; db_must_be_within_tree(); zFullpath = mprintf("%s/%s", g.zLocalRoot, zName); + if( strcmp(zBaseline,"idx")==0 && ! db_exists( + "SELECT 1 FROM vfile" " WHERE pathname=%Q AND deleted=0 " +#ifdef __MINGW32__ + "COLLATE nocase" +#endif + , zName) ) { + reason = "file not added to the repository"; + goto doc_not_found; + } + if( !file_isfile(zFullpath) ){ + reason = "file not found"; goto doc_not_found; } if( blob_read_from_file(&filebody, zFullpath)<0 ){ + reason = "cannot read file"; goto doc_not_found; } }else{ db_begin_transaction(); if( strcmp(zBaseline,"tip")==0 ){ @@ -464,11 +479,11 @@ doc_not_found: /* Jump here when unable to locate the document */ db_end_transaction(0); style_header("Document Not Found"); - @
No such document: %h(PD("name","tip/index.wiki"))
+ @Error: %h(reason): %h(zName)
style_footer(); return; } /*