From: Derrick Stolee <stolee@gmail.com>
To: Taylor Blau <me@ttaylorr.com>, git@vger.kernel.org
Cc: dstolee@microsoft.com, gitster@pobox.com, peff@peff.net,
szeder.dev@gmail.com
Subject: Re: [PATCH 8/8] commit-graph: drop COMMIT_GRAPH_WRITE_CHECK_OIDS flag
Date: Tue, 5 May 2020 08:10:40 -0400 [thread overview]
Message-ID: <81fb0f5e-e7e1-7541-d6c7-36828190c95b@gmail.com> (raw)
In-Reply-To: <6c2d130b0cd4b6a8a541b362ae7dd44d4c282e3f.1588641176.git.me@ttaylorr.com>
On 5/4/2020 9:14 PM, Taylor Blau wrote:
> Since 7c5c9b9c57 (commit-graph: error out on invalid commit oids in
> 'write --stdin-commits', 2019-08-05), the commit-graph builtin dies on
> receiving non-commit OIDs as input to '--stdin-commits'.
>
> This behavior can be cumbersome to work around in, say, the case of
> piping 'git for-each-ref' to 'git commit-graph write --stdin-commits' if
> the caller does not want to cull out non-commits themselves. In this
> situation, it would be ideal if 'git commit-graph write' wrote the graph
> containing the inputs that did pertain to commits, and silently ignored
> the remainder of the input.
>
> Some options have been proposed to the effect of '--[no-]check-oids'
> which would allow callers to have the commit-graph builtin do just that.
> After some discussion, it is difficult to imagine a caller who wouldn't
> want to pass '--no-check-oids', suggesting that we should get rid of the
> behavior of complaining about non-commit inputs altogether.
>
> If callers do wish to retain this behavior, they can easily work around
> this change by doing the following:
>
> git for-each-ref --format='%(objectname) %(objecttype) %(*objecttype)' |
> awk '/commit/ { print $1 }' |
> git commit-graph write --stdin-commits
I appreciate that you included the workaround here for posterity. That
allows anyone complaining to bisect to these instructions.
> To make it so that valid OIDs that refer to non-existent objects are
> indeed an error after loosening the error handling, perform an extra
> lookup to make sure that object indeed exists before sending it to the
> commit-graph internals.
>
> Signed-off-by: Taylor Blau <me@ttaylorr.com>
> ---
> Documentation/git-commit-graph.txt | 6 ++++--
> builtin/commit-graph.c | 10 +++++-----
> commit-graph.c | 2 --
> commit-graph.h | 10 ++++------
> t/t5318-commit-graph.sh | 15 +++++++++++----
> 5 files changed, 24 insertions(+), 19 deletions(-)
>
> diff --git a/Documentation/git-commit-graph.txt b/Documentation/git-commit-graph.txt
> index 53a650225a..fcac7d12e1 100644
> --- a/Documentation/git-commit-graph.txt
> +++ b/Documentation/git-commit-graph.txt
> @@ -47,8 +47,10 @@ with `--stdin-commits` or `--reachable`.)
> +
> With the `--stdin-commits` option, generate the new commit graph by
> walking commits starting at the commits specified in stdin as a list
> -of OIDs in hex, one OID per line. (Cannot be combined with
> -`--stdin-packs` or `--reachable`.)
> +of OIDs in hex, one OID per line. OIDs that resolve to non-commits
> +(either directly, or by peeling tags) are silently ignored. OIDs that
> +are malformed, or do not exist generate an error. (Cannot be combined
> +with `--stdin-packs` or `--reachable`.)
> +
> With the `--reachable` option, generate the new commit graph by walking
> commits starting at all refs. (Cannot be combined with `--stdin-commits`
> diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
> index 9eec68572f..3637d079fb 100644
> --- a/builtin/commit-graph.c
> +++ b/builtin/commit-graph.c
> @@ -153,13 +153,14 @@ static int read_one_commit(struct oidset *commits, struct progress *progress,
>
> display_progress(progress, oidset_size(commits) + 1);
>
> + if (oid_object_info(the_repository, &oid, NULL) < 0) {
> + error(_("object %s does not exist"), hash);
> + return 1;
> + }
> +
If we get a non-existent object, then this will cause us to fail
the command, right?
> diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
> index 89020d3d44..74f93f0a17 100755
> --- a/t/t5318-commit-graph.sh
> +++ b/t/t5318-commit-graph.sh
> @@ -84,11 +84,18 @@ graph_read_expect() {
>
> test_expect_success 'exit with correct error on bad input to --stdin-commits' '
> cd "$TRASH_DIRECTORY/full" &&
> - echo HEAD | test_expect_code 1 git commit-graph write --stdin-commits 2>stderr &&
> + # invalid, non-hex OID
> + echo HEAD >in &&
> + test_expect_code 1 git commit-graph write --stdin-commits <in 2>stderr &&
> test_i18ngrep "unexpected non-hex object ID: HEAD" stderr &&
> - # valid tree OID, but not a commit OID
> - git rev-parse HEAD^{tree} | test_expect_code 1 git commit-graph write --stdin-commits 2>stderr &&
> - test_i18ngrep "invalid commit object id" stderr
> + # non-existent OID
> + echo $ZERO_OID >in &&
> + test_expect_code 1 git commit-graph write --stdin-commits <in 2>stderr &&
> + test_i18ngrep "does not exist" stderr &&
And here you verify that it fails at that point. Excellent!
> + # valid commit and tree OID
> + git rev-parse HEAD HEAD^{tree} >in &&
> + git commit-graph write --stdin-commits <in &&
> + graph_read_expect 3
> '
This is an excellent series! Thanks.
Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
next prev parent reply other threads:[~2020-05-05 12:10 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-05 1:13 [PATCH 0/8] commit-graph: drop CHECK_OIDS, peel in callers Taylor Blau
2020-05-05 1:13 ` [PATCH 1/8] commit-graph.c: extract 'refs_cb_data' Taylor Blau
2020-05-05 1:13 ` [PATCH 2/8] commit-graph.c: show progress of finding reachable commits Taylor Blau
2020-05-05 11:50 ` Derrick Stolee
2020-05-05 16:13 ` Taylor Blau
2020-05-05 1:13 ` [PATCH 3/8] commit-graph.c: peel refs in 'add_ref_to_set' Taylor Blau
2020-05-07 19:54 ` Jeff King
2020-05-13 19:48 ` Taylor Blau
2020-05-13 20:17 ` Jeff King
2020-05-05 1:13 ` [PATCH 4/8] builtin/commit-graph.c: extract 'read_one_commit()' Taylor Blau
2020-05-07 20:03 ` Jeff King
2020-05-13 20:01 ` Taylor Blau
2020-05-05 1:13 ` [PATCH 5/8] builtin/commit-graph.c: dereference tags in builtin Taylor Blau
2020-05-05 12:01 ` Derrick Stolee
2020-05-05 16:14 ` Taylor Blau
2020-05-07 20:14 ` Jeff King
2020-05-05 1:13 ` [PATCH 6/8] commit-graph.c: simplify 'fill_oids_from_commits' Taylor Blau
2020-05-05 12:05 ` Derrick Stolee
2020-05-07 20:21 ` Jeff King
2020-05-05 1:14 ` [PATCH 7/8] t5318: reorder test below 'graph_read_expect' Taylor Blau
2020-05-05 1:14 ` [PATCH 8/8] commit-graph: drop COMMIT_GRAPH_WRITE_CHECK_OIDS flag Taylor Blau
2020-05-05 12:10 ` Derrick Stolee [this message]
2020-05-05 16:16 ` Taylor Blau
2020-05-07 20:40 ` Jeff King
2020-05-13 21:32 ` Taylor Blau
2020-05-05 11:35 ` [PATCH 0/8] commit-graph: drop CHECK_OIDS, peel in callers Derrick Stolee
2020-05-05 16:11 ` Taylor Blau
2020-05-06 0:07 ` [PATCH v2 " Taylor Blau
2020-05-06 0:07 ` [PATCH v2 1/8] commit-graph.c: extract 'refs_cb_data' Taylor Blau
2020-05-06 0:07 ` [PATCH v2 2/8] commit-graph.c: show progress of finding reachable commits Taylor Blau
2020-05-06 0:07 ` [PATCH v2 3/8] commit-graph.c: peel refs in 'add_ref_to_set' Taylor Blau
2020-05-06 0:07 ` [PATCH v2 4/8] builtin/commit-graph.c: extract 'read_one_commit()' Taylor Blau
2020-05-06 0:07 ` [PATCH v2 5/8] builtin/commit-graph.c: dereference tags in builtin Taylor Blau
2020-05-06 0:07 ` [PATCH v2 6/8] commit-graph.c: simplify 'fill_oids_from_commits' Taylor Blau
2020-05-06 0:07 ` [PATCH v2 7/8] t5318: reorder test below 'graph_read_expect' Taylor Blau
2020-05-06 0:07 ` [PATCH v2 8/8] commit-graph: drop COMMIT_GRAPH_WRITE_CHECK_OIDS flag Taylor Blau
2020-05-07 20:42 ` [PATCH v2 0/8] commit-graph: drop CHECK_OIDS, peel in callers Jeff King
2020-05-13 21:59 ` [PATCH v3 " Taylor Blau
2020-05-13 21:59 ` [PATCH v3 1/8] commit-graph.c: extract 'refs_cb_data' Taylor Blau
2020-05-13 21:59 ` [PATCH v3 2/8] commit-graph.c: show progress of finding reachable commits Taylor Blau
2020-05-13 21:59 ` [PATCH v3 3/8] commit-graph.c: peel refs in 'add_ref_to_set' Taylor Blau
2020-05-13 21:59 ` [PATCH v3 4/8] builtin/commit-graph.c: extract 'read_one_commit()' Taylor Blau
2020-05-14 17:56 ` Jeff King
2020-05-14 18:02 ` Taylor Blau
2020-05-14 18:27 ` Junio C Hamano
2020-05-18 19:27 ` Taylor Blau
2020-05-13 21:59 ` [PATCH v3 5/8] builtin/commit-graph.c: dereference tags in builtin Taylor Blau
2020-05-14 18:01 ` Jeff King
2020-05-14 18:04 ` Taylor Blau
2020-07-10 19:02 ` [PATCH] commit-graph: fix "Collecting commits from input" progress line SZEDER Gábor
2020-07-10 19:17 ` Taylor Blau
2020-07-15 18:33 ` SZEDER Gábor
2020-07-15 18:43 ` Derrick Stolee
2020-07-15 18:58 ` Junio C Hamano
2020-05-13 21:59 ` [PATCH v3 6/8] commit-graph.c: simplify 'fill_oids_from_commits' Taylor Blau
2020-05-13 21:59 ` [PATCH v3 7/8] t5318: reorder test below 'graph_read_expect' Taylor Blau
2020-05-13 21:59 ` [PATCH v3 8/8] commit-graph: drop COMMIT_GRAPH_WRITE_CHECK_OIDS flag Taylor Blau
2020-05-14 18:09 ` Jeff King
2020-05-14 18:12 ` [PATCH v3 0/8] commit-graph: drop CHECK_OIDS, peel in callers Jeff King
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=81fb0f5e-e7e1-7541-d6c7-36828190c95b@gmail.com \
--to=stolee@gmail.com \
--cc=dstolee@microsoft.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=me@ttaylorr.com \
--cc=peff@peff.net \
--cc=szeder.dev@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.
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 NNTP newsgroup(s).