[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
Thank you very much for this patch!
I applied it and also updated the manual page `gcli(1)` as well as
the changelog.
Nico
------_=_55e9418470a4e71e44f4dd10_=_--
---
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