Skip to content

add more ref consistency checks

shejialuo git 8 versions – New

Get series with b4
b4 am Z8CMx7O19PMs9sVY@ArchLinux

Versions newest first · linked by author and title

  1. v8 Latest9 patches 0 repliesNew
  2. v79 patches 5 repliesSuperseded
  3. v69 patches 4 repliesSuperseded
Earlier versions · 5
VersionPostedPatchesRepliesStatus
v58 patches5 repliesSuperseded
v48 patches9 repliesSuperseded
v38 patches12 repliesSuperseded
v28 patches27 repliesApplied
v110 patches29 repliesSuperseded

Patches in v8 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9t0602: use subshell to ensure working directory unchangedt/t0602-reffiles-fsck.sh+494 -4730 replies
2/9builtin/refs: get worktrees without reading head informationbuiltin/refs.c worktree.c worktree.h+14 -10 replies
3/9packed-backend: check whether the "packed-refs" is regular filerefs/packed-backend.c t/t0602-reffiles-fsck.sh+78 -40 replies
4/9packed-backend: check if header starts with "# pack-refs with: "refs/packed-backend.c+1 -10 replies
5/9packed-backend: add "packed-refs" header consistency checkDocumentation/fsck-msgids.adoc fsck.h refs/packed-backend.c +1 more+135 -00 replies
6/9packed-backend: check whether the refname contains NUL charactersrefs/packed-backend.c+18 -00 replies
7/9packed-backend: add "packed-refs" entry consistency checkDocumentation/fsck-msgids.adoc fsck.h refs/packed-backend.c +1 more+169 -10 replies
8/9packed-backend: check whether the "packed-refs" is sortedDocumentation/fsck-msgids.adoc fsck.h refs/packed-backend.c +1 more+191 -160 replies
9/9builtin/fsck: add `git refs verify` child processDocumentation/git-fsck.adoc builtin/fsck.c t/t0602-reffiles-fsck.sh+77 -20 replies

Reviews trailers per patch

None of the 9 patches has a Reviewed-by or Acked-by.

PatchPatrick SteinhardtKarthik Nayak
1/9Mentored-by Mentored-by
2/9Mentored-by Mentored-by
3/9Mentored-by Mentored-by
4/9Mentored-by Mentored-by
5/9Mentored-by Mentored-by
6/9Mentored-by Mentored-by
7/9Mentored-by Mentored-by
8/9Mentored-by Mentored-by
9/9Mentored-by Mentored-by

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v8 thread

Cover letter [PATCH v8 0/9] add more ref consistency checks

Hi All:

This changes enhances the following things:

1. [PATCH v8 3/9]: initialize fd = -1 for two purposes:
1. We could use unified goto cleanup where we have one only control.
2. We should not close the fd when we cannot open the file.

Hope that this version would be final. Thank for the effort of every reviewer.

Thanks,
Jialuo

---

This series mainly does the following things:

1. Fix subshell issues
2. Add ref checks for packed-backend.
1. Check whether the filetype of "packed-refs" is correct.
2. Check whether the syntax of "packed-refs" is correct by using the rules from "packed-backend.c::create_snapshot" and "packed-backend.c::next_record".
3. Check whether the pointed object exists and whether the "packed-refs" file is sorted.
3. Call "git refs verify" for "git-fsck(1)".

shejialuo (9):
t0602: use subshell to ensure working directory unchanged builtin/refs: get worktrees without reading head information
packed-backend: check whether the "packed-refs" is regular file
packed-backend: check if header starts with "# pack-refs with: "
packed-backend: add "packed-refs" header consistency check
packed-backend: check whether the refname contains NUL characters
packed-backend: add "packed-refs" entry consistency check
packed-backend: check whether the "packed-refs" is sorted builtin/fsck: add git refs verify child process

 Documentation/fsck-msgids.adoc |   14 +
 Documentation/git-fsck.adoc    |    7 +-
 builtin/fsck.c                 |   33 +-
 builtin/refs.c                 |    2 +-
 fsck.h                         |    4 +
 refs/packed-backend.c          |  363 +++++++++-
 t/t0602-reffiles-fsck.sh       | 1209 +++++++++++++++++++-------------
 worktree.c                     |    5 +
 worktree.h                     |    8 +
 9 files changed, 1162 insertions(+), 483 deletions(-)

Range-diff against v7:

 1:  b3952d80a2 =  1:  b3952d80a2 t0602: use subshell to ensure working directory unchanged
 2:  fa5ce20bb7 =  2:  fa5ce20bb7 builtin/refs: get worktrees without reading head information
 3:  861583f417 !  3:  b3686a9695 packed-backend: check whether the "packed-refs" is regular file
    @@ refs/packed-backend.c: static struct ref_iterator *packed_reflog_iterator_begin(
     +							REF_STORE_READ, "fsck");
     +	struct stat st;
     +	int ret = 0;
    -+	int fd;
    ++	int fd = -1;
      
      	if (!is_main_worktree(wt))
    - 		return 0;
    +-		return 0;
    ++		goto cleanup;
      
     -	return 0;
     +	if (o->verbose)
 4:  5f54cb05c3 =  4:  2638d5043f packed-backend: check if header starts with "# pack-refs with: "
 5:  7d7dc899ad !  5:  13e34de350 packed-backend: add "packed-refs" header consistency check
    @@ refs/packed-backend.c: static struct ref_iterator *packed_reflog_iterator_begin(
     +	struct strbuf packed_ref_content = STRBUF_INIT;
      	struct stat st;
      	int ret = 0;
    - 	int fd;
    + 	int fd = -1;
     @@ refs/packed-backend.c: static int packed_fsck(struct ref_store *ref_store,
      		goto cleanup;
      	}
 6:  571479d3e7 =  6:  0632a1d5e2 packed-backend: check whether the refname contains NUL characters
 7:  e498a57286 =  7:  4618da3199 packed-backend: add "packed-refs" entry consistency check
 8:  3638cb118d !  8:  355e43d251 packed-backend: check whether the "packed-refs" is sorted
    @@ refs/packed-backend.c: static int packed_fsck(struct ref_store *ref_store,
     +	unsigned int sorted = 0;
      	struct stat st;
      	int ret = 0;
    - 	int fd;
    + 	int fd = -1;
     @@ refs/packed-backend.c: static int packed_fsck(struct ref_store *ref_store,
      		goto cleanup;
      	}

9: 5d87e76d28 = 9: 57dac06151 builtin/fsck: add git refs verify child process

Signature · 1 line
2.48.1