Fossil SCM
added current branch name to /json/branch/list payload when in an opened checkout.
Commit
7592fe934be48540dd6e7d6ea35d0a0c5c21eda1
Parent
4a9b51649d6499d…
1 file changed
+22
+22
| --- src/json.c | ||
| +++ src/json.c | ||
| @@ -275,10 +275,18 @@ | ||
| 275 | 275 | */ |
| 276 | 276 | cson_value * json_rc_string( int code ){ |
| 277 | 277 | return cson_value_new_string( json_rc_cstr(code), 11 ); |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | +/* | |
| 281 | +** Convenience wrapper around cson_value_new_string(). | |
| 282 | +*/ | |
| 283 | +cson_value * json_new_string( char const * str ){ | |
| 284 | + return str | |
| 285 | + ? cson_value_new_string(str,strlen(str)) | |
| 286 | + : NULL; | |
| 287 | +} | |
| 280 | 288 | |
| 281 | 289 | /* |
| 282 | 290 | ** Gets a POST/POST.payload/GET/COOKIE/ENV value. The returned memory |
| 283 | 291 | ** is owned by the g.json object (one of its sub-objects). Returns |
| 284 | 292 | ** NULL if no match is found. |
| @@ -1630,10 +1638,24 @@ | ||
| 1630 | 1638 | range = "open"; |
| 1631 | 1639 | which = 0; |
| 1632 | 1640 | break; |
| 1633 | 1641 | }; |
| 1634 | 1642 | cson_object_set(pay,"range",cson_value_new_string(range,strlen(range))); |
| 1643 | + | |
| 1644 | + if( g.localOpen ){ | |
| 1645 | + int vid = db_lget_int("checkout", 0); | |
| 1646 | + char const * zCurrent = vid | |
| 1647 | + ? db_text(0, "SELECT value FROM tagxref" | |
| 1648 | + " WHERE rid=%d AND tagid=%d", | |
| 1649 | + vid, TAG_BRANCH) | |
| 1650 | + : 0; | |
| 1651 | + if(zCurrent){ | |
| 1652 | + cson_object_set(pay,"current",json_new_string(zCurrent)); | |
| 1653 | + } | |
| 1654 | + } | |
| 1655 | + | |
| 1656 | + | |
| 1635 | 1657 | branch_prepare_list_query(&q, which); |
| 1636 | 1658 | cson_object_set(pay,"branches",listV); |
| 1637 | 1659 | while((SQLITE_ROW==db_step(&q))){ |
| 1638 | 1660 | cson_value * v = cson_sqlite3_column_to_value(q.pStmt,0); |
| 1639 | 1661 | if(v){ |
| 1640 | 1662 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -275,10 +275,18 @@ | |
| 275 | */ |
| 276 | cson_value * json_rc_string( int code ){ |
| 277 | return cson_value_new_string( json_rc_cstr(code), 11 ); |
| 278 | } |
| 279 | |
| 280 | |
| 281 | /* |
| 282 | ** Gets a POST/POST.payload/GET/COOKIE/ENV value. The returned memory |
| 283 | ** is owned by the g.json object (one of its sub-objects). Returns |
| 284 | ** NULL if no match is found. |
| @@ -1630,10 +1638,24 @@ | |
| 1630 | range = "open"; |
| 1631 | which = 0; |
| 1632 | break; |
| 1633 | }; |
| 1634 | cson_object_set(pay,"range",cson_value_new_string(range,strlen(range))); |
| 1635 | branch_prepare_list_query(&q, which); |
| 1636 | cson_object_set(pay,"branches",listV); |
| 1637 | while((SQLITE_ROW==db_step(&q))){ |
| 1638 | cson_value * v = cson_sqlite3_column_to_value(q.pStmt,0); |
| 1639 | if(v){ |
| 1640 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -275,10 +275,18 @@ | |
| 275 | */ |
| 276 | cson_value * json_rc_string( int code ){ |
| 277 | return cson_value_new_string( json_rc_cstr(code), 11 ); |
| 278 | } |
| 279 | |
| 280 | /* |
| 281 | ** Convenience wrapper around cson_value_new_string(). |
| 282 | */ |
| 283 | cson_value * json_new_string( char const * str ){ |
| 284 | return str |
| 285 | ? cson_value_new_string(str,strlen(str)) |
| 286 | : NULL; |
| 287 | } |
| 288 | |
| 289 | /* |
| 290 | ** Gets a POST/POST.payload/GET/COOKIE/ENV value. The returned memory |
| 291 | ** is owned by the g.json object (one of its sub-objects). Returns |
| 292 | ** NULL if no match is found. |
| @@ -1630,10 +1638,24 @@ | |
| 1638 | range = "open"; |
| 1639 | which = 0; |
| 1640 | break; |
| 1641 | }; |
| 1642 | cson_object_set(pay,"range",cson_value_new_string(range,strlen(range))); |
| 1643 | |
| 1644 | if( g.localOpen ){ |
| 1645 | int vid = db_lget_int("checkout", 0); |
| 1646 | char const * zCurrent = vid |
| 1647 | ? db_text(0, "SELECT value FROM tagxref" |
| 1648 | " WHERE rid=%d AND tagid=%d", |
| 1649 | vid, TAG_BRANCH) |
| 1650 | : 0; |
| 1651 | if(zCurrent){ |
| 1652 | cson_object_set(pay,"current",json_new_string(zCurrent)); |
| 1653 | } |
| 1654 | } |
| 1655 | |
| 1656 | |
| 1657 | branch_prepare_list_query(&q, which); |
| 1658 | cson_object_set(pay,"branches",listV); |
| 1659 | while((SQLITE_ROW==db_step(&q))){ |
| 1660 | cson_value * v = cson_sqlite3_column_to_value(q.pStmt,0); |
| 1661 | if(v){ |
| 1662 |