mbox series

[v8,00/17] fsck: lib-ify object-file.c & better fsck "invalid object" error reporting

Message ID cover-v8-00.17-00000000000-20210928T021616Z-avarab@gmail.com (mailing list archive)
Headers show
Series fsck: lib-ify object-file.c & better fsck "invalid object" error reporting | expand

Message

Ævar Arnfjörð Bjarmason Sept. 28, 2021, 2:18 a.m. UTC
This improves fsck error reporting, see the examples in the commit
messages of 16/17 and 17/17. To get there I've lib-ified more things
in object-file.c and the general object APIs, i.e. now we'll return
error codes instead of calling die() in these cases.

v6 of this got a very detailed review from Taylor Blau (thanks a
lot!), for the v6 see:
https://lore.kernel.org/git/cover-v6-00.22-00000000000-20210907T104558Z-avarab@gmail.com/

The v7 had a couple of trivial shellscripting issues, a typo'd
test_oid variable, and a warning on a "test" comparison. For v7 see
https://lore.kernel.org/git/cover-v7-00.17-00000000000-20210920T190304Z-avarab@gmail.com/

Ævar Arnfjörð Bjarmason (17):
  fsck tests: add test for fsck-ing an unknown type
  fsck tests: refactor one test to use a sub-repo
  fsck tests: test current hash/type mismatch behavior
  fsck tests: test for garbage appended to a loose object
  cat-file tests: move bogus_* variable declarations earlier
  cat-file tests: test for missing/bogus object with -t, -s and -p
  cat-file tests: add corrupt loose object test
  cat-file tests: test for current --allow-unknown-type behavior
  object-file.c: don't set "typep" when returning non-zero
  object-file.c: return -1, not "status" from unpack_loose_header()
  object-file.c: make parse_loose_header_extended() public
  object-file.c: simplify unpack_loose_short_header()
  object-file.c: use "enum" return type for unpack_loose_header()
  object-file.c: return ULHR_TOO_LONG on "header too long"
  object-file.c: stop dying in parse_loose_header()
  fsck: don't hard die on invalid object types
  fsck: report invalid object type-path combinations

 builtin/fast-export.c |   2 +-
 builtin/fsck.c        |  28 +++++-
 builtin/index-pack.c  |   2 +-
 builtin/mktag.c       |   3 +-
 cache.h               |  45 ++++++++-
 object-file.c         | 176 +++++++++++++++------------------
 object-store.h        |   7 +-
 object.c              |   4 +-
 pack-check.c          |   3 +-
 streaming.c           |  27 +++--
 t/oid-info/oid        |   2 +
 t/t1006-cat-file.sh   | 223 +++++++++++++++++++++++++++++++++++++++---
 t/t1450-fsck.sh       |  99 +++++++++++++++----
 13 files changed, 463 insertions(+), 158 deletions(-)

Range-diff against v7:
 1:  752cef556c2 =  1:  b999ab695d9 fsck tests: add test for fsck-ing an unknown type
 2:  612003bdd2c =  2:  e01c21378a4 fsck tests: refactor one test to use a sub-repo
 3:  1e40a4235e9 =  3:  93197a7bcee fsck tests: test current hash/type mismatch behavior
 4:  854991c1543 =  4:  277188dd58d fsck tests: test for garbage appended to a loose object
 5:  fc93c2c2530 =  5:  ab2ea1beaaf cat-file tests: move bogus_* variable declarations earlier
 6:  051088aa114 !  6:  91229b94fac cat-file tests: test for missing/bogus object with -t, -s and -p
    @@ t/oid-info/oid: numeric		sha1:0123456789012345678901234567890123456789
      deadbeef	sha1:deadbeefdeadbeefdeadbeefdeadbeefdeadbeef
      deadbeef	sha256:deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
     +deadbeef_short	sha1:deadbeefdeadbeefdeadbeefdeadbeefdeadbee
    -+deadbee_short	sha256:deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbee
    ++deadbeef_short	sha256:deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbee
     
      ## t/t1006-cat-file.sh ##
     @@ t/t1006-cat-file.sh: test_expect_success 'setup bogus data' '
    @@ t/t1006-cat-file.sh: test_expect_success 'setup bogus data' '
     +do
     +	for arg2 in -s -t -p
     +	do
    -+		if test $arg1 = "--allow-unknown-type" && test "$arg2" = "-p"
    ++		if test "$arg1" = "--allow-unknown-type" && test "$arg2" = "-p"
     +		then
     +			continue
     +		fi
 7:  20bd81c1af0 =  7:  9e95e134d30 cat-file tests: add corrupt loose object test
 8:  cd1d52b8a07 =  8:  215f98ad369 cat-file tests: test for current --allow-unknown-type behavior
 9:  d9f5adfc74b =  9:  3e1df3594df object-file.c: don't set "typep" when returning non-zero
10:  51d14bc9274 = 10:  b96828f3d5b object-file.c: return -1, not "status" from unpack_loose_header()
11:  f43cfd8a5ed = 11:  273acb45517 object-file.c: make parse_loose_header_extended() public
12:  50d938f7f3c = 12:  314d34357dd object-file.c: simplify unpack_loose_short_header()
13:  755fde00b46 = 13:  07481bcb55c object-file.c: use "enum" return type for unpack_loose_header()
14:  522d71eb19d = 14:  42b8d135c8c object-file.c: return ULHR_TOO_LONG on "header too long"
15:  1ca875395c1 = 15:  106b7461ce9 object-file.c: stop dying in parse_loose_header()
16:  d38067feab3 = 16:  d01223ae322 fsck: don't hard die on invalid object types
17:  b07e892fc19 = 17:  7f394a991a6 fsck: report invalid object type-path combinations

Comments

Taylor Blau Sept. 29, 2021, 7:50 p.m. UTC | #1
On Tue, Sep 28, 2021 at 04:18:41AM +0200, Ævar Arnfjörð Bjarmason wrote:
> This improves fsck error reporting, see the examples in the commit
> messages of 16/17 and 17/17. To get there I've lib-ified more things
> in object-file.c and the general object APIs, i.e. now we'll return
> error codes instead of calling die() in these cases.
>
> v6 of this got a very detailed review from Taylor Blau (thanks a
> lot!), for the v6 see:
> https://lore.kernel.org/git/cover-v6-00.22-00000000000-20210907T104558Z-avarab@gmail.com/
>
> The v7 had a couple of trivial shellscripting issues, a typo'd
> test_oid variable, and a warning on a "test" comparison. For v7 see
> https://lore.kernel.org/git/cover-v7-00.17-00000000000-20210920T190304Z-avarab@gmail.com/

Thanks; I looked at the range-diff and it addresses both of my comments.

This series looks good to me.

Thanks,
Taylor