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

[PATCH] ls-files: make option parser keep argv[0]

From
Ben Walton <bwalton@artsci.utoronto.ca>
Date
Oct 8, 2009, 14:20 UTC
Message-ID
<1255011628-31841-1-git-send-email-bwalton@artsci.utoronto.ca>

The ls-files built-in was not asking the option parser to maintain argv[0]. This led to the possibility of fprintf(stderr, "...", NULL). On Solaris, this was causing a segfault. On glibc systems, printed error messages didn't contain proper strings, but rather, "(null)":...

A trigger for this bug was: `git ls-files -i`
Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>
---
 builtin-ls-files.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index f473220..9a3705a 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
@@ -482,7 +482,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
 	git_config(git_default_config, NULL);
 
 	argc = parse_options(argc, argv, prefix, builtin_ls_files_options,
-			ls_files_usage, 0);
+			ls_files_usage, PARSE_OPT_KEEP_ARGV0);
 	if (show_tag || show_valid_bit) {
 		tag_cached = "H ";
 		tag_unmerged = "M ";
@@ -505,7 +505,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
 	if (require_work_tree && !is_inside_work_tree())
 		setup_work_tree();
 
-	pathspec = get_pathspec(prefix, argv);
+	pathspec = get_pathspec(prefix, argv + 1);
 
 	/* be nice with submodule paths ending in a slash */
 	read_cache();
-- 
1.6.4.4
Next: Stephen Boyd
Message 1 of 4 in “ls-files: make option parser keep argv[0]”
  1. ls-files: make option parser keep argv[0]Ben Walton, Oct 8, 2009
  2. Stephen BoydOct 8, 2009
  3. ls-files: die instead of fprintf/exit in -i errorBen Walton, Oct 9, 2009
  4. Junio C HamanoOct 9, 2009

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.