git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] builtin-tag.c: allow arguments in $EDITOR
@ 2007-12-19 23:23 Luciano Rocha
  2007-12-20  9:57 ` [PATCH v2] " Luciano Rocha
  0 siblings, 1 reply; 7+ messages in thread
From: Luciano Rocha @ 2007-12-19 23:23 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 1449 bytes --]

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/>

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-12-22 14:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-19 23:23 [PATCH] builtin-tag.c: allow arguments in $EDITOR Luciano Rocha
2007-12-20  9:57 ` [PATCH v2] " Luciano Rocha
2007-12-20 11:58   ` Johannes Schindelin
2007-12-20 12:06     ` Luciano Rocha
2007-12-20 22:14     ` Junio C Hamano
2007-12-21  0:33       ` Steven Grimm
2007-12-22 14:50       ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).