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

[PATCH 2/3] repack: make parsed string options const-correct

From
Jeff King <peff@peff.net>
Date
Jan 23, 2014, 01:28 UTC
Message-ID
<20140123012830.GB19472@sigill.intra.peff.net>
In-Reply-To
<20140123012656.GC17254@sigill.intra.peff.net>

When we use OPT_STRING to parse an option, we get back a pointer into the argv array, which should be "const char *". The compiler doesn't notice because it gets passed through a "void *" in the option struct.

Signed-off-by: Jeff King <peff@peff.net>
---
Not a big deal, but just for consistency with the next patch.
 builtin/repack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/repack.c b/builtin/repack.c
index 528725b..7f89c7c 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -129,7 +129,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 	/* variables to be filled by option parsing */
 	int pack_everything = 0;
 	int delete_redundant = 0;
-	char *unpack_unreachable = NULL;
+	const char *unpack_unreachable = NULL;
 	int window = 0, window_memory = 0;
 	int depth = 0;
 	int max_pack_size = 0;
-- 
1.8.5.2.500.g8060133
Previous: Jeff KingNext: Jeff King
Message 10 of 14 in “git repack --max-pack-size broken in git-next”
  1. Siddharth AgarwalJan 21, 2014
  2. Junio C HamanoJan 21, 2014
  3. Junio C HamanoJan 21, 2014
  4. 0/2 Fix "repack --window-memory=4g" regression in 1.8.4Junio C Hamano, Jan 22, 2014
  5. 1/2 parse-options: refactor human-friendly-integer parser out of pack-objectsJunio C Hamano, Jan 22, 2014
  6. 2/2 repack: accept larger window-memory and max-pack-sizeJunio C Hamano, Jan 22, 2014
  7. Jeff KingJan 23, 2014
  8. Jeff KingJan 23, 2014
  9. 1/3 repack: fix typo in max-pack-size optionJeff King, Jan 23, 2014
  10. 2/3 repack: make parsed string options const-correctJeff King, Jan 23, 2014
  11. 3/3 repack: propagate pack-objects options as stringsJeff King, Jan 23, 2014
  12. Jeff KingJan 23, 2014
  13. Junio C HamanoJan 23, 2014
  14. Stefan BellerJan 22, 2014

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.