Git development
 help / color / mirror / Atom feed
From: Kenneth Lorber <keni@his.com>
To: git@vger.kernel.org
Cc: Kenneth Lorber <keni@his.com>, Patrick Steinhardt <ps@pks.im>,
	Junio C Hamano <gitster@pobox.com>,
	Karthik Nayak <karthik.188@gmail.com>
Subject: [PATCH v2 1/1] config: surface editor failure in exit code
Date: Wed, 19 Aug 2026 11:09:20 -0400	[thread overview]
Message-ID: <20260819150922.2984850-4-keni@his.com> (raw)
In-Reply-To: <20260819150922.2984850-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 | 12 ++++++++++++
 2 files changed, 15 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..3e218079ee 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -1823,6 +1823,18 @@ test_expect_success 'command line overrides environment config' '
 	test_cmp expect actual
 '
 
+test_expect_success 'git config -e successful exit' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	test_env GIT_EDITOR=true git -C repo config -e
+'
+
+test_expect_success 'git config -e failure exit' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	test_env GIT_EDITOR=false test_must_fail git -C repo config -e
+'
+
 test_expect_success 'git config --edit works' '
 	git config -f tmp test.value no &&
 	echo test.value=yes >expect &&
-- 
2.43.0



  parent reply	other threads:[~2026-08-19 15:11 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 ` [RFC PATCH 1/1] " Kenneth Lorber
2026-08-18  8:42   ` 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   ` Kenneth Lorber [this message]
2026-08-19 17:58   ` 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=20260819150922.2984850-4-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox