All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kenneth Lorber <keni@his.com>
To: git@vger.kernel.org
Cc: Kenneth Lorber <keni@his.com>,
	Karthik Nayak <karthik.188@gmail.com>,
	Patrick Steinhardt <ps@pks.im>,
	Junio C Hamano <gitster@pobox.com>
Subject: [RFC PATCH 1/1] config: surface editor failure in exit code
Date: Mon, 17 Aug 2026 17:19:33 -0400	[thread overview]
Message-ID: <20260817211936.2943278-2-keni@his.com> (raw)
In-Reply-To: <20260817211936.2943278-1-keni@his.com>

Teach git config --edit to show editor failure to the
parent process.

Add 2 tests to t1300 to check editor exiting successfully
or failing.

Signed-off-by: Kenneth Lorber <keni@his.com>
---
 builtin/config.c  |  5 +++--
 t/t1300-config.sh | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/builtin/config.c b/builtin/config.c
index 0882899c3f..a166b2131e 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -1291,6 +1291,7 @@ static int cmd_config_remove_section(int argc, const char **argv, const char *pr
 static int show_editor(struct config_location_options *opts)
 {
 	char *config_file;
+	int ret;
 
 	if (!opts->source.file && !startup_info->have_repository)
 		die(_("not in a git directory"));
@@ -1313,10 +1314,10 @@ static int show_editor(struct config_location_options *opts)
 		else if (errno != EEXIST)
 			die_errno(_("cannot create configuration file %s"), config_file);
 	}
-	launch_editor(config_file, NULL, NULL);
+	ret = launch_editor(config_file, NULL, NULL);
 	free(config_file);
 
-	return 0;
+	return ret;
 }
 
 static int cmd_config_edit(int argc, const char **argv, const char *prefix,
diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index e3f8064889..9a8f852a86 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -1823,6 +1823,24 @@ test_expect_success 'command line overrides environment config' '
 	test_cmp expect actual
 '
 
+test_expect_success 'git config --edit successful exit' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	GIT_EDITOR=true &&
+	export GIT_EDITOR &&
+	git -C repo config -e &&
+	unset GIT_EDITOR
+'
+
+test_expect_success 'git config --edit failure exit' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	GIT_EDITOR=false &&
+	export GIT_EDITOR &&
+	test_must_fail git -C repo config -e &&
+	unset GIT_EDITOR
+'
+
 test_expect_success 'git config --edit works' '
 	git config -f tmp test.value no &&
 	echo test.value=yes >expect &&
-- 
2.43.0



  reply	other threads:[~2026-08-17 21:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-17 21:19 [RFC PATCH 0/1] config: surface editor failure in exit code Kenneth Lorber
2026-08-17 21:19 ` Kenneth Lorber [this message]
2026-08-18  8:42   ` [RFC PATCH 1/1] " Karthik Nayak
2026-08-19 11:17     ` Kenneth Lorber
2026-08-19 20:11     ` Junio C Hamano
2026-08-17 22:39 ` [RFC PATCH 0/1] " Junio C Hamano
2026-08-18  8:26   ` Karthik Nayak
2026-08-18 14:31     ` Junio C Hamano
2026-08-18 22:12       ` brian m. carlson
2026-08-19 15:09 ` [PATCH v2 " Kenneth Lorber
2026-08-19 15:09   ` [PATCH v2 1/1] " Kenneth Lorber
2026-08-19 15:09   ` [PATCH v2 0/1] " Kenneth Lorber
2026-08-19 15:09   ` [PATCH v2 1/1] " Kenneth Lorber
2026-08-19 17:58   ` [PATCH v2 0/1] " Junio C Hamano
2026-08-19 18:58     ` Kenneth Lorber
2026-08-19 19:24       ` Junio C Hamano

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=20260817211936.2943278-2-keni@his.com \
    --to=keni@his.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=karthik.188@gmail.com \
    --cc=ps@pks.im \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.