Fossil SCM

Minimal implementation to return just the hash of a named artifact via /whatis. See discussion in [forum:4b11cfc8fac93800|forum post 4b11cfc8fac93800] for details.

andybradford 2025-03-22 15:08 trunk
Commit 12ecd0ab38a94d4299a22681ff387c37b5bda4a9140a32ead805dd5d0ff91914
1 file changed +10
+10
--- src/info.c
+++ src/info.c
@@ -2643,10 +2643,11 @@
26432643
** filename=NAME - alternative spelling for "name="
26442644
** fn=NAME - alternative spelling for "name="
26452645
** ci=VERSION - The specific check-in to use with "name=" to
26462646
** identify the file.
26472647
** txt - Force display of unformatted source text
2648
+** hash - Output only the hash of the artifact
26482649
**
26492650
** The /artifact page show the complete content of a file
26502651
** identified by HASH. The /whatis page shows only a description
26512652
** of how the artifact is used. The /file page shows the most recent
26522653
** version of the file or directory called NAME, or a list of the
@@ -2665,18 +2666,20 @@
26652666
void artifact_page(void){
26662667
int rid = 0;
26672668
Blob content;
26682669
const char *zMime;
26692670
Blob downloadName;
2671
+ Blob uuid;
26702672
int renderAsWiki = 0;
26712673
int renderAsHtml = 0;
26722674
int renderAsSvg = 0;
26732675
int objType;
26742676
int asText;
26752677
const char *zUuid = 0;
26762678
u32 objdescFlags = OBJDESC_BASE;
26772679
int descOnly = fossil_strcmp(g.zPath,"whatis")==0;
2680
+ int hashOnly = P("hash")!=0;
26782681
int isFile = fossil_strcmp(g.zPath,"file")==0;
26792682
const char *zLn = P("ln");
26802683
const char *zName = P("name");
26812684
const char *zCI = P("ci");
26822685
HQuery url;
@@ -2791,10 +2794,17 @@
27912794
}
27922795
zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid);
27932796
etag_check(ETAG_HASH, zUuid);
27942797
27952798
asText = P("txt")!=0;
2799
+ if( descOnly && hashOnly ){
2800
+ blob_set(&uuid, zUuid);
2801
+ cgi_set_content_type("text/plain");
2802
+ cgi_set_content(&uuid);
2803
+ return;
2804
+ }
2805
+
27962806
if( isFile ){
27972807
if( zCI==0 || fossil_strcmp(zCI,"tip")==0 ){
27982808
zCI = "tip";
27992809
@ <h2>File %z(href("%R/finfo?name=%T&m&ci=tip",zName))%h(zName)</a>
28002810
@ from the %z(href("%R/info/tip"))latest check-in</a></h2>
28012811
--- src/info.c
+++ src/info.c
@@ -2643,10 +2643,11 @@
2643 ** filename=NAME - alternative spelling for "name="
2644 ** fn=NAME - alternative spelling for "name="
2645 ** ci=VERSION - The specific check-in to use with "name=" to
2646 ** identify the file.
2647 ** txt - Force display of unformatted source text
 
2648 **
2649 ** The /artifact page show the complete content of a file
2650 ** identified by HASH. The /whatis page shows only a description
2651 ** of how the artifact is used. The /file page shows the most recent
2652 ** version of the file or directory called NAME, or a list of the
@@ -2665,18 +2666,20 @@
2665 void artifact_page(void){
2666 int rid = 0;
2667 Blob content;
2668 const char *zMime;
2669 Blob downloadName;
 
2670 int renderAsWiki = 0;
2671 int renderAsHtml = 0;
2672 int renderAsSvg = 0;
2673 int objType;
2674 int asText;
2675 const char *zUuid = 0;
2676 u32 objdescFlags = OBJDESC_BASE;
2677 int descOnly = fossil_strcmp(g.zPath,"whatis")==0;
 
2678 int isFile = fossil_strcmp(g.zPath,"file")==0;
2679 const char *zLn = P("ln");
2680 const char *zName = P("name");
2681 const char *zCI = P("ci");
2682 HQuery url;
@@ -2791,10 +2794,17 @@
2791 }
2792 zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid);
2793 etag_check(ETAG_HASH, zUuid);
2794
2795 asText = P("txt")!=0;
 
 
 
 
 
 
 
2796 if( isFile ){
2797 if( zCI==0 || fossil_strcmp(zCI,"tip")==0 ){
2798 zCI = "tip";
2799 @ <h2>File %z(href("%R/finfo?name=%T&m&ci=tip",zName))%h(zName)</a>
2800 @ from the %z(href("%R/info/tip"))latest check-in</a></h2>
2801
--- src/info.c
+++ src/info.c
@@ -2643,10 +2643,11 @@
2643 ** filename=NAME - alternative spelling for "name="
2644 ** fn=NAME - alternative spelling for "name="
2645 ** ci=VERSION - The specific check-in to use with "name=" to
2646 ** identify the file.
2647 ** txt - Force display of unformatted source text
2648 ** hash - Output only the hash of the artifact
2649 **
2650 ** The /artifact page show the complete content of a file
2651 ** identified by HASH. The /whatis page shows only a description
2652 ** of how the artifact is used. The /file page shows the most recent
2653 ** version of the file or directory called NAME, or a list of the
@@ -2665,18 +2666,20 @@
2666 void artifact_page(void){
2667 int rid = 0;
2668 Blob content;
2669 const char *zMime;
2670 Blob downloadName;
2671 Blob uuid;
2672 int renderAsWiki = 0;
2673 int renderAsHtml = 0;
2674 int renderAsSvg = 0;
2675 int objType;
2676 int asText;
2677 const char *zUuid = 0;
2678 u32 objdescFlags = OBJDESC_BASE;
2679 int descOnly = fossil_strcmp(g.zPath,"whatis")==0;
2680 int hashOnly = P("hash")!=0;
2681 int isFile = fossil_strcmp(g.zPath,"file")==0;
2682 const char *zLn = P("ln");
2683 const char *zName = P("name");
2684 const char *zCI = P("ci");
2685 HQuery url;
@@ -2791,10 +2794,17 @@
2794 }
2795 zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid);
2796 etag_check(ETAG_HASH, zUuid);
2797
2798 asText = P("txt")!=0;
2799 if( descOnly && hashOnly ){
2800 blob_set(&uuid, zUuid);
2801 cgi_set_content_type("text/plain");
2802 cgi_set_content(&uuid);
2803 return;
2804 }
2805
2806 if( isFile ){
2807 if( zCI==0 || fossil_strcmp(zCI,"tip")==0 ){
2808 zCI = "tip";
2809 @ <h2>File %z(href("%R/finfo?name=%T&m&ci=tip",zName))%h(zName)</a>
2810 @ from the %z(href("%R/info/tip"))latest check-in</a></h2>
2811

Keyboard Shortcuts

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