~herrhotzenplotz/gcli-devel

gcli: Use GIT_EDITOR and VISUAL as git(1) does v1 APPLIED

remph: 1
 Use GIT_EDITOR and VISUAL as git(1) does

 1 files changed, 13 insertions(+), 1 deletions(-)
build pending: alpine.yml
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~herrhotzenplotz/gcli-devel/patches/56576/mbox | git am -3
Learn more about email & git

[PATCH gcli] Use GIT_EDITOR and VISUAL as git(1) does Export this patch

gcli using only EDITOR can be surprising; this patch imitates git's behaviour
in checking GIT_EDITOR, VISUAL, then EDITOR in that order
---
 src/cmd/editor.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/cmd/editor.c b/src/cmd/editor.c
index 80466b9..dd98c73 100644
--- a/src/cmd/editor.c
+++ b/src/cmd/editor.c
@@ -50,10 +50,22 @@ sv_append(sn_sv this, sn_sv const that)
	return this;
}

static char *
get_env_editor(void)
{
	static char const *const env_vars[] = { "GIT_EDITOR", "VISUAL", "EDITOR", NULL };
	size_t i = 0;
	char *result = NULL;
	do
		result = getenv(env_vars[i]);
	while (!result && env_vars[++i]);
	return result;
}

static void
edit(struct gcli_ctx *ctx, char const *filename)
{
	char *editor = getenv("EDITOR");
	char *editor = get_env_editor();
	char *env_editor = editor;

	if (!editor) {
-- 
2.47.1
Content-Type: multipart/mixed; boundary="----_=_55e9418470a4e71e44f4dd10_=_"



This is a multipart message in MIME format.



------_=_55e9418470a4e71e44f4dd10_=_

Content-Type: text/plain; charset=UTF-8

Content-Disposition: inline

Content-Transfer-Encoding: quoted-printable



remph <lhr@disroot.org> wrote:
iour