Fossil SCM

Fix the unversioned_content_hash() function so that it returns the SHA1 of a zero-length buffer if the "unversioned" table does not exist.

drh 2021-07-07 18:14 trunk
Commit ccce70fb59a636ab7576863032bf45ef69a1842529de55386af1fdffbfeb91e0
1 file changed +4 -1
--- src/unversioned.c
+++ src/unversioned.c
@@ -62,11 +62,14 @@
6262
** If debugFlag is set, force the value to be recomputed and write
6363
** the text of the hashed string to stdout.
6464
*/
6565
const char *unversioned_content_hash(int debugFlag){
6666
const char *zHash = debugFlag ? 0 : db_get("uv-hash", 0);
67
- if( zHash==0 ){
67
+ if( zHash ) return zHash;
68
+ if( !db_table_exists("repository","unversioned") ){
69
+ return "da39a3ee5e6b4b0d3255bfef95601890afd80709";
70
+ }else{
6871
Stmt q;
6972
db_prepare(&q,
7073
"SELECT printf('%%s %%s %%s\n',name,datetime(mtime,'unixepoch'),hash)"
7174
" FROM unversioned"
7275
" WHERE hash IS NOT NULL"
7376
--- src/unversioned.c
+++ src/unversioned.c
@@ -62,11 +62,14 @@
62 ** If debugFlag is set, force the value to be recomputed and write
63 ** the text of the hashed string to stdout.
64 */
65 const char *unversioned_content_hash(int debugFlag){
66 const char *zHash = debugFlag ? 0 : db_get("uv-hash", 0);
67 if( zHash==0 ){
 
 
 
68 Stmt q;
69 db_prepare(&q,
70 "SELECT printf('%%s %%s %%s\n',name,datetime(mtime,'unixepoch'),hash)"
71 " FROM unversioned"
72 " WHERE hash IS NOT NULL"
73
--- src/unversioned.c
+++ src/unversioned.c
@@ -62,11 +62,14 @@
62 ** If debugFlag is set, force the value to be recomputed and write
63 ** the text of the hashed string to stdout.
64 */
65 const char *unversioned_content_hash(int debugFlag){
66 const char *zHash = debugFlag ? 0 : db_get("uv-hash", 0);
67 if( zHash ) return zHash;
68 if( !db_table_exists("repository","unversioned") ){
69 return "da39a3ee5e6b4b0d3255bfef95601890afd80709";
70 }else{
71 Stmt q;
72 db_prepare(&q,
73 "SELECT printf('%%s %%s %%s\n',name,datetime(mtime,'unixepoch'),hash)"
74 " FROM unversioned"
75 " WHERE hash IS NOT NULL"
76

Keyboard Shortcuts

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