diff BUGFIX keep user-ord changes order
Needs to be adjusted when the instance is
already in the diff.
diff --git a/src/diff.c b/src/diff.c
index 16b1f2f..fd72132 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -291,6 +291,7 @@
const struct lyd_node *parent = NULL;
enum lyd_diff_op cur_op;
struct lyd_meta *meta;
+ uint32_t diff_opts;
assert(diff);
@@ -342,6 +343,14 @@
assert(!lyd_diff_get_op(diff_parent, &cur_op) && (cur_op == LYD_DIFF_OP_NONE));
(void)cur_op;
+ /* move it to the end where it is expected (matters for user-ordered lists) */
+ if (lysc_is_userordered(diff_parent->schema)) {
+ for (elem = diff_parent; elem->next && (elem->next->schema == elem->schema); elem = elem->next) {}
+ if (elem != diff_parent) {
+ LY_CHECK_RET(lyd_insert_after(elem, diff_parent));
+ }
+ }
+
/* will be replaced by the new operation but keep the current op for descendants */
lyd_diff_del_meta(diff_parent, "operation");
LY_LIST_FOR(lyd_child_no_keys(diff_parent), elem) {