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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Mar 25, 2019 at 13:08 UTC 93b4405ffe4ad9308740e7c1c71383bfc369baaa
1 file changed +19 -19
commit-graph.c
+19 -19
@@ -167,21 +167,21 @@ struct commit_graph *parse_commit_graph(void *graph_map, int fd,
167
168 graph_signature = get_be32(data);
169 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"),
171 graph_signature, GRAPH_SIGNATURE);
172 return NULL;
173 }
174
175 graph_version = *(unsigned char*)(data + 4);
176 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"),
178 graph_version, GRAPH_VERSION);
179 return NULL;
180 }
181
182 hash_version = *(unsigned char*)(data + 5);
183 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"),
185 hash_version, oid_version());
186 return NULL;
187 }
@@ -204,7 +204,7 @@ struct commit_graph *parse_commit_graph(void *graph_map, int fd,
204
205 if (data + graph_size - chunk_lookup <
206 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"));
208 free(graph);
209 return NULL;
210 }
@@ -215,7 +215,7 @@ struct commit_graph *parse_commit_graph(void *graph_map, int fd,
215 chunk_lookup += GRAPH_CHUNKLOOKUP_WIDTH;
216
217 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),
219 (uint32_t)chunk_offset);
220 free(graph);
221 return NULL;
@@ -252,7 +252,7 @@ struct commit_graph *parse_commit_graph(void *graph_map, int fd,
252 }
253
254 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);
256 free(graph);
257 return NULL;
258 }
@@ -1162,7 +1162,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
1162 hashcpy(cur_oid.hash, g->chunk_oid_lookup + g->hash_len * i);
1163
1164 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"),
1166 oid_to_hex(&prev_oid),
1167 oid_to_hex(&cur_oid));
1168
@@ -1172,14 +1172,14 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
1172 uint32_t fanout_value = get_be32(g->chunk_oid_fanout + cur_fanout_pos);
1173
1174 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"),
1176 cur_fanout_pos, fanout_value, i);
1177 cur_fanout_pos++;
1178 }
1179
1180 graph_commit = lookup_commit(r, &cur_oid);
1181 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"),
1183 oid_to_hex(&cur_oid));
1184 }
1185
@@ -1187,7 +1187,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
1187 uint32_t fanout_value = get_be32(g->chunk_oid_fanout + cur_fanout_pos);
1188
1189 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"),
1191 cur_fanout_pos, fanout_value, i);
1192
1193 cur_fanout_pos++;
@@ -1209,14 +1209,14 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
1209 graph_commit = lookup_commit(r, &cur_oid);
1210 odb_commit = (struct commit *)create_object(r, cur_oid.hash, alloc_commit_node(r));
1211 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"),
1213 oid_to_hex(&cur_oid));
1214 continue;
1215 }
1216
1217 if (!oideq(&get_commit_tree_in_graph_one(r, g, graph_commit)->object.oid,
1218 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"),
1220 oid_to_hex(&cur_oid),
1221 oid_to_hex(get_commit_tree_oid(graph_commit)),
1222 oid_to_hex(get_commit_tree_oid(odb_commit)));
@@ -1226,13 +1226,13 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
1226
1227 while (graph_parents) {
1228 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"),
1230 oid_to_hex(&cur_oid));
1231 break;
1232 }
1233
1234 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"),
1236 oid_to_hex(&cur_oid),
1237 oid_to_hex(&graph_parents->item->object.oid),
1238 oid_to_hex(&odb_parents->item->object.oid));
@@ -1245,16 +1245,16 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
1245 }
1246
1247 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"),
1249 oid_to_hex(&cur_oid));
1250
1251 if (!graph_commit->generation) {
1252 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"),
1254 oid_to_hex(&cur_oid));
1255 generation_zero = GENERATION_ZERO_EXISTS;
1256 } 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"),
1258 oid_to_hex(&cur_oid));
1259
1260 if (generation_zero == GENERATION_ZERO_EXISTS)
@@ -1269,13 +1269,13 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
1269 max_generation--;
1270
1271 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"),
1273 oid_to_hex(&cur_oid),
1274 graph_commit->generation,
1275 max_generation + 1);
1276
1277 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),
1279 oid_to_hex(&cur_oid),
1280 graph_commit->date,
1281 odb_commit->date);