Fossil SCM
fixed a bug in the handling of /json/tag/find --raw format (caused by moving code w/o paying attention). Added a warning when the given tag is not found.
Commit
be41009046fb078d5cd8e6da2e4b6784d35b2ddd
Parent
9d27ade314cabed…
2 files changed
+1
+6
-13
+1
| --- src/json_detail.h | ||
| +++ src/json_detail.h | ||
| @@ -40,10 +40,11 @@ | ||
| 40 | 40 | FSL_JSON_W_START = 0, |
| 41 | 41 | FSL_JSON_W_UNKNOWN /*+1*/, |
| 42 | 42 | FSL_JSON_W_ROW_TO_JSON_FAILED /*+2*/, |
| 43 | 43 | FSL_JSON_W_COL_TO_JSON_FAILED /*+3*/, |
| 44 | 44 | FSL_JSON_W_STRING_TO_ARRAY_FAILED /*+4*/, |
| 45 | +FSL_JSON_W_TAG_NOT_FOUND /*+5*/, | |
| 45 | 46 | |
| 46 | 47 | FSL_JSON_W_END = 1000, |
| 47 | 48 | FSL_JSON_E_GENERIC = 1000, |
| 48 | 49 | FSL_JSON_E_GENERIC_SUB1 = FSL_JSON_E_GENERIC + 100, |
| 49 | 50 | FSL_JSON_E_INVALID_REQUEST /*+1*/, |
| 50 | 51 |
| --- src/json_detail.h | |
| +++ src/json_detail.h | |
| @@ -40,10 +40,11 @@ | |
| 40 | FSL_JSON_W_START = 0, |
| 41 | FSL_JSON_W_UNKNOWN /*+1*/, |
| 42 | FSL_JSON_W_ROW_TO_JSON_FAILED /*+2*/, |
| 43 | FSL_JSON_W_COL_TO_JSON_FAILED /*+3*/, |
| 44 | FSL_JSON_W_STRING_TO_ARRAY_FAILED /*+4*/, |
| 45 | |
| 46 | FSL_JSON_W_END = 1000, |
| 47 | FSL_JSON_E_GENERIC = 1000, |
| 48 | FSL_JSON_E_GENERIC_SUB1 = FSL_JSON_E_GENERIC + 100, |
| 49 | FSL_JSON_E_INVALID_REQUEST /*+1*/, |
| 50 |
| --- src/json_detail.h | |
| +++ src/json_detail.h | |
| @@ -40,10 +40,11 @@ | |
| 40 | FSL_JSON_W_START = 0, |
| 41 | FSL_JSON_W_UNKNOWN /*+1*/, |
| 42 | FSL_JSON_W_ROW_TO_JSON_FAILED /*+2*/, |
| 43 | FSL_JSON_W_COL_TO_JSON_FAILED /*+3*/, |
| 44 | FSL_JSON_W_STRING_TO_ARRAY_FAILED /*+4*/, |
| 45 | FSL_JSON_W_TAG_NOT_FOUND /*+5*/, |
| 46 | |
| 47 | FSL_JSON_W_END = 1000, |
| 48 | FSL_JSON_E_GENERIC = 1000, |
| 49 | FSL_JSON_E_GENERIC_SUB1 = FSL_JSON_E_GENERIC + 100, |
| 50 | FSL_JSON_E_INVALID_REQUEST /*+1*/, |
| 51 |
+6
-13
| --- src/json_tag.c | ||
| +++ src/json_tag.c | ||
| @@ -216,25 +216,17 @@ | ||
| 216 | 216 | zType = json_find_option_cstr("type",NULL,"t"); |
| 217 | 217 | if(!zType || !*zType){ |
| 218 | 218 | zType = "*"; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'", | |
| 222 | - zName); | |
| 223 | -#if 0 | |
| 224 | - /* It is arguable to return an error in this case. We could | |
| 225 | - alternatively simply return an empty set. | |
| 226 | - */ | |
| 227 | - if( tagid<=0 ){ | |
| 228 | - json_set_err(FSL_JSON_E_RESOURCE_NOT_FOUND, | |
| 229 | - "Could not find tag ID for tag '%s'.", zName); | |
| 230 | - return NULL; | |
| 231 | - } | |
| 232 | -#endif | |
| 233 | - | |
| 234 | 221 | limit = json_find_option_int("limit",NULL,"n",0); |
| 235 | 222 | fRaw = json_find_option_bool("raw",NULL,NULL,0); |
| 223 | + | |
| 224 | + tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='%s' || %Q", | |
| 225 | + fRaw ? "" : "sym-", | |
| 226 | + zName); | |
| 227 | + | |
| 236 | 228 | payV = cson_value_new_object(); |
| 237 | 229 | pay = cson_value_get_object(payV); |
| 238 | 230 | cson_object_set(pay, "name", json_new_string(zName)); |
| 239 | 231 | cson_object_set(pay, "raw", cson_value_new_bool(fRaw)); |
| 240 | 232 | cson_object_set(pay, "type", json_new_string(zType)); |
| @@ -241,10 +233,11 @@ | ||
| 241 | 233 | cson_object_set(pay, "limit", json_new_int(limit)); |
| 242 | 234 | |
| 243 | 235 | #if 1 |
| 244 | 236 | if( tagid<=0 ){ |
| 245 | 237 | cson_object_set(pay,"artifacts", cson_value_null()); |
| 238 | + json_warn(FSL_JSON_W_TAG_NOT_FOUND, "Tag not found."); | |
| 246 | 239 | return payV; |
| 247 | 240 | } |
| 248 | 241 | #endif |
| 249 | 242 | |
| 250 | 243 | if( fRaw ){ |
| 251 | 244 |
| --- src/json_tag.c | |
| +++ src/json_tag.c | |
| @@ -216,25 +216,17 @@ | |
| 216 | zType = json_find_option_cstr("type",NULL,"t"); |
| 217 | if(!zType || !*zType){ |
| 218 | zType = "*"; |
| 219 | } |
| 220 | |
| 221 | tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'", |
| 222 | zName); |
| 223 | #if 0 |
| 224 | /* It is arguable to return an error in this case. We could |
| 225 | alternatively simply return an empty set. |
| 226 | */ |
| 227 | if( tagid<=0 ){ |
| 228 | json_set_err(FSL_JSON_E_RESOURCE_NOT_FOUND, |
| 229 | "Could not find tag ID for tag '%s'.", zName); |
| 230 | return NULL; |
| 231 | } |
| 232 | #endif |
| 233 | |
| 234 | limit = json_find_option_int("limit",NULL,"n",0); |
| 235 | fRaw = json_find_option_bool("raw",NULL,NULL,0); |
| 236 | payV = cson_value_new_object(); |
| 237 | pay = cson_value_get_object(payV); |
| 238 | cson_object_set(pay, "name", json_new_string(zName)); |
| 239 | cson_object_set(pay, "raw", cson_value_new_bool(fRaw)); |
| 240 | cson_object_set(pay, "type", json_new_string(zType)); |
| @@ -241,10 +233,11 @@ | |
| 241 | cson_object_set(pay, "limit", json_new_int(limit)); |
| 242 | |
| 243 | #if 1 |
| 244 | if( tagid<=0 ){ |
| 245 | cson_object_set(pay,"artifacts", cson_value_null()); |
| 246 | return payV; |
| 247 | } |
| 248 | #endif |
| 249 | |
| 250 | if( fRaw ){ |
| 251 |
| --- src/json_tag.c | |
| +++ src/json_tag.c | |
| @@ -216,25 +216,17 @@ | |
| 216 | zType = json_find_option_cstr("type",NULL,"t"); |
| 217 | if(!zType || !*zType){ |
| 218 | zType = "*"; |
| 219 | } |
| 220 | |
| 221 | limit = json_find_option_int("limit",NULL,"n",0); |
| 222 | fRaw = json_find_option_bool("raw",NULL,NULL,0); |
| 223 | |
| 224 | tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='%s' || %Q", |
| 225 | fRaw ? "" : "sym-", |
| 226 | zName); |
| 227 | |
| 228 | payV = cson_value_new_object(); |
| 229 | pay = cson_value_get_object(payV); |
| 230 | cson_object_set(pay, "name", json_new_string(zName)); |
| 231 | cson_object_set(pay, "raw", cson_value_new_bool(fRaw)); |
| 232 | cson_object_set(pay, "type", json_new_string(zType)); |
| @@ -241,10 +233,11 @@ | |
| 233 | cson_object_set(pay, "limit", json_new_int(limit)); |
| 234 | |
| 235 | #if 1 |
| 236 | if( tagid<=0 ){ |
| 237 | cson_object_set(pay,"artifacts", cson_value_null()); |
| 238 | json_warn(FSL_JSON_W_TAG_NOT_FOUND, "Tag not found."); |
| 239 | return payV; |
| 240 | } |
| 241 | #endif |
| 242 | |
| 243 | if( fRaw ){ |
| 244 |