git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] var: add GIT_SEQUENCE_EDITOR variable

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 21, 2022, 08:09 UTC
Message-ID
<xmqq1qpwwwxg.fsf@gitster.g>
In-Reply-To
<pull.1424.git.1668972017089.gitgitgadget@gmail.com>
"Sean Allred via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 6 quoted lines
> From: Sean Allred <allred.sean@gmail.com>
>
> Provides the same benefits to scripts as exposing GIT_EDITOR, but
> allows distinguishing the 'sequence' editor from the 'core' editor.
>
> See also 44fcb4977cbae67f4698306ccfe982420ceebcbf.
Why should we ;-)?

If you explain why "git var GIT_SEQUENCE_EDITOR" is useful in a more direct way, you do not even have to refer to a long hexadecimal string which by itself does not mean anything to sane human beings.

    The editor program used by Git when editing the sequencer "todo"
    file is determined by examining a few environment variables and
    also affected by configuration variables.  Introduce "git var
    GIT_SEQUENCE_EDITOR" that gives users an access to the final
    result of the logic without having to know the exact detail.
    This is very similar in spirit to 44fcb497 (Teach git var about
    GIT_EDITOR, 2009-11-11) that introduced "git var GIT_EDITOR".
or something like that, perhaps?
> +GIT_SEQUENCE_EDITOR::
> +    Text editor for use by Git sequencer commands. Like `GIT_EDITOR`,

Do our readers know what "Git sequencer commands" are? "rebase -i" of course is the primary one, but "cherry-pick" and "revert" that deals with multiple commits are technically "sequencer commands", as they also use the sequencer machinery. But for them, the users do not get a chance to edit the "todo" list with their sequence editor, unlike "rebase -i".

I am wondering if it is easier to understand, without losing technical correctness, to exactly name the command, without pretending as if the sequence editor is used in situations wider than where "rebase -i" is used, e.g.

	The text editor program used to edit the 'todo' file while
	running "git rebase -i".
or something.
> +    the value is meant to be interpreted by the shell when it is used.
> +    The order of preference is the `$GIT_SEQUENCE_EDITOR` environment
> +    variable, then `sequence.editor` configuration, and then the value
> +    of `git var GIT_EDITOR`.
OK.
Show 14 quoted lines
> diff --git a/builtin/var.c b/builtin/var.c
> index 491db274292..9a2d31dc4aa 100644
> --- a/builtin/var.c
> +++ b/builtin/var.c
> @@ -19,6 +19,16 @@ static const char *editor(int flag)
>  	return pgm;
>  }
>  
> +static const char *sequence_editor(int flag)
> +{
> +	const char *pgm = git_sequence_editor();
> +
> +	if (!pgm && flag & IDENT_STRICT)
> +		die("Terminal is dumb, but EDITOR unset");

I know this was copied from editor(), but the message does not make much sense. It's not like the caller of read_var() is not prepared to see a NULL returned, so letting it return NULL would make more sense. Since the ancient past back when editor() function was written, launch_editor() and the logic to die with "on dumb terminal you must specify an EDITOR" have migrated to editor.c and there is no strong reason to keep the corresponding die() even in editor() function (I do not recommend removing it as part of this topic, though), and adding a new one makes even less sense.

Previous: Sean Allred via GitGitGadgetNext: Sean Allred
Message 2 of 4 in “var: add GIT_SEQUENCE_EDITOR variable”
  1. var: add GIT_SEQUENCE_EDITOR variableSean Allred via GitGitGadget, Nov 20, 2022
  2. Junio C HamanoNov 21, 2022
  3. Sean AllredNov 23, 2022
  4. var: add GIT_SEQUENCE_EDITOR variableSean Allred via GitGitGadget, Dec 17, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.