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

[PATCH] builtin-fmt-merge-msg: fix bugs in --file option

From
MCMichael Coleman <tutufan@gmail.com>
Date
Feb 28, 2007, 05:44 UTC
Message-ID
<1172641482207-git-send-email-tutufan@gmail.com>
If --file's argument is missing, don't crash.  If it cannot be opened,
die with an error message.
---
 builtin-fmt-merge-msg.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/builtin-fmt-merge-msg.c b/builtin-fmt-merge-msg.c
index 1489883..5c145d2 100644
--- a/builtin-fmt-merge-msg.c
+++ b/builtin-fmt-merge-msg.c
@@ -259,13 +259,15 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
 		else if (!strcmp(argv[1], "--no-summary"))
 			merge_summary = 0;
 		else if (!strcmp(argv[1], "-F") || !strcmp(argv[1], "--file")) {
-			if (argc < 2)
+			if (argc < 3)
 				die ("Which file?");
 			if (!strcmp(argv[2], "-"))
 				in = stdin;
 			else {
 				fclose(in);
 				in = fopen(argv[2], "r");
+				if (!in)
+					die("cannot open %s", argv[2]);
 			}
 			argc--; argv++;
 		} else
-- 
1.5.0.rc3
Message 1 of 1 in “builtin-fmt-merge-msg: fix bugs in --file option”
  1. builtin-fmt-merge-msg: fix bugs in --file optionMichael Coleman, Feb 28, 2007

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.