Fossil SCM
json mode now accepts command=string request parameter if path length is 1 (no subcommand was specified).
Commit
225fd3dad33e7a945d0ade473ab39cc5110c77b7
Parent
8145cdbf3b167ef…
1 file changed
+14
-1
+14
-1
| --- src/json.c | ||
| +++ src/json.c | ||
| @@ -981,10 +981,23 @@ | ||
| 981 | 981 | |
| 982 | 982 | /* Anything which needs json_getenv() and friends should go after |
| 983 | 983 | this point. |
| 984 | 984 | */ |
| 985 | 985 | |
| 986 | + if(1 == cson_array_length_get(g.json.cmd.a)){ | |
| 987 | + /* special case: if we're at the top path, look for | |
| 988 | + a "command" request arg which specifies which command | |
| 989 | + to run. | |
| 990 | + */ | |
| 991 | + char const * cmd = json_getenv_cstr("command"); | |
| 992 | + if(cmd){ | |
| 993 | + json_string_split(cmd, '/', 0, g.json.cmd.a); | |
| 994 | + } | |
| 995 | + } | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 986 | 999 | if(!g.json.jsonp && g.json.post.o){ |
| 987 | 1000 | g.json.jsonp = |
| 988 | 1001 | json_getenv_cstr("jsonp") |
| 989 | 1002 | /*cson_string_cstr(cson_value_get_string(cson_object_get(g.json.post.o,"jsonp")))*/ |
| 990 | 1003 | ; |
| @@ -1989,11 +2002,11 @@ | ||
| 1989 | 2002 | handling. |
| 1990 | 2003 | */ |
| 1991 | 2004 | ; |
| 1992 | 2005 | json_main_bootstrap(); |
| 1993 | 2006 | json_mode_bootstrap(); |
| 1994 | - if( g.argc<3 ){ | |
| 2007 | + if( 2 > cson_array_length_get(g.json.cmd.a) ){ | |
| 1995 | 2008 | goto usage; |
| 1996 | 2009 | } |
| 1997 | 2010 | db_find_and_open_repository(0, 0); |
| 1998 | 2011 | #if 0 |
| 1999 | 2012 | json_warn(FSL_JSON_W_ROW_TO_JSON_FAILED, "Just testing."); |
| 2000 | 2013 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -981,10 +981,23 @@ | |
| 981 | |
| 982 | /* Anything which needs json_getenv() and friends should go after |
| 983 | this point. |
| 984 | */ |
| 985 | |
| 986 | if(!g.json.jsonp && g.json.post.o){ |
| 987 | g.json.jsonp = |
| 988 | json_getenv_cstr("jsonp") |
| 989 | /*cson_string_cstr(cson_value_get_string(cson_object_get(g.json.post.o,"jsonp")))*/ |
| 990 | ; |
| @@ -1989,11 +2002,11 @@ | |
| 1989 | handling. |
| 1990 | */ |
| 1991 | ; |
| 1992 | json_main_bootstrap(); |
| 1993 | json_mode_bootstrap(); |
| 1994 | if( g.argc<3 ){ |
| 1995 | goto usage; |
| 1996 | } |
| 1997 | db_find_and_open_repository(0, 0); |
| 1998 | #if 0 |
| 1999 | json_warn(FSL_JSON_W_ROW_TO_JSON_FAILED, "Just testing."); |
| 2000 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -981,10 +981,23 @@ | |
| 981 | |
| 982 | /* Anything which needs json_getenv() and friends should go after |
| 983 | this point. |
| 984 | */ |
| 985 | |
| 986 | if(1 == cson_array_length_get(g.json.cmd.a)){ |
| 987 | /* special case: if we're at the top path, look for |
| 988 | a "command" request arg which specifies which command |
| 989 | to run. |
| 990 | */ |
| 991 | char const * cmd = json_getenv_cstr("command"); |
| 992 | if(cmd){ |
| 993 | json_string_split(cmd, '/', 0, g.json.cmd.a); |
| 994 | } |
| 995 | } |
| 996 | |
| 997 | |
| 998 | |
| 999 | if(!g.json.jsonp && g.json.post.o){ |
| 1000 | g.json.jsonp = |
| 1001 | json_getenv_cstr("jsonp") |
| 1002 | /*cson_string_cstr(cson_value_get_string(cson_object_get(g.json.post.o,"jsonp")))*/ |
| 1003 | ; |
| @@ -1989,11 +2002,11 @@ | |
| 2002 | handling. |
| 2003 | */ |
| 2004 | ; |
| 2005 | json_main_bootstrap(); |
| 2006 | json_mode_bootstrap(); |
| 2007 | if( 2 > cson_array_length_get(g.json.cmd.a) ){ |
| 2008 | goto usage; |
| 2009 | } |
| 2010 | db_find_and_open_repository(0, 0); |
| 2011 | #if 0 |
| 2012 | json_warn(FSL_JSON_W_ROW_TO_JSON_FAILED, "Just testing."); |
| 2013 |