Subject: [PATCH 0/7] improve reporting of unexpected objects

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Mon, 8 Mar 2021 21:04:19 +0100

We have some errors that say "your OID %s is not a blob" or whatever,
now with 5/7 we'll say "object %s is a %s, not a %s" in most cases.

Then 7/7 fixes a regression which AFAICT is from 2005. So it's pretty
obscure. When you craft an invalid tag object saying an OID is a tag
instead of a commit, we'd buggily invert the two types when reporting
that error.

The solution to that in 7/7 may not be ideal, but is the best one I
could come up with, so feedback on that patch & this whole thing is
most welcome.

Ævar Arnfjörð Bjarmason (7):
  object.c: refactor type_from_string_gently()
  object.c: make type_from_string() return "enum object_type"
  oid_object_info(): return "enum object_type"
  tree.c: fix misindentation in parse_tree_gently()
  object.c: add a utility function for "expected type X, got Y"
  object tests: add test for unexpected objects in tags
  tag: don't misreport type of tagged objects in errors

 blob.c                                 |  16 +++-
 blob.h                                 |   3 +
 builtin/blame.c                        |   2 +-
 builtin/cat-file.c                     |   2 +-
 builtin/index-pack.c                   |  15 ++--
 builtin/mktree.c                       |   2 +-
 builtin/pack-objects.c                 |   4 +-
 builtin/replace.c                      |   2 +-
 builtin/tag.c                          |   2 +-
 builtin/unpack-objects.c               |   6 +-
 commit.c                               |  24 ++++--
 commit.h                               |   2 +
 fsck.c                                 |   4 +-
 object-file.c                          |  15 ++--
 object-name.c                          |  18 ++--
 object-store.h                         |   2 +-
 object.c                               |  62 +++++++++++---
 object.h                               |   9 +-
 packfile.c                             |   4 +-
 reachable.c                            |   5 +-
 t/t6102-rev-list-unexpected-objects.sh | 113 ++++++++++++++++++++++++-
 tag.c                                  |  14 ++-
 tag.h                                  |   2 +
 tree.c                                 |  27 ++++--
 tree.h                                 |   2 +
 25 files changed, 282 insertions(+), 75 deletions(-)

-- 
2.31.0.rc1.210.g0f8085a843c