diff --git a/gio/gio-tool-info.c b/gio/gio-tool-info.c index dbdc6b69e..a773d8d6c 100644 --- a/gio/gio-tool-info.c +++ b/gio/gio-tool-info.c @@ -177,7 +177,8 @@ show_info (GFile *file, GFileInfo *info) g_free (flatten); } - name = g_file_info_get_name (info); + name = g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_NAME) ? + g_file_info_get_name (info) : NULL; if (name) { escaped = escape_string (name); diff --git a/gio/tests/gio-tool.py b/gio/tests/gio-tool.py index b977eb102..593ac9767 100644 --- a/gio/tests/gio-tool.py +++ b/gio/tests/gio-tool.py @@ -119,6 +119,14 @@ class TestGioTool(unittest.TestCase): with self.assertRaises(subprocess.CalledProcessError): self.runGio() + def test_info_non_default_attributes(self): + """Test running `gio info --attributes` with a non-default list.""" + with tempfile.NamedTemporaryFile(dir=self.tmpdir.name) as tmpfile: + result = self.runGio( + "info", "--attributes=standard::content-type", tmpfile.name + ) + self.assertIn("standard::content-type: application/x-zerosize", result.out) + if __name__ == "__main__": unittest.main(testRunner=taptestrunner.TAPTestRunner())