git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/1] commit-graph: improve error messages
@ 2019-04-26 11:48 Derrick Stolee via GitGitGadget
  2019-04-26 11:48 ` [PATCH 1/1] " Derrick Stolee via GitGitGadget
  0 siblings, 1 reply; 3+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2019-04-26 11:48 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

Here is a small patch that revises the error messages from
ab/commit-graph-fixes, as recommended by Ævar. Hopefully, it can be merged
faster than the commit-graph v2 stuff, and I can update that series to
include this change if we agree it is a good one.

Thanks, -Stolee

Cc: avarab@gmail.com

In-Reply-To: 878svxrwsh.fsf@evledraar.gmail.com
[878svxrwsh.fsf@evledraar.gmail.com]

Derrick Stolee (1):
  commit-graph: improve error messages

 commit-graph.c          | 10 +++++-----
 t/t5318-commit-graph.sh |  6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)


base-commit: 93b4405ffe4ad9308740e7c1c71383bfc369baaa
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-181%2Fderrickstolee%2Fgraph%2Fmessage-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-181/derrickstolee/graph/message-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/181
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] commit-graph: improve error messages
  2019-04-26 11:48 [PATCH 0/1] commit-graph: improve error messages Derrick Stolee via GitGitGadget
@ 2019-04-26 11:48 ` Derrick Stolee via GitGitGadget
  2019-04-26 12:33   ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 3+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2019-04-26 11:48 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Derrick Stolee

From: Derrick Stolee <dstolee@microsoft.com>

The error messages when reading a commit-graph have a few problems:

1. Some values are output in hexadecimal, but that is not made
   clear by the message. Prepend "0x" to these values.

2. The version number does not need to be hexadecimal, and also
   should mention a "maximum supported version". This has one
   possible confusing case: we could have a corrupt commit-graph
   file with version number zero, so the output would be

   "commit-graph has version 0, our maximum supported version is 1"

   This will only happen with corrupt data. This error message is
   designed instead for the case where a client is downgraded after
   writing a newer file version.

Update t5318-commit-graph.sh to watch for these new error messages.

Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
 commit-graph.c          | 10 +++++-----
 t/t5318-commit-graph.sh |  6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/commit-graph.c b/commit-graph.c
index 66865acbd7..aba591913e 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -167,21 +167,21 @@ struct commit_graph *parse_commit_graph(void *graph_map, int fd,
 
 	graph_signature = get_be32(data);
 	if (graph_signature != GRAPH_SIGNATURE) {
-		error(_("commit-graph signature %X does not match signature %X"),
+		error(_("commit-graph signature 0x%X does not match signature 0x%X"),
 		      graph_signature, GRAPH_SIGNATURE);
 		return NULL;
 	}
 
 	graph_version = *(unsigned char*)(data + 4);
 	if (graph_version != GRAPH_VERSION) {
-		error(_("commit-graph version %X does not match version %X"),
+		error(_("commit-graph has version %d, our maximum supported version is %d"),
 		      graph_version, GRAPH_VERSION);
 		return NULL;
 	}
 
 	hash_version = *(unsigned char*)(data + 5);
 	if (hash_version != oid_version()) {
-		error(_("commit-graph hash version %X does not match version %X"),
+		error(_("commit-graph has hash version %d, our maximum supported version is %d"),
 		      hash_version, oid_version());
 		return NULL;
 	}
@@ -215,7 +215,7 @@ struct commit_graph *parse_commit_graph(void *graph_map, int fd,
 		chunk_lookup += GRAPH_CHUNKLOOKUP_WIDTH;
 
 		if (chunk_offset > graph_size - the_hash_algo->rawsz) {
-			error(_("commit-graph improper chunk offset %08x%08x"), (uint32_t)(chunk_offset >> 32),
+			error(_("commit-graph improper chunk offset 0x%08x%08x"), (uint32_t)(chunk_offset >> 32),
 			      (uint32_t)chunk_offset);
 			free(graph);
 			return NULL;
@@ -252,7 +252,7 @@ struct commit_graph *parse_commit_graph(void *graph_map, int fd,
 		}
 
 		if (chunk_repeated) {
-			error(_("commit-graph chunk id %08x appears multiple times"), chunk_id);
+			error(_("commit-graph chunk id 0x%08x appears multiple times"), chunk_id);
 			free(graph);
 			return NULL;
 		}
diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
index e80c1cac02..264ebb15b1 100755
--- a/t/t5318-commit-graph.sh
+++ b/t/t5318-commit-graph.sh
@@ -420,17 +420,17 @@ test_expect_success 'detect too small' '
 
 test_expect_success 'detect bad signature' '
 	corrupt_graph_and_verify 0 "\0" \
-		"graph signature"
+		"commit-graph signature"
 '
 
 test_expect_success 'detect bad version' '
 	corrupt_graph_and_verify $GRAPH_BYTE_VERSION "\02" \
-		"graph version"
+		"commit-graph has version"
 '
 
 test_expect_success 'detect bad hash version' '
 	corrupt_graph_and_verify $GRAPH_BYTE_HASH "\02" \
-		"hash version"
+		"commit-graph has hash version"
 '
 
 test_expect_success 'detect low chunk count' '
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] commit-graph: improve error messages
  2019-04-26 11:48 ` [PATCH 1/1] " Derrick Stolee via GitGitGadget
@ 2019-04-26 12:33   ` Ævar Arnfjörð Bjarmason
  0 siblings, 0 replies; 3+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2019-04-26 12:33 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget; +Cc: git, Junio C Hamano, Derrick Stolee


On Fri, Apr 26 2019, Derrick Stolee via GitGitGadget wrote:

> The error messages when reading a commit-graph have a few problems:
>
> 1. Some values are output in hexadecimal, but that is not made
>    clear by the message. Prepend "0x" to these values.
>
> 2. The version number does not need to be hexadecimal, and also
>    should mention a "maximum supported version". This has one
>    possible confusing case: we could have a corrupt commit-graph
>    file with version number zero, so the output would be
>
>    "commit-graph has version 0, our maximum supported version is 1"
>
>    This will only happen with corrupt data. This error message is
>    designed instead for the case where a client is downgraded after
>    writing a newer file version.

This looks good to me and is obviously correct:

> Update t5318-commit-graph.sh to watch for these new error messages.
> [...]
> diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
> index e80c1cac02..264ebb15b1 100755
> --- a/t/t5318-commit-graph.sh
> +++ b/t/t5318-commit-graph.sh
> @@ -420,17 +420,17 @@ test_expect_success 'detect too small' '
>
>  test_expect_success 'detect bad signature' '
>  	corrupt_graph_and_verify 0 "\0" \
> -		"graph signature"
> +		"commit-graph signature"
>  '
>
>  test_expect_success 'detect bad version' '
>  	corrupt_graph_and_verify $GRAPH_BYTE_VERSION "\02" \
> -		"graph version"
> +		"commit-graph has version"
>  '
>
>  test_expect_success 'detect bad hash version' '
>  	corrupt_graph_and_verify $GRAPH_BYTE_HASH "\02" \
> -		"hash version"
> +		"commit-graph has hash version"
>  '
>
>  test_expect_success 'detect low chunk count' '

Just a small nit/OCD :).

The only change to that test code that's actually needed is just doing:

    -               "graph version"
    +               "graph has version"

The rest were already grepping subsets of the message before/after, and
maybe worth it to keep it consistent that all these
"corrupt_graph_and_verify" invocations grep the part of the message that
isn't the "commit-graph <whatever>", i.e. now with just that change:

    $ git grep -h -A1 corrupt_graph_and_verify|grep -o '".*"$'
    "graph signature"
    "graph has version"
    "hash version"
    "missing the .* chunk"
    "missing the OID Fanout chunk"
    "missing the OID Lookup chunk"
    "missing the Commit Data chunk"
    "fanout value"
    "fanout value"
    "incorrect OID order"
    "from object database"
    "root tree OID for commit"
    "invalid parent"
    "is too long"
    "commit-graph parent for"
    "generation for commit"
    "non-zero generation number"
    "commit date"
    "invalid parent"
    "incorrect checksum"

Well, there's the sore thumb of "commit-graph parent for".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-26 12:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-26 11:48 [PATCH 0/1] commit-graph: improve error messages Derrick Stolee via GitGitGadget
2019-04-26 11:48 ` [PATCH 1/1] " Derrick Stolee via GitGitGadget
2019-04-26 12:33   ` Ævar Arnfjörð Bjarmason

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).