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

[PATCH] builtin-tag.c: allow arguments in $EDITOR

From
LRLuciano Rocha <luciano@eurotux.com>
Date
Dec 19, 2007, 23:23 UTC
Message-ID
<20071219232326.GA4135@bit.office.eurotux.com>

The previous sh version of git-commit evaluated the value of the defined editor, thus allowing arguments.

Make the builtin version work the same, by adding an explicit check for arguments in the editor command, and extract them to an additional argument.

Signed-off-by: Luciano Rocha <luciano@eurotux.com>
---
 builtin-tag.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
I personally use EDITOR="gvim -f", thus this patch.

Created on top of ce85b053d827e2f7c2ee2683cc09393e4768cc22, git-describe is now: v1.5.4-rc0-75-g5f791e5

diff --git a/builtin-tag.c b/builtin-tag.c
index 274901a..57dcfe0 100644
--- a/builtin-tag.c
+++ b/builtin-tag.c
@@ -46,7 +46,18 @@ void launch_editor(const char *path, struct strbuf *buffer, const char *const *e
 	if (!editor)
 		editor = "vi";
 
-	if (strcmp(editor, ":")) {
+	if (strstr(editor, " -")) {
+		char *editor_cmd = xstrdup(editor);
+		char *editor_sep = strstr(editor_cmd, " -");
+		const char *args[] = { editor_cmd, editor_sep + 1,
+			path, NULL };
+
+		*editor_sep = '\0';
+
+		if (run_command_v_opt_cd_env(args, 0, NULL, env))
+			die("There was a problem with the editor %s.",
+					editor_cmd);
+	} else if (strcmp(editor, ":")) {
 		const char *args[] = { editor, path, NULL };
 
 		if (run_command_v_opt_cd_env(args, 0, NULL, env))
-- 
Luciano Rocha <luciano@eurotux.com>
Eurotux Informática, S.A. <http://www.eurotux.com/>
Next: Luciano Rocha
Message 1 of 7 in “builtin-tag.c: allow arguments in $EDITOR”
  1. builtin-tag.c: allow arguments in $EDITORLuciano Rocha, Dec 19, 2007
  2. builtin-tag.c: allow arguments in $EDITORLuciano Rocha, Dec 20, 2007
  3. Johannes SchindelinDec 20, 2007
  4. Luciano RochaDec 20, 2007
  5. Junio C HamanoDec 20, 2007
  6. Steven GrimmDec 21, 2007
  7. Johannes SchindelinDec 22, 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.