Skip to contentSkip to conversation

archive: fix misleading error message

PATCH In review René Scharfe 2 participants 2 messages Oct 3, 2024 – Oct 4, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 archive: fix misleading error message

The error message added by 296743a7ca (archive: load index before pathspec checks, 2024-09-21) is misleading: unpack_trees() is not touching the working tree at all here, but just loading a tree into the index. Correct it.

---
Silly me, I stole the wrong message. :-/

 archive.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
archive.c +2 -1
index 58f86bf75c..a7a92ff839 100644
@@ -536,7 +536,8 @@ static void parse_treeish_arg(const char **argv,
 		opts.fn = oneway_merge;
 		init_tree_desc(&t, &tree->object.oid, tree->buffer, tree->size);
 		if (unpack_trees(1, &t, &opts))
-			die(_("unable to checkout working tree"));
+			die(_("failed to unpack tree object %s"),
+			    oid_to_hex(&tree->object.oid));
 
 		git_attr_set_direction(GIT_ATTR_INDEX);
 	}

--
2.46.2

#1 lore raw

archive.c static void parse_treeish_arg(const char **argv, · line 540

Quoted 11 lines · René Scharfe

The error message added by 296743a7ca (archive: load index before pathspec checks, 2024-09-21) is misleading: unpack_trees() is not touching the working tree at all here, but just loading a tree into the index. Correct it.

                init_tree_desc(&t, &tree->object.oid, tree->buffer, tree->size);
                if (unpack_trees(1, &t, &opts))
archive.c +2 -1
-                       die(_("unable to checkout working tree"));
+                       die(_("failed to unpack tree object %s"),
+                           oid_to_hex(&tree->object.oid));

The existing instance of this message isn't translated, so it'll still be a new string to translate. Anyway, it's good to use the same wording here as elsewhere.

There's also a "failed to unpack trees", but here, we're indeed unpacking *one* tree.

Good catch!

Martin