Subject: [PATCH v4 0/8] Allow writing invalid OIDs into refs for testing purposes

From: "Han-Wen Nienhuys via GitGitGadget" <[email-masked]>
Date: Tue, 07 Dec 2021 13:38:12 +0000

this covers a few cases of direct filesystem access to the ref database in
tests.

v4:

 * fix stack OOB read due to missing array terminator.

Han-Wen Nienhuys (8):
  test-ref-store: remove force-create argument for create-reflog
  test-ref-store: parse symbolic flag constants
  test-ref-store: plug memory leak in cmd_delete_refs
  refs: update comment.
  refs: introduce REF_SKIP_OID_VERIFICATION flag
  refs: introduce REF_SKIP_REFNAME_VERIFICATION flag
  t1430: remove refs using test-tool
  t1430: create valid symrefs using test-helper

 refs.c                         |  7 +--
 refs.h                         | 16 +++++-
 refs/files-backend.c           | 53 ++++++++++---------
 t/helper/test-ref-store.c      | 75 +++++++++++++++++++++++----
 t/t1006-cat-file.sh            |  5 +-
 t/t1405-main-ref-store.sh      |  8 ++-
 t/t1406-submodule-ref-store.sh |  2 +-
 t/t1430-bad-ref-name.sh        | 93 ++++++++++++++++++----------------
 t/t3800-mktag.sh               |  6 ++-
 9 files changed, 172 insertions(+), 93 deletions(-)

base-commit: abe6bb3905392d5eb6b01fa6e54d7e784e0522aa
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1147%2Fhanwen%2Fskip-verification-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1147/hanwen/skip-verification-v4
Pull-Request: https://github.com/git/git/pull/1147

Range-diff vs v3:

 1:  3649ef6d0fa = 1:  3649ef6d0fa test-ref-store: remove force-create argument for create-reflog
 2:  3cdebd2dbca ! 2:  865458bc0cb test-ref-store: parse symbolic flag constants
     @@ t/helper/test-ref-store.c
      +	return result;
      +}
      +
     -+static struct flag_definition empty_flags[] = {
     -+	{ NULL, 0 },
     -+};
     ++static struct flag_definition empty_flags[] = { { NULL, 0 } };
      +
       static const char *notnull(const char *arg, const char *name)
       {
     @@ t/helper/test-ref-store.c: static const char **get_store(const char **argv, stru
       	return argv + 1;
       }
       
     -+static struct flag_definition pack_flags[] = {
     -+	FLAG_DEF(PACK_REFS_PRUNE),
     -+	FLAG_DEF(PACK_REFS_ALL),
     -+};
     ++static struct flag_definition pack_flags[] = { FLAG_DEF(PACK_REFS_PRUNE),
     ++					       FLAG_DEF(PACK_REFS_ALL),
     ++					       { NULL, 0 } };
       
       static int cmd_pack_refs(struct ref_store *refs, const char **argv)
       {
     @@ t/helper/test-ref-store.c: static int cmd_create_symref(struct ref_store *refs,
      +static struct flag_definition transaction_flags[] = {
      +	FLAG_DEF(REF_NO_DEREF),
      +	FLAG_DEF(REF_FORCE_CREATE_REFLOG),
     -+	{ NULL, 0 },
     ++	{ NULL, 0 }
      +};
      +
       static int cmd_delete_refs(struct ref_store *refs, const char **argv)
 3:  536005d65a2 = 3:  dcd4e9f5f26 test-ref-store: plug memory leak in cmd_delete_refs
 4:  466b4451015 = 4:  67d22211ac4 refs: update comment.
 5:  89d692a34b8 ! 5:  a8713dd59ee refs: introduce REF_SKIP_OID_VERIFICATION flag
     @@ t/helper/test-ref-store.c: static int cmd_create_symref(struct ref_store *refs,
       	FLAG_DEF(REF_NO_DEREF),
       	FLAG_DEF(REF_FORCE_CREATE_REFLOG),
      +	FLAG_DEF(REF_SKIP_OID_VERIFICATION),
     - 	{ NULL, 0 },
     + 	{ NULL, 0 }
       };

 6:  af9e94935bf ! 6:  577726dc9df refs: introduce REF_SKIP_REFNAME_VERIFICATION flag
     @@ t/helper/test-ref-store.c: static struct flag_definition transaction_flags[] = {
       	FLAG_DEF(REF_FORCE_CREATE_REFLOG),
       	FLAG_DEF(REF_SKIP_OID_VERIFICATION),
      +	FLAG_DEF(REF_SKIP_REFNAME_VERIFICATION),
     - 	{ NULL, 0 },
     + 	{ NULL, 0 }
       };

 7:  d4f1d209468 = 7:  d85cfa3fee1 t1430: remove refs using test-tool
 8:  ca7f8aea3d9 = 8:  7597620ec83 t1430: create valid symrefs using test-helper

-- 
gitgitgadget