Fossil SCM
Show the correct hash algorithm name in the Overview section of the /info webpage.
Commit
92fb97609a0788badbe4a66d165e05c177322dfb
Parent
fc3995a01bdf108…
2 files changed
+10
+2
-1
+10
| --- src/hname.c | ||
| +++ src/hname.c | ||
| @@ -48,10 +48,20 @@ | ||
| 48 | 48 | ** The number of distinct hash algorithms: |
| 49 | 49 | */ |
| 50 | 50 | #define HNAME_COUNT 2 /* Just SHA1 and SHA3-256. Let's keep it that way! */ |
| 51 | 51 | |
| 52 | 52 | #endif /* INTERFACE */ |
| 53 | + | |
| 54 | +/* | |
| 55 | +** Return a human-readable name for the hash algorithm given a hash with | |
| 56 | +** a length of nHash hexadecimal digits. | |
| 57 | +*/ | |
| 58 | +const char *hname_alg(int nHash){ | |
| 59 | + if( nHash==HNAME_LEN_SHA1 ) return "SHA1"; | |
| 60 | + if( nHash==HNAME_LEN_K256 ) return "SHA3-256"; | |
| 61 | + return "?"; | |
| 62 | +} | |
| 53 | 63 | |
| 54 | 64 | /* |
| 55 | 65 | ** Return the integer hash algorithm code number (ex: HNAME_K224) for |
| 56 | 66 | ** the hash string provided. Or return HNAME_ERROR (0) if the input string |
| 57 | 67 | ** is not a valid artifact hash string. |
| 58 | 68 |
| --- src/hname.c | |
| +++ src/hname.c | |
| @@ -48,10 +48,20 @@ | |
| 48 | ** The number of distinct hash algorithms: |
| 49 | */ |
| 50 | #define HNAME_COUNT 2 /* Just SHA1 and SHA3-256. Let's keep it that way! */ |
| 51 | |
| 52 | #endif /* INTERFACE */ |
| 53 | |
| 54 | /* |
| 55 | ** Return the integer hash algorithm code number (ex: HNAME_K224) for |
| 56 | ** the hash string provided. Or return HNAME_ERROR (0) if the input string |
| 57 | ** is not a valid artifact hash string. |
| 58 |
| --- src/hname.c | |
| +++ src/hname.c | |
| @@ -48,10 +48,20 @@ | |
| 48 | ** The number of distinct hash algorithms: |
| 49 | */ |
| 50 | #define HNAME_COUNT 2 /* Just SHA1 and SHA3-256. Let's keep it that way! */ |
| 51 | |
| 52 | #endif /* INTERFACE */ |
| 53 | |
| 54 | /* |
| 55 | ** Return a human-readable name for the hash algorithm given a hash with |
| 56 | ** a length of nHash hexadecimal digits. |
| 57 | */ |
| 58 | const char *hname_alg(int nHash){ |
| 59 | if( nHash==HNAME_LEN_SHA1 ) return "SHA1"; |
| 60 | if( nHash==HNAME_LEN_K256 ) return "SHA3-256"; |
| 61 | return "?"; |
| 62 | } |
| 63 | |
| 64 | /* |
| 65 | ** Return the integer hash algorithm code number (ex: HNAME_K224) for |
| 66 | ** the hash string provided. Or return HNAME_ERROR (0) if the input string |
| 67 | ** is not a valid artifact hash string. |
| 68 |
+2
-1
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -572,10 +572,11 @@ | ||
| 572 | 572 | rid, rid |
| 573 | 573 | ); |
| 574 | 574 | sideBySide = !is_false(PD("sbs","1")); |
| 575 | 575 | if( db_step(&q1)==SQLITE_ROW ){ |
| 576 | 576 | const char *zUuid = db_column_text(&q1, 0); |
| 577 | + int nUuid = db_column_bytes(&q1, 0); | |
| 577 | 578 | char *zEUser, *zEComment; |
| 578 | 579 | const char *zUser; |
| 579 | 580 | const char *zComment; |
| 580 | 581 | const char *zDate; |
| 581 | 582 | const char *zOrigDate; |
| @@ -593,11 +594,11 @@ | ||
| 593 | 594 | zComment = db_column_text(&q1, 3); |
| 594 | 595 | zDate = db_column_text(&q1,1); |
| 595 | 596 | zOrigDate = db_column_text(&q1, 4); |
| 596 | 597 | @ <div class="section">Overview</div> |
| 597 | 598 | @ <table class="label-value"> |
| 598 | - @ <tr><th>SHA1 Hash:</th><td>%s(zUuid) | |
| 599 | + @ <tr><th>%s(hname_alg(nUuid)):</th><td>%s(zUuid) | |
| 599 | 600 | if( g.perm.Setup ){ |
| 600 | 601 | @ (Record ID: %d(rid)) |
| 601 | 602 | } |
| 602 | 603 | @ </td></tr> |
| 603 | 604 | @ <tr><th>Date:</th><td> |
| 604 | 605 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -572,10 +572,11 @@ | |
| 572 | rid, rid |
| 573 | ); |
| 574 | sideBySide = !is_false(PD("sbs","1")); |
| 575 | if( db_step(&q1)==SQLITE_ROW ){ |
| 576 | const char *zUuid = db_column_text(&q1, 0); |
| 577 | char *zEUser, *zEComment; |
| 578 | const char *zUser; |
| 579 | const char *zComment; |
| 580 | const char *zDate; |
| 581 | const char *zOrigDate; |
| @@ -593,11 +594,11 @@ | |
| 593 | zComment = db_column_text(&q1, 3); |
| 594 | zDate = db_column_text(&q1,1); |
| 595 | zOrigDate = db_column_text(&q1, 4); |
| 596 | @ <div class="section">Overview</div> |
| 597 | @ <table class="label-value"> |
| 598 | @ <tr><th>SHA1 Hash:</th><td>%s(zUuid) |
| 599 | if( g.perm.Setup ){ |
| 600 | @ (Record ID: %d(rid)) |
| 601 | } |
| 602 | @ </td></tr> |
| 603 | @ <tr><th>Date:</th><td> |
| 604 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -572,10 +572,11 @@ | |
| 572 | rid, rid |
| 573 | ); |
| 574 | sideBySide = !is_false(PD("sbs","1")); |
| 575 | if( db_step(&q1)==SQLITE_ROW ){ |
| 576 | const char *zUuid = db_column_text(&q1, 0); |
| 577 | int nUuid = db_column_bytes(&q1, 0); |
| 578 | char *zEUser, *zEComment; |
| 579 | const char *zUser; |
| 580 | const char *zComment; |
| 581 | const char *zDate; |
| 582 | const char *zOrigDate; |
| @@ -593,11 +594,11 @@ | |
| 594 | zComment = db_column_text(&q1, 3); |
| 595 | zDate = db_column_text(&q1,1); |
| 596 | zOrigDate = db_column_text(&q1, 4); |
| 597 | @ <div class="section">Overview</div> |
| 598 | @ <table class="label-value"> |
| 599 | @ <tr><th>%s(hname_alg(nUuid)):</th><td>%s(zUuid) |
| 600 | if( g.perm.Setup ){ |
| 601 | @ (Record ID: %d(rid)) |
| 602 | } |
| 603 | @ </td></tr> |
| 604 | @ <tr><th>Date:</th><td> |
| 605 |