diff -pruN 2.2.1-1/debian/changelog 2.2.1-1ubuntu1/debian/changelog
--- 2.2.1-1/debian/changelog	2024-11-26 20:06:37.000000000 +0000
+++ 2.2.1-1ubuntu1/debian/changelog	2025-10-16 08:07:01.000000000 +0000
@@ -1,3 +1,12 @@
+tree (2.2.1-1ubuntu1) resolute; urgency=medium
+
+  * Fix XML/JSON output on empty directoryes (LP: #2113790)
+    - d/p/0001-tree-list-call-printinfo-on-error-cases-too.patch:
+      call printinfo on error cases too, thanks to Simon Chopin
+    - d/t/clitest.md: update expected output for new patch
+
+ -- Nadzeya Hutsko <nadzeya.hutsko@canonical.com>  Thu, 16 Oct 2025 10:07:01 +0200
+
 tree (2.2.1-1) unstable; urgency=medium
 
   * [70f7a56] New upstream version 2.2.1
diff -pruN 2.2.1-1/debian/control 2.2.1-1ubuntu1/debian/control
--- 2.2.1-1/debian/control	2024-07-04 17:39:59.000000000 +0000
+++ 2.2.1-1ubuntu1/debian/control	2025-10-16 08:07:01.000000000 +0000
@@ -1,7 +1,8 @@
 Source: tree
 Section: utils
 Priority: optional
-Maintainer: Florian Ernst <florian@debian.org>
+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
+XSBC-Original-Maintainer: Florian Ernst <florian@debian.org>
 Build-Depends: debhelper-compat (= 13)
 Standards-Version: 4.7.0
 Rules-Requires-Root: no
diff -pruN 2.2.1-1/debian/patches/0001-tree-list-call-printinfo-on-error-cases-too.patch 2.2.1-1ubuntu1/debian/patches/0001-tree-list-call-printinfo-on-error-cases-too.patch
--- 2.2.1-1/debian/patches/0001-tree-list-call-printinfo-on-error-cases-too.patch	1970-01-01 00:00:00.000000000 +0000
+++ 2.2.1-1ubuntu1/debian/patches/0001-tree-list-call-printinfo-on-error-cases-too.patch	2025-10-16 08:07:01.000000000 +0000
@@ -0,0 +1,64 @@
+From 40cf0be3df7411e3cb9f9db2432efbef9905d37c Mon Sep 17 00:00:00 2001
+From: Simon Chopin <schopin@ubuntu.com>
+Date: Tue, 10 Jun 2025 18:04:25 +0200
+Subject: [PATCH] tree: list: call printinfo on error cases too
+
+This only needs a slight adjustment of fillinfo to do an early return
+if info is NULL, all other implementations already supporting that case.
+
+The change is necessary as the markup outputs will open an
+object in that function for the printfile function to write in.
+
+BEFORE:
+[
+  ,"name":"toto","contents":[{"error": "error opening dir"}
+  ]}
+,
+  {"type":"report","directories":0,"files":0}
+]
+
+AFTER:
+[
+  {"type":"unknown","name":"toto","contents":[{"error": "error opening dir"}
+  ]}
+,
+  {"type":"report","directories":0,"files":0}
+]
+
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/tree/+bug/2113790
+Fixes: f210506b50 ("Version 2.0.0 (12/21/2021)")
+---
+ list.c | 2 +-
+ tree.c | 2 ++
+ 2 files changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/list.c b/list.c
+index 4db6e6e..298f2bd 100644
+--- a/list.c
++++ b/list.c
+@@ -94,8 +94,8 @@ void emit_tree(char **dirname, bool needfulltree)
+ 	dir = read_dir(dirname[i], &n, inf != NULL);
+       }
+ 
+-      lc.printinfo(dirname[i], info, 0);
+     } else info = NULL;
++    lc.printinfo(dirname[i], info, 0);
+ 
+     needsclosed = lc.printfile(dirname[i], dirname[i], info, (dir != NULL) || (!dir && n));
+     subtotal = (struct totals){0, 0, 0};
+diff --git a/tree.c b/tree.c
+index 13e8c3d..9f32db6 100644
+--- a/tree.c
++++ b/tree.c
+@@ -1492,6 +1492,8 @@ char *fillinfo(char *buf, const struct _info *ent)
+ {
+   int n;
+   buf[n=0] = 0;
++  if (!ent)
++    return buf;
+   #ifdef __USE_FILE_OFFSET64
+   if (inodeflag) n += sprintf(buf," %7lld",(long long)ent->linode);
+   #else
+-- 
+2.48.1
+
diff -pruN 2.2.1-1/debian/patches/series 2.2.1-1ubuntu1/debian/patches/series
--- 2.2.1-1/debian/patches/series	2023-06-26 16:01:52.000000000 +0000
+++ 2.2.1-1ubuntu1/debian/patches/series	2025-10-16 08:07:01.000000000 +0000
@@ -1 +1,2 @@
 manpage
+0001-tree-list-call-printinfo-on-error-cases-too.patch
diff -pruN 2.2.1-1/debian/tests/clitest.md 2.2.1-1ubuntu1/debian/tests/clitest.md
--- 2.2.1-1/debian/tests/clitest.md	2024-11-26 20:02:04.000000000 +0000
+++ 2.2.1-1ubuntu1/debian/tests/clitest.md	2025-10-16 08:07:01.000000000 +0000
@@ -11,6 +11,7 @@ debian
 |-- copyright
 |-- docs
 |-- patches
+|   |-- 0001-tree-list-call-printinfo-on-error-cases-too.patch
 |   |-- manpage
 |   `-- series
 |-- rules
@@ -22,7 +23,7 @@ debian
 |   `-- control
 `-- watch
 
-4 directories, 12 files
+4 directories, 13 files
 $
 ```
 
@@ -108,6 +109,7 @@ debian
 |-- control
 |-- copyright
 |-- patches
+|   |-- 0001-tree-list-call-printinfo-on-error-cases-too.patch
 |   |-- manpage
 |   `-- series
 |-- source
@@ -117,7 +119,7 @@ debian
 |   `-- control
 `-- watch
 
-4 directories, 8 files
+4 directories, 9 files
 $
 ```
 
@@ -223,6 +225,7 @@ debian
 |-- salsa-ci.yml
 |-- watch
 |-- patches
+|   |-- 0001-tree-list-call-printinfo-on-error-cases-too.patch
 |   |-- manpage
 |   `-- series
 |-- source
@@ -231,7 +234,7 @@ debian
     |-- clitest.md
     `-- control
 
-4 directories, 12 files
+4 directories, 13 files
 $
 ```
 
@@ -241,6 +244,7 @@ List files before directories:
 $ tree --dirsfirst debian
 debian
 |-- patches
+|   |-- 0001-tree-list-call-printinfo-on-error-cases-too.patch
 |   |-- manpage
 |   `-- series
 |-- source
@@ -256,7 +260,7 @@ debian
 |-- salsa-ci.yml
 `-- watch
 
-4 directories, 12 files
+4 directories, 13 files
 $
 ```
 
