mbox series

[GSoC,v9,0/9] ref consistency check infra setup

Message ID Zo0sQCBqyxX8dJ-f@ArchLinux (mailing list archive)
Headers show
Series ref consistency check infra setup | expand

Message

shejialuo July 9, 2024, 12:32 p.m. UTC
Hi All:

This version changes the following things:

1. Instead of using "oid_skiplist", use "skip_oids".
2. In "fsck_refs_error_function", I define a static struct strbuf here,
the reason why I define it to be `static` is that we may call this
function many times. It's a bad idea to allocate memory too frequently.
And we should never free its memory. I made a mistake here, I should
call `strbuf_reset` function every time. So this version, add
"strbuf_reset" to make the behavior correct.

shejialuo (9):
  fsck: rename "skiplist" to "skip_oids"
  fsck: add a unified interface for reporting fsck messages
  fsck: add refs-related options and error report function
  refs: set up ref consistency check infrastructure
  builtin/refs: add verify subcommand
  builtin/fsck: add `git-refs verify` child process
  files-backend: add unified interface for refs scanning
  fsck: add ref name check for files backend
  fsck: add ref content check for files backend

 Documentation/fsck-msgids.txt |  12 ++
 Documentation/git-refs.txt    |  13 ++
 builtin/fsck.c                |  32 ++++-
 builtin/mktag.c               |   1 +
 builtin/refs.c                |  44 ++++++
 fsck.c                        | 108 +++++++++++---
 fsck.h                        |  63 ++++++---
 object-file.c                 |  11 +-
 refs.c                        |   7 +-
 refs.h                        |   8 ++
 refs/debug.c                  |  11 ++
 refs/files-backend.c          | 255 +++++++++++++++++++++++++++++++++-
 refs/packed-backend.c         |   8 ++
 refs/refs-internal.h          |  11 +-
 refs/reftable-backend.c       |   8 ++
 t/t0602-reffiles-fsck.sh      | 211 ++++++++++++++++++++++++++++
 16 files changed, 746 insertions(+), 57 deletions(-)
 create mode 100755 t/t0602-reffiles-fsck.sh

Range-diff against v8:
 1:  61e475840f !  1:  e044f933de fsck: rename "skiplist" to "oid_skiplist"
    @@ Metadata
     Author: shejialuo <shejialuo@gmail.com>
     
      ## Commit message ##
    -    fsck: rename "skiplist" to "oid_skiplist"
    +    fsck: rename "skiplist" to "skip_oids"
     
         The "skiplist" field in "fsck_options" is related to objects. Because we
         are going to introduce ref consistency check, the "skiplist" name is too
    @@ Commit message
         "skiplist" here. However, the type for "skiplist" is `struct oidset`
         which is totally unsuitable for refs.
     
    -    To avoid above ambiguity, rename "skiplist" to "oid_skiplist".
    +    To avoid above ambiguity, rename "skiplist" to "skip_oids".
     
         Mentored-by: Patrick Steinhardt <ps@pks.im>
         Mentored-by: Karthik Nayak <karthik.188@gmail.com>
    @@ fsck.c: void fsck_set_msg_types(struct fsck_options *options, const char *values
      			if (equal == len)
      				die("skiplist requires a path");
     -			oidset_parse_file(&options->skiplist, buf + equal + 1,
    -+			oidset_parse_file(&options->oid_skiplist, buf + equal + 1,
    ++			oidset_parse_file(&options->skip_oids, buf + equal + 1,
      					  the_repository->hash_algo);
      			buf += len + 1;
      			continue;
    @@ fsck.c: void fsck_set_msg_types(struct fsck_options *options, const char *values
      			      const struct object_id *oid)
      {
     -	return opts && oid && oidset_contains(&opts->skiplist, oid);
    -+	return opts && oid && oidset_contains(&opts->oid_skiplist, oid);
    ++	return opts && oid && oidset_contains(&opts->skip_oids, oid);
      }
      
      __attribute__((format (printf, 5, 6)))
    @@ fsck.h: struct fsck_options {
      	unsigned strict:1;
      	enum fsck_msg_type *msg_type;
     -	struct oidset skiplist;
    -+	struct oidset oid_skiplist;
    ++	struct oidset skip_oids;
      	struct oidset gitmodules_found;
      	struct oidset gitmodules_done;
      	struct oidset gitattributes_found;
    +@@ fsck.h: struct fsck_options {
    + };
    + 
    + #define FSCK_OPTIONS_DEFAULT { \
    +-	.skiplist = OIDSET_INIT, \
    ++	.skip_oids = OIDSET_INIT, \
    + 	.gitmodules_found = OIDSET_INIT, \
    + 	.gitmodules_done = OIDSET_INIT, \
    + 	.gitattributes_found = OIDSET_INIT, \
 2:  f2576d88a9 !  2:  daaf3d0ffe fsck: add a unified interface for reporting fsck messages
    @@ builtin/mktag.c: static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;
     
      ## fsck.c ##
     @@ fsck.c: static int object_on_skiplist(struct fsck_options *opts,
    - 	return opts && oid && oidset_contains(&opts->oid_skiplist, oid);
    + 	return opts && oid && oidset_contains(&opts->skip_oids, oid);
      }
      
     -__attribute__((format (printf, 5, 6)))
    @@ fsck.h: int is_valid_msg_type(const char *msg_id, const char *msg_type);
      struct fsck_options {
      	fsck_walk_func walk;
     @@ fsck.h: struct fsck_options {
    - };
    - 
    - #define FSCK_OPTIONS_DEFAULT { \
    --	.skiplist = OIDSET_INIT, \
    -+	.oid_skiplist = OIDSET_INIT, \
    - 	.gitmodules_found = OIDSET_INIT, \
      	.gitmodules_done = OIDSET_INIT, \
      	.gitattributes_found = OIDSET_INIT, \
      	.gitattributes_done = OIDSET_INIT, \
 3:  c3c2dda50c !  3:  40da85ae30 fsck: add refs-related options and error report function
    @@ fsck.c: int fsck_objects_error_function(struct fsck_options *o,
     +{
     +	static struct strbuf sb = STRBUF_INIT;
     +
    ++	strbuf_reset(&sb);
     +	strbuf_addstr(&sb, checked_ref_name);
     +	if (oid)
     +		strbuf_addf(&sb, " -> (%s)", oid_to_hex(oid));
    @@ fsck.h: int fsck_objects_error_cb_print_missing_gitmodules(struct fsck_options *
      	unsigned strict:1;
     +	unsigned verbose_refs:1;
      	enum fsck_msg_type *msg_type;
    - 	struct oidset oid_skiplist;
    + 	struct oidset skip_oids;
      	struct oidset gitmodules_found;
     @@ fsck.h: struct fsck_options {
      	.gitattributes_done = OIDSET_INIT, \
 4:  e826dc17ec =  4:  a38ea1b117 refs: set up ref consistency check infrastructure
 5:  33cac4882b !  5:  8320f56e0b builtin/refs: add verify subcommand
    @@ builtin/refs.c: static int cmd_refs_migrate(int argc, const char **argv, const c
     +	 * Explicitly free the allocated array and "oid_skiplist"
     +	 */
     +	free(fsck_refs_options.msg_type);
    -+	oidset_clear(&fsck_refs_options.oid_skiplist);
    ++	oidset_clear(&fsck_refs_options.skip_oids);
     +	return ret;
     +}
     +
 6:  32668e3543 =  6:  6614a06ef5 builtin/fsck: add `git-refs verify` child process
 7:  df83b2a990 =  7:  928cc96396 files-backend: add unified interface for refs scanning
 8:  c696c15651 =  8:  4d50d4932f fsck: add ref name check for files backend
 9:  8b0f3aeb9c =  9:  7edb810819 fsck: add ref content check for files backend