X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=cli.c;h=1a478bb05eae953de0f4284f6bc78f586b23ef3e;hp=828c7b931593dba7d92ea982db6eec4d356062c6;hb=4b1ddfb8358bcd57560406db26d7041c9c0cb90b;hpb=d0470b6f42a7eeba079adeee21ad96170de67f34;ds=sidebyside diff --git a/cli.c b/cli.c index 828c7b9..1a478bb 100644 --- a/cli.c +++ b/cli.c @@ -91,7 +91,7 @@ static int package_cmd(int cmd, char *package) } switch(cmd) { case CMD_COMMIT: - if (uci_commit(ctx, &p) != UCI_OK) + if (uci_commit(ctx, &p, false) != UCI_OK) uci_perror(ctx, appname); break; case CMD_EXPORT: @@ -128,8 +128,17 @@ static int uci_do_import(int argc, char **argv) package = NULL; } ret = uci_import(ctx, input, name, &package, (name != NULL)); - if ((ret == UCI_OK) && (flags & CLI_FLAG_MERGE)) { - ret = uci_save(ctx, package); + if (ret == UCI_OK) { + if (flags & CLI_FLAG_MERGE) { + ret = uci_save(ctx, package); + } else { + struct uci_element *e; + /* loop through all config sections and overwrite existing data */ + uci_foreach_element(&ctx->root, e) { + struct uci_package *p = uci_to_package(e); + ret = uci_commit(ctx, &p, true); + } + } } if (ret != UCI_OK) {