show-index: use gettext wrapping in user facing error messages

Multiple 'die()' calls in show-index.c use literal strings directly. Wrap all user-facing 'die()' messages with '_()' so they can be translated via gettext, this ensures better support for users. Signed-off-by: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Shreyansh Paliwal committed Jan 30, 2026 at 21:01 UTC 227e2cc4e1415c4aeadceef527dd33e478ad5ec3
1 file changed +11 -11
builtin/show-index.c
+11 -11
@@ -55,23 +55,23 @@ int cmd_show_index(int argc,
55 hashsz = the_hash_algo->rawsz;
56
57 if (fread(top_index, 2 * 4, 1, stdin) != 1)
58 - die("unable to read header");
58 + die(_("unable to read header"));
59 if (top_index[0] == htonl(PACK_IDX_SIGNATURE)) {
60 version = ntohl(top_index[1]);
61 if (version < 2 || version > 2)
62 - die("unknown index version");
62 + die(_("unknown index version"));
63 if (fread(top_index, 256 * 4, 1, stdin) != 1)
64 - die("unable to read index");
64 + die(_("unable to read index"));
65 } else {
66 version = 1;
67 if (fread(&top_index[2], 254 * 4, 1, stdin) != 1)
68 - die("unable to read index");
68 + die(_("unable to read index"));
69 }
70 nr = 0;
71 for (i = 0; i < 256; i++) {
72 unsigned n = ntohl(top_index[i]);
73 if (n < nr)
74 - die("corrupt index file");
74 + die(_("corrupt index file"));
75 nr = n;
76 }
77 if (version == 1) {
@@ -79,7 +79,7 @@ int cmd_show_index(int argc,
79 unsigned int offset, entry[(GIT_MAX_RAWSZ + 4) / sizeof(unsigned int)];
80
81 if (fread(entry, 4 + hashsz, 1, stdin) != 1)
82 - die("unable to read entry %u/%u", i, nr);
82 + die(_("unable to read entry %u/%u"), i, nr);
83 offset = ntohl(entry[0]);
84 printf("%u %s\n", offset, hash_to_hex((void *)(entry+1)));
85 }
@@ -93,15 +93,15 @@ int cmd_show_index(int argc,
93 ALLOC_ARRAY(entries, nr);
94 for (i = 0; i < nr; i++) {
95 if (fread(entries[i].oid.hash, hashsz, 1, stdin) != 1)
96 - die("unable to read sha1 %u/%u", i, nr);
96 + die(_("unable to read sha1 %u/%u"), i, nr);
97 entries[i].oid.algo = hash_algo_by_ptr(the_hash_algo);
98 }
99 for (i = 0; i < nr; i++)
100 if (fread(&entries[i].crc, 4, 1, stdin) != 1)
101 - die("unable to read crc %u/%u", i, nr);
101 + die(_("unable to read crc %u/%u"), i, nr);
102 for (i = 0; i < nr; i++)
103 if (fread(&entries[i].off, 4, 1, stdin) != 1)
104 - die("unable to read 32b offset %u/%u", i, nr);
104 + die(_("unable to read 32b offset %u/%u"), i, nr);
105 for (i = 0; i < nr; i++) {
106 uint64_t offset;
107 uint32_t off = ntohl(entries[i].off);
@@ -110,9 +110,9 @@ int cmd_show_index(int argc,
110 } else {
111 uint32_t off64[2];
112 if ((off & 0x7fffffff) != off64_nr)
113 - die("inconsistent 64b offset index");
113 + die(_("inconsistent 64b offset index"));
114 if (fread(off64, 8, 1, stdin) != 1)
115 - die("unable to read 64b offset %u", off64_nr);
115 + die(_("unable to read 64b offset %u"), off64_nr);
116 offset = (((uint64_t)ntohl(off64[0])) << 32) |
117 ntohl(off64[1]);
118 off64_nr++;