git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pierre Habouzit <madcoder@debian.org>
To: "Jan Hudec" <bulb@ucw.cz>, "Git ML" <git@vger.kernel.org>,
	"Kristian Høgsberg" <krh@redhat.com>,
	"Junio C Hamano" <gitster@pobox.com>
Subject: [PATCH] Make builtin-commit.c export GIT_INDEX_FILE for launch_editor as well.
Date: Mon, 26 Nov 2007 09:59:27 +0100	[thread overview]
Message-ID: <20071126085927.GC23373@artemis.corp> (raw)
In-Reply-To: <20071126084731.GB23373@artemis.corp>

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

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---

  And here's the fix for this tiny problem …



 builtin-commit.c |    9 ++++++---
 builtin-tag.c    |    6 +++---
 strbuf.h         |    2 +-
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/builtin-commit.c b/builtin-commit.c
index 5d27102..6e6b9f2 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -748,9 +748,12 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 
 	/* Get the commit message and validate it */
 	header_len = sb.len;
-	if (!no_edit)
-		launch_editor(git_path(commit_editmsg), &sb);
-	else if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) {
+	if (!no_edit) {
+		char index[PATH_MAX];
+		const char *env[2] = { index, NULL };
+		snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
+		launch_editor(git_path(commit_editmsg), &sb, env);
+	} else if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) {
 		rollback_index_files();
 		die("could not read commit message\n");
 	}
diff --git a/builtin-tag.c b/builtin-tag.c
index e89b201..8cc7f9c 100644
--- a/builtin-tag.c
+++ b/builtin-tag.c
@@ -23,7 +23,7 @@ static const char * const git_tag_usage[] = {
 
 static char signingkey[1000];
 
-void launch_editor(const char *path, struct strbuf *buffer)
+void launch_editor(const char *path, struct strbuf *buffer, const char *const *env)
 {
 	const char *editor, *terminal;
 
@@ -49,7 +49,7 @@ void launch_editor(const char *path, struct strbuf *buffer)
 	if (strcmp(editor, ":")) {
 		const char *args[] = { editor, path, NULL };
 
-		if (run_command_v_opt(args, 0))
+		if (run_command_v_opt_cd_env(args, 0, NULL, env))
 			die("There was a problem with the editor %s.", editor);
 	}
 
@@ -318,7 +318,7 @@ static void create_tag(const unsigned char *object, const char *tag,
 			write_or_die(fd, tag_template, strlen(tag_template));
 		close(fd);
 
-		launch_editor(path, buf);
+		launch_editor(path, buf, NULL);
 
 		unlink(path);
 		free(path);
diff --git a/strbuf.h b/strbuf.h
index 8334a9b..36d61db 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -117,6 +117,6 @@ extern int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint);
 extern int strbuf_getline(struct strbuf *, FILE *, int);
 
 extern void stripspace(struct strbuf *buf, int skip_comments);
-extern void launch_editor(const char *path, struct strbuf *buffer);
+extern void launch_editor(const char *path, struct strbuf *buffer, const char *const *env);
 
 #endif /* STRBUF_H */
-- 
1.5.3.6.2015.g9baba-dirty


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

  reply	other threads:[~2007-11-26  8:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-25 21:18 [RFC] best way to show diff of commit Pierre Habouzit
2007-11-25 21:27 ` J. Bruce Fields
2007-11-25 22:09   ` Pierre Habouzit
2007-11-25 22:27     ` Junio C Hamano
2007-11-25 22:31       ` Pierre Habouzit
2007-11-25 22:52         ` Junio C Hamano
2007-11-25 23:47           ` Pierre Habouzit
2007-11-25 23:43       ` David Brown
2007-11-26  0:25 ` Jan Hudec
2007-11-26  8:42   ` Pierre Habouzit
2007-11-26  8:47   ` Pierre Habouzit
2007-11-26  8:59     ` Pierre Habouzit [this message]
2007-11-26  9:38       ` [PATCH] Make builtin-commit.c export GIT_INDEX_FILE for launch_editor as well Pierre Habouzit
2007-11-26 15:27       ` Kristian Høgsberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071126085927.GC23373@artemis.corp \
    --to=madcoder@debian.org \
    --cc=bulb@ucw.cz \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=krh@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).