diff FEATURE add orig-default meta for all changed leaves

Not only when the default flag changes.
diff --git a/src/diff.c b/src/diff.c
index 3f5f5b4..08d100e 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -299,9 +299,7 @@
      */
 
     /* orig-default */
-    if ((options & LYD_DIFF_DEFAULTS) && (schema->nodetype == LYS_LEAFLIST) &&
-            ((*op == LYD_DIFF_OP_REPLACE) || (*op == LYD_DIFF_OP_NONE)) &&
-            ((first->flags & LYD_DEFAULT) != (second->flags & LYD_DEFAULT))) {
+    if ((schema->nodetype == LYS_LEAFLIST) && ((*op == LYD_DIFF_OP_REPLACE) || (*op == LYD_DIFF_OP_NONE))) {
         if (first->flags & LYD_DEFAULT) {
             *orig_default = "true";
         } else {
@@ -460,9 +458,7 @@
      */
 
     /* orig-default */
-    if ((options & LYD_DIFF_DEFAULTS) && (schema->nodetype & LYD_NODE_TERM) &&
-            ((*op == LYD_DIFF_OP_REPLACE) || (*op == LYD_DIFF_OP_NONE)) &&
-            ((first->flags & LYD_DEFAULT) != (second->flags & LYD_DEFAULT))) {
+    if ((schema->nodetype & LYD_NODE_TERM) && ((*op == LYD_DIFF_OP_REPLACE) || (*op == LYD_DIFF_OP_NONE))) {
         if (first->flags & LYD_DEFAULT) {
             *orig_default = "true";
         } else {
@@ -1233,6 +1229,10 @@
         }
 
         if (diff_match->schema->nodetype & LYD_NODE_TERM) {
+            /* add orig-dflt metadata */
+            LY_CHECK_RET(lyd_new_meta(LYD_CTX(src_diff), diff_match, NULL, "yang:orig-default",
+                    trg_flags & LYD_DEFAULT ? "true" : "false", 0, NULL));
+
             /* update dflt flag itself */
             diff_match->flags &= ~LYD_DEFAULT;
             diff_match->flags |= src_diff->flags & LYD_DEFAULT;
diff --git a/tests/utests/data/test_diff.c b/tests/utests/data/test_diff.c
index f29e80d..f179b54 100644
--- a/tests/utests/data/test_diff.c
+++ b/tests/utests/data/test_diff.c
@@ -434,7 +434,7 @@
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
     assert_string_equal(st->xml,
         "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
-            "<foo yang:operation=\"replace\" yang:orig-value=\"42\">41</foo>"
+            "<foo yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"42\">41</foo>"
             "<b1_1 yang:operation=\"create\">42</b1_1>"
         "</df>"
         "<hidden xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">"
@@ -456,7 +456,7 @@
     lyd_print_mem(&st->xml, st->diff2, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
     assert_string_equal(st->xml,
         "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
-            "<foo yang:operation=\"replace\" yang:orig-value=\"41\">40</foo>"
+            "<foo yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"41\">40</foo>"
             "<b1_1 yang:operation=\"delete\">42</b1_1>"
         "</df>"
         "<hidden xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">"
@@ -478,10 +478,10 @@
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
     assert_string_equal(st->xml,
         "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
-            "<foo yang:operation=\"replace\" yang:orig-value=\"42\">40</foo>"
+            "<foo yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"42\">40</foo>"
         "</df>"
         "<hidden xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
-            "<foo yang:operation=\"replace\" yang:orig-value=\"42\">40</foo>"
+            "<foo yang:operation=\"replace\" yang:orig-value=\"42\" yang:orig-default=\"false\">40</foo>"
             "<baz yang:operation=\"delete\">42</baz>"
         "</hidden>"
     );
@@ -524,7 +524,7 @@
             "</list>"
             "<list yang:operation=\"none\">"
                 "<name>b</name>"
-                "<value yang:operation=\"replace\" yang:orig-value=\"2\">-2</value>"
+                "<value yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\">-2</value>"
             "</list>"
             "<list yang:operation=\"create\">"
                 "<name>c</name>"
@@ -573,11 +573,11 @@
         "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
             "<list yang:operation=\"none\">"
                 "<name>a</name>"
-                "<value yang:operation=\"replace\" yang:orig-value=\"1\">2</value>"
+                "<value yang:operation=\"replace\" yang:orig-value=\"1\" yang:orig-default=\"false\">2</value>"
             "</list>"
             "<list yang:operation=\"none\">"
                 "<name>b</name>"
-                "<value yang:operation=\"replace\" yang:orig-value=\"2\">-2</value>"
+                "<value yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\">-2</value>"
             "</list>"
         "</df>"
     );
@@ -622,8 +622,8 @@
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
     assert_string_equal(st->xml,
         "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
-            "<llist yang:operation=\"replace\" yang:orig-value=\"3\" yang:value=\"1\">4</llist>"
-            "<llist yang:operation=\"replace\" yang:orig-value=\"2\" yang:value=\"4\">3</llist>"
+            "<llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"3\" yang:value=\"1\">4</llist>"
+            "<llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\" yang:value=\"4\">3</llist>"
         "</df>"
     );
 
@@ -641,7 +641,7 @@
     assert_string_equal(st->xml,
         "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
             "<llist yang:operation=\"delete\" yang:orig-value=\"\">1</llist>"
-            "<llist yang:operation=\"replace\" yang:orig-value=\"2\" yang:value=\"\">5</llist>"
+            "<llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\" yang:value=\"\">5</llist>"
         "</df>"
     );
 
@@ -659,10 +659,10 @@
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
     assert_string_equal(st->xml,
         "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
-            "<llist yang:operation=\"replace\" yang:orig-value=\"3\" yang:value=\"1\">4</llist>"
-            "<llist yang:operation=\"replace\" yang:orig-value=\"2\" yang:value=\"4\">3</llist>"
+            "<llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"3\" yang:value=\"1\">4</llist>"
+            "<llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\" yang:value=\"4\">3</llist>"
             "<llist yang:orig-value=\"\" yang:operation=\"delete\">1</llist>"
-            "<llist yang:orig-value=\"2\" yang:value=\"\" yang:operation=\"replace\">5</llist>"
+            "<llist yang:orig-default=\"false\" yang:orig-value=\"2\" yang:value=\"\" yang:operation=\"replace\">5</llist>"
         "</df>"
     );
 }
@@ -706,7 +706,7 @@
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
     assert_string_equal(st->xml,
         "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
-            "<llist yang:operation=\"replace\" yang:orig-value=\"3\" yang:value=\"2\">4</llist>"
+            "<llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"3\" yang:value=\"2\">4</llist>"
         "</df>"
     );
 
@@ -724,7 +724,7 @@
     assert_string_equal(st->xml,
         "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
             "<llist yang:operation=\"delete\" yang:orig-value=\"1\">2</llist>"
-            "<llist yang:operation=\"replace\" yang:orig-value=\"1\" yang:value=\"\">4</llist>"
+            "<llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"1\" yang:value=\"\">4</llist>"
         "</df>"
     );
 
@@ -742,7 +742,7 @@
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
     assert_string_equal(st->xml,
         "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
-            "<llist yang:operation=\"replace\" yang:orig-value=\"3\" yang:value=\"\">4</llist>"
+            "<llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"3\" yang:value=\"\">4</llist>"
             "<llist yang:orig-value=\"1\" yang:operation=\"delete\">2</llist>"
         "</df>"
     );
@@ -782,7 +782,7 @@
     assert_string_equal(st->xml,
         "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
             "<llist yang:operation=\"delete\" yang:orig-value=\"1\">2</llist>"
-            "<llist yang:operation=\"replace\" yang:orig-value=\"1\" yang:value=\"\">3</llist>"
+            "<llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"1\" yang:value=\"\">3</llist>"
         "</df>"
     );
 
@@ -799,7 +799,7 @@
     lyd_print_mem(&st->xml, st->diff2, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
     assert_string_equal(st->xml,
         "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
-            "<llist yang:operation=\"replace\" yang:orig-value=\"3\" yang:value=\"\">1</llist>"
+            "<llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"3\" yang:value=\"\">1</llist>"
             "<llist yang:operation=\"create\" yang:value=\"1\">4</llist>"
         "</df>"
     );
@@ -819,8 +819,8 @@
     assert_string_equal(st->xml,
         "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
             "<llist yang:operation=\"delete\" yang:orig-value=\"1\">2</llist>"
-            "<llist yang:operation=\"replace\" yang:orig-value=\"1\" yang:value=\"\">3</llist>"
-            "<llist yang:orig-value=\"3\" yang:value=\"\" yang:operation=\"replace\">1</llist>"
+            "<llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"1\" yang:value=\"\">3</llist>"
+            "<llist yang:orig-default=\"false\" yang:orig-value=\"3\" yang:value=\"\" yang:operation=\"replace\">1</llist>"
             "<llist yang:value=\"1\" yang:operation=\"create\">4</llist>"
         "</df>"
     );
@@ -877,7 +877,7 @@
     lyd_print_mem(&st->xml, st->diff2, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL | LYD_PRINT_SHRINK);
     assert_string_equal(st->xml,
         "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
-            "<foo yang:operation=\"replace\" yang:orig-value=\"41\">42</foo>"
+            "<foo yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"41\">42</foo>"
             "<dllist yang:operation=\"create\">1</dllist>"
         "</df>"
     );