Skip to content

Commit 93b4405

Browse files
avargitster
authored andcommitted
commit-graph: improve & i18n error messages
Change the error emitted when a commit-graph file is corrupt so that we actually mention the commit-graph, e.g. change errors like: error: improper chunk offset 0000000000385e0c To: error: commit-graph improper chunk offset 0000000000385e0c As discussed in the commits leading up to this one the commit-graph machinery is now used by common commands like "status". If the graph was corrupt we'd often emit some error that gave no indication what was wrong. Now some of them are still cryptic, but they'll at least mention "commit-graph" to give the user a hint as to where to look. While I'm at it mark some of the strings that hadn't been marked for translation. It's clear from the commit history and the code that this was merely forgotten at the time, and wasn't intentional.p5 Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 43d3561 commit 93b4405

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

commit-graph.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -167,21 +167,21 @@ struct commit_graph *parse_commit_graph(void *graph_map, int fd,
167167

168168
graph_signature = get_be32(data);
169169
if (graph_signature != GRAPH_SIGNATURE) {
170-
error(_("graph signature %X does not match signature %X"),
170+
error(_("commit-graph signature %X does not match signature %X"),
171171
graph_signature, GRAPH_SIGNATURE);
172172
return NULL;
173173
}
174174

175175
graph_version = *(unsigned char*)(data + 4);
176176
if (graph_version != GRAPH_VERSION) {
177-
error(_("graph version %X does not match version %X"),
177+
error(_("commit-graph version %X does not match version %X"),
178178
graph_version, GRAPH_VERSION);
179179
return NULL;
180180
}
181181

182182
hash_version = *(unsigned char*)(data + 5);
183183
if (hash_version != oid_version()) {
184-
error(_("hash version %X does not match version %X"),
184+
error(_("commit-graph hash version %X does not match version %X"),
185185
hash_version, oid_version());
186186
return NULL;
187187
}
@@ -204,7 +204,7 @@ struct commit_graph *parse_commit_graph(void *graph_map, int fd,
204204

205205
if (data + graph_size - chunk_lookup <
206206
GRAPH_CHUNKLOOKUP_WIDTH) {
207-
error(_("chunk lookup table entry missing; graph file may be incomplete"));
207+
error(_("commit-graph chunk lookup table entry missing; file may be incomplete"));
208208
free(graph);
209209
return NULL;
210210
}
@@ -215,7 +215,7 @@ struct commit_graph *parse_commit_graph(void *graph_map, int fd,
215215
chunk_lookup += GRAPH_CHUNKLOOKUP_WIDTH;
216216

217217
if (chunk_offset > graph_size - the_hash_algo->rawsz) {
218-
error(_("improper chunk offset %08x%08x"), (uint32_t)(chunk_offset >> 32),
218+
error(_("commit-graph improper chunk offset %08x%08x"), (uint32_t)(chunk_offset >> 32),
219219
(uint32_t)chunk_offset);
220220
free(graph);
221221
return NULL;
@@ -252,7 +252,7 @@ struct commit_graph *parse_commit_graph(void *graph_map, int fd,
252252
}
253253

254254
if (chunk_repeated) {
255-
error(_("chunk id %08x appears multiple times"), chunk_id);
255+
error(_("commit-graph chunk id %08x appears multiple times"), chunk_id);
256256
free(graph);
257257
return NULL;
258258
}
@@ -1162,7 +1162,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
11621162
hashcpy(cur_oid.hash, g->chunk_oid_lookup + g->hash_len * i);
11631163

11641164
if (i && oidcmp(&prev_oid, &cur_oid) >= 0)
1165-
graph_report("commit-graph has incorrect OID order: %s then %s",
1165+
graph_report(_("commit-graph has incorrect OID order: %s then %s"),
11661166
oid_to_hex(&prev_oid),
11671167
oid_to_hex(&cur_oid));
11681168

@@ -1172,22 +1172,22 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
11721172
uint32_t fanout_value = get_be32(g->chunk_oid_fanout + cur_fanout_pos);
11731173

11741174
if (i != fanout_value)
1175-
graph_report("commit-graph has incorrect fanout value: fanout[%d] = %u != %u",
1175+
graph_report(_("commit-graph has incorrect fanout value: fanout[%d] = %u != %u"),
11761176
cur_fanout_pos, fanout_value, i);
11771177
cur_fanout_pos++;
11781178
}
11791179

11801180
graph_commit = lookup_commit(r, &cur_oid);
11811181
if (!parse_commit_in_graph_one(r, g, graph_commit))
1182-
graph_report("failed to parse %s from commit-graph",
1182+
graph_report(_("failed to parse commit %s from commit-graph"),
11831183
oid_to_hex(&cur_oid));
11841184
}
11851185

11861186
while (cur_fanout_pos < 256) {
11871187
uint32_t fanout_value = get_be32(g->chunk_oid_fanout + cur_fanout_pos);
11881188

11891189
if (g->num_commits != fanout_value)
1190-
graph_report("commit-graph has incorrect fanout value: fanout[%d] = %u != %u",
1190+
graph_report(_("commit-graph has incorrect fanout value: fanout[%d] = %u != %u"),
11911191
cur_fanout_pos, fanout_value, i);
11921192

11931193
cur_fanout_pos++;
@@ -1209,14 +1209,14 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
12091209
graph_commit = lookup_commit(r, &cur_oid);
12101210
odb_commit = (struct commit *)create_object(r, cur_oid.hash, alloc_commit_node(r));
12111211
if (parse_commit_internal(odb_commit, 0, 0)) {
1212-
graph_report("failed to parse %s from object database",
1212+
graph_report(_("failed to parse commit %s from object database for commit-graph"),
12131213
oid_to_hex(&cur_oid));
12141214
continue;
12151215
}
12161216

12171217
if (!oideq(&get_commit_tree_in_graph_one(r, g, graph_commit)->object.oid,
12181218
get_commit_tree_oid(odb_commit)))
1219-
graph_report("root tree OID for commit %s in commit-graph is %s != %s",
1219+
graph_report(_("root tree OID for commit %s in commit-graph is %s != %s"),
12201220
oid_to_hex(&cur_oid),
12211221
oid_to_hex(get_commit_tree_oid(graph_commit)),
12221222
oid_to_hex(get_commit_tree_oid(odb_commit)));
@@ -1226,13 +1226,13 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
12261226

12271227
while (graph_parents) {
12281228
if (odb_parents == NULL) {
1229-
graph_report("commit-graph parent list for commit %s is too long",
1229+
graph_report(_("commit-graph parent list for commit %s is too long"),
12301230
oid_to_hex(&cur_oid));
12311231
break;
12321232
}
12331233

12341234
if (!oideq(&graph_parents->item->object.oid, &odb_parents->item->object.oid))
1235-
graph_report("commit-graph parent for %s is %s != %s",
1235+
graph_report(_("commit-graph parent for %s is %s != %s"),
12361236
oid_to_hex(&cur_oid),
12371237
oid_to_hex(&graph_parents->item->object.oid),
12381238
oid_to_hex(&odb_parents->item->object.oid));
@@ -1245,16 +1245,16 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
12451245
}
12461246

12471247
if (odb_parents != NULL)
1248-
graph_report("commit-graph parent list for commit %s terminates early",
1248+
graph_report(_("commit-graph parent list for commit %s terminates early"),
12491249
oid_to_hex(&cur_oid));
12501250

12511251
if (!graph_commit->generation) {
12521252
if (generation_zero == GENERATION_NUMBER_EXISTS)
1253-
graph_report("commit-graph has generation number zero for commit %s, but non-zero elsewhere",
1253+
graph_report(_("commit-graph has generation number zero for commit %s, but non-zero elsewhere"),
12541254
oid_to_hex(&cur_oid));
12551255
generation_zero = GENERATION_ZERO_EXISTS;
12561256
} else if (generation_zero == GENERATION_ZERO_EXISTS)
1257-
graph_report("commit-graph has non-zero generation number for commit %s, but zero elsewhere",
1257+
graph_report(_("commit-graph has non-zero generation number for commit %s, but zero elsewhere"),
12581258
oid_to_hex(&cur_oid));
12591259

12601260
if (generation_zero == GENERATION_ZERO_EXISTS)
@@ -1269,13 +1269,13 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
12691269
max_generation--;
12701270

12711271
if (graph_commit->generation != max_generation + 1)
1272-
graph_report("commit-graph generation for commit %s is %u != %u",
1272+
graph_report(_("commit-graph generation for commit %s is %u != %u"),
12731273
oid_to_hex(&cur_oid),
12741274
graph_commit->generation,
12751275
max_generation + 1);
12761276

12771277
if (graph_commit->date != odb_commit->date)
1278-
graph_report("commit date for commit %s in commit-graph is %"PRItime" != %"PRItime,
1278+
graph_report(_("commit date for commit %s in commit-graph is %"PRItime" != %"PRItime),
12791279
oid_to_hex(&cur_oid),
12801280
graph_commit->date,
12811281
odb_commit->date);

0 commit comments

Comments
 (0)