git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH V2 2/2] show-index: use gettext wrapping in user facing error messages

From
Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
Date
Jan 30, 2026, 15:31 UTC
Message-ID
<20260130153603.290196-3-shreyanshpaliwalcmsmn@gmail.com>
In-Reply-To
<20260130153603.290196-1-shreyanshpaliwalcmsmn@gmail.com>
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>
---
 builtin/show-index.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/builtin/show-index.c b/builtin/show-index.c
index 45795da2da..24f0230967 100644
--- a/builtin/show-index.c
+++ b/builtin/show-index.c
@@ -55,23 +55,23 @@ int cmd_show_index(int argc,
 	hashsz = the_hash_algo->rawsz;
 
 	if (fread(top_index, 2 * 4, 1, stdin) != 1)
-		die("unable to read header");
+		die(_("unable to read header"));
 	if (top_index[0] == htonl(PACK_IDX_SIGNATURE)) {
 		version = ntohl(top_index[1]);
 		if (version < 2 || version > 2)
-			die("unknown index version");
+			die(_("unknown index version"));
 		if (fread(top_index, 256 * 4, 1, stdin) != 1)
-			die("unable to read index");
+			die(_("unable to read index"));
 	} else {
 		version = 1;
 		if (fread(&top_index[2], 254 * 4, 1, stdin) != 1)
-			die("unable to read index");
+			die(_("unable to read index"));
 	}
 	nr = 0;
 	for (i = 0; i < 256; i++) {
 		unsigned n = ntohl(top_index[i]);
 		if (n < nr)
-			die("corrupt index file");
+			die(_("corrupt index file"));
 		nr = n;
 	}
 	if (version == 1) {
@@ -79,7 +79,7 @@ int cmd_show_index(int argc,
 			unsigned int offset, entry[(GIT_MAX_RAWSZ + 4) / sizeof(unsigned int)];
 
 			if (fread(entry, 4 + hashsz, 1, stdin) != 1)
-				die("unable to read entry %u/%u", i, nr);
+				die(_("unable to read entry %u/%u"), i, nr);
 			offset = ntohl(entry[0]);
 			printf("%u %s\n", offset, hash_to_hex((void *)(entry+1)));
 		}
@@ -93,15 +93,15 @@ int cmd_show_index(int argc,
 		ALLOC_ARRAY(entries, nr);
 		for (i = 0; i < nr; i++) {
 			if (fread(entries[i].oid.hash, hashsz, 1, stdin) != 1)
-				die("unable to read sha1 %u/%u", i, nr);
+				die(_("unable to read sha1 %u/%u"), i, nr);
 			entries[i].oid.algo = hash_algo_by_ptr(the_hash_algo);
 		}
 		for (i = 0; i < nr; i++)
 			if (fread(&entries[i].crc, 4, 1, stdin) != 1)
-				die("unable to read crc %u/%u", i, nr);
+				die(_("unable to read crc %u/%u"), i, nr);
 		for (i = 0; i < nr; i++)
 			if (fread(&entries[i].off, 4, 1, stdin) != 1)
-				die("unable to read 32b offset %u/%u", i, nr);
+				die(_("unable to read 32b offset %u/%u"), i, nr);
 		for (i = 0; i < nr; i++) {
 			uint64_t offset;
 			uint32_t off = ntohl(entries[i].off);
@@ -110,9 +110,9 @@ int cmd_show_index(int argc,
 			} else {
 				uint32_t off64[2];
 				if ((off & 0x7fffffff) != off64_nr)
-					die("inconsistent 64b offset index");
+					die(_("inconsistent 64b offset index"));
 				if (fread(off64, 8, 1, stdin) != 1)
-					die("unable to read 64b offset %u", off64_nr);
+					die(_("unable to read 64b offset %u"), off64_nr);
 				offset = (((uint64_t)ntohl(off64[0])) << 32) |
 						     ntohl(off64[1]);
 				off64_nr++;
-- 
2.52.0
Previous: Shreyansh PaliwalNext: Junio C Hamano
Message 24 of 25 in “show-index: modernize and implement auto-detection of hash algorithm”
  1. Shreyansh PaliwalJan 20, 2026
  2. 1/3 show-index: implement automatic hash detectionShreyansh Paliwal, Jan 20, 2026
  3. Junio C HamanoJan 20, 2026
  4. Patrick SteinhardtJan 21, 2026
  5. Shreyansh PaliwalJan 21, 2026
  6. Patrick SteinhardtJan 23, 2026
  7. Shreyansh PaliwalJan 23, 2026
  8. brian m. carlsonJan 23, 2026
  9. Shreyansh PaliwalJan 21, 2026
  10. 2/3 show-index: use gettext wrapping in error messagesShreyansh Paliwal, Jan 20, 2026
  11. 3/3 show-index: remove global state variablesShreyansh Paliwal, Jan 20, 2026
  12. Phillip WoodJan 21, 2026
  13. Shreyansh PaliwalJan 21, 2026
  14. Junio C HamanoJan 21, 2026
  15. show-index: warn when falling back to SHA-1 outside a repositoryShreyansh Paliwal, Jan 29, 2026
  16. Junio C HamanoJan 29, 2026
  17. Shreyansh PaliwalJan 30, 2026
  18. brian m. carlsonJan 29, 2026
  19. Shreyansh PaliwalJan 30, 2026
  20. Patrick SteinhardtJan 30, 2026
  21. Junio C HamanoJan 30, 2026
  22. 0/2 show-index: add warning and wrap error messages with gettextShreyansh Paliwal, Jan 30, 2026
  23. 1/2 show-index: warn when falling back to SHA-1 outside a repositoryShreyansh Paliwal, Jan 30, 2026
  24. 2/2 show-index: use gettext wrapping in user facing error messagesShreyansh Paliwal, Jan 30, 2026
  25. Junio C HamanoJan 30, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.