From: Christian Couder <christian.couder@gmail.com>
To: Son Luong Ngoc via GitGitGadget <gitgitgadget@gmail.com>
Cc: git <git@vger.kernel.org>, Son Luong Ngoc <sluongng@gmail.com>
Subject: Re: [PATCH] commit-graph: add verify changed paths option
Date: Fri, 31 Jul 2020 18:21:54 +0200 [thread overview]
Message-ID: <CAP8UFD3QF9P4UvQqaguc0MgNijBvzC4KhF=D_+MN+NjfaR535g@mail.gmail.com> (raw)
In-Reply-To: <pull.687.git.1596181765336.gitgitgadget@gmail.com>
On Fri, Jul 31, 2020 at 9:52 AM Son Luong Ngoc via GitGitGadget
<gitgitgadget@gmail.com> wrote:
>
> From: Son Luong Ngoc <sluongng@gmail.com>
>
> Add '--has-changed-paths' option to 'git commit-graph verify' subcommand
> to validate whether the commit-graph was written with '--changed-paths'
> option.
>
> Signed-off-by: Son Luong Ngoc <sluongng@gmail.com>
[...]
> It's probably going to take me a bit more time to write up some tests
> for this,
It would need some documentation too.
> so I want to send it out first for comments.
[...]
> diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
> index 16c9f6101a..ce8a7cbe90 100644
> --- a/builtin/commit-graph.c
> +++ b/builtin/commit-graph.c
> @@ -18,7 +18,8 @@ static char const * const builtin_commit_graph_usage[] = {
> };
>
> static const char * const builtin_commit_graph_verify_usage[] = {
> - N_("git commit-graph verify [--object-dir <objdir>] [--shallow] [--[no-]progress]"),
> + N_("git commit-graph verify [--object-dir <objdir>] [--shallow] "
> + "[--has-changed-paths] [--[no-]progress]"),
> NULL
> };
>
> @@ -37,6 +38,7 @@ static struct opts_commit_graph {
> int append;
> int split;
> int shallow;
> + int has_changed_paths;
> int progress;
> int enable_changed_paths;
> } opts;
> @@ -71,12 +73,14 @@ static int graph_verify(int argc, const char **argv)
> int open_ok;
> int fd;
> struct stat st;
> - int flags = 0;
> + enum commit_graph_verify_flags flags = 0;
>
> static struct option builtin_commit_graph_verify_options[] = {
> OPT_STRING(0, "object-dir", &opts.obj_dir,
> N_("dir"),
> N_("The object directory to store the graph")),
> + OPT_BOOL(0, "has-changed-paths", &opts.has_changed_paths,
> + N_("verify that the commit-graph includes changed paths")),
> OPT_BOOL(0, "shallow", &opts.shallow,
> N_("if the commit-graph is split, only verify the tip file")),
> OPT_BOOL(0, "progress", &opts.progress, N_("force progress reporting")),
> @@ -94,8 +98,10 @@ static int graph_verify(int argc, const char **argv)
> opts.obj_dir = get_object_directory();
> if (opts.shallow)
> flags |= COMMIT_GRAPH_VERIFY_SHALLOW;
> + if (opts.has_changed_paths)
> + flags |= COMMIT_GRAPH_VERIFY_CHANGED_PATHS;
I wonder if OPT_BIT() could be used instead of OPT_BOOL() above to
directly set the above flag, as the 'has_changed_paths' field in
'struct opts_commit_graph' seems to be used only for the purpose of
setting this flag.
> if (opts.progress)
> - flags |= COMMIT_GRAPH_WRITE_PROGRESS;
> + flags |= COMMIT_GRAPH_VERIFY_PROGRESS;
Does this change belong to this patch? I think it would deserve an
explanation in the commit message if that's the case.
> odb = find_odb(the_repository, opts.obj_dir);
> graph_name = get_commit_graph_filename(odb);
> diff --git a/commit-graph.c b/commit-graph.c
> index 1af68c297d..d83f5a2325 100644
> --- a/commit-graph.c
> +++ b/commit-graph.c
> @@ -250,7 +250,7 @@ struct commit_graph *load_commit_graph_one_fd_st(int fd, struct stat *st,
> return ret;
> }
>
> -static int verify_commit_graph_lite(struct commit_graph *g)
> +static int verify_commit_graph_lite(struct commit_graph *g, int verify_changed_path)
[...]
> -int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
> +int verify_commit_graph(struct repository *r,
> + struct commit_graph *g,
> + enum commit_graph_verify_flags flags)
It seems to me that it would be more coherent to have both
verify_commit_graph() and verify_commit_graph_lite() accept an 'enum
commit_graph_verify_flags flags' argument.
Right now the "has_changed_paths" option is first an int, then it's
converted to a flag and then to an int again before being passed to
verify_commit_graph_lite(). It would be simpler if it could be a flag
all along.
Thanks,
Christian.
next prev parent reply other threads:[~2020-07-31 16:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-31 7:49 [PATCH] commit-graph: add verify changed paths option Son Luong Ngoc via GitGitGadget
2020-07-31 16:21 ` Christian Couder [this message]
2020-07-31 17:14 ` Junio C Hamano
2020-07-31 18:06 ` Taylor Blau
2020-07-31 18:02 ` Jeff King
2020-07-31 18:09 ` Taylor Blau
2020-07-31 19:14 ` Jeff King
2020-07-31 19:31 ` Son Luong Ngoc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAP8UFD3QF9P4UvQqaguc0MgNijBvzC4KhF=D_+MN+NjfaR535g@mail.gmail.com' \
--to=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=sluongng@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).