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

[PATCH] diff: trivial fix for --output file error message

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
Sep 29, 2010, 07:26 UTC
Message-ID
<1285745183-7809-1-git-send-email-Matthieu.Moy@imag.fr>

Since we use parse_long_opt(), the option argument is either after --output=... or in the next command-line argument. optarg is the reliable way to access it.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---

On my system, it seems --output file works, probably because the argument array is stored as "--output\0file", but we should definitely not rely on that ...

 diff.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/diff.c b/diff.c
index 276e029..38f5f9c 100644
--- a/diff.c
+++ b/diff.c
@@ -3315,7 +3315,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
 	else if ((argcount = parse_long_opt("output", av, &optarg))) {
 		options->file = fopen(optarg, "w");
 		if (!options->file)
-			die_errno("Could not open '%s'", arg + strlen("--output="));
+			die_errno("Could not open '%s'", optarg);
 		options->close_file = 1;
 		return argcount;
 	} else
-- 
1.7.3.2.g257b5f
Message 1 of 1 in “diff: trivial fix for --output file error message”
  1. diff: trivial fix for --output file error messageMatthieu Moy, Sep 29, 2010

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.