var: add GIT_SEQUENCE_EDITOR variable
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" to give users access to the final result of the
logic without having to know the exact details.
This is very similar in spirit to 44fcb497
(Teach git var about
GIT_EDITOR, 2009-11-11) that introduced "git var GIT_EDITOR".
Signed-off-by: Sean Allred <allred.sean@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
57e2c6ebbe
commit
4c3dd9304e
@ -50,6 +50,14 @@ ifdef::git-default-editor[]
|
|||||||
The build you are using chose '{git-default-editor}' as the default.
|
The build you are using chose '{git-default-editor}' as the default.
|
||||||
endif::git-default-editor[]
|
endif::git-default-editor[]
|
||||||
|
|
||||||
|
GIT_SEQUENCE_EDITOR::
|
||||||
|
Text editor used to edit the 'todo' file while running `git rebase
|
||||||
|
-i`. Like `GIT_EDITOR`, 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`.
|
||||||
|
|
||||||
GIT_PAGER::
|
GIT_PAGER::
|
||||||
Text viewer for use by Git commands (e.g., 'less'). The value
|
Text viewer for use by Git commands (e.g., 'less'). The value
|
||||||
is meant to be interpreted by the shell. The order of preference
|
is meant to be interpreted by the shell. The order of preference
|
||||||
|
@ -14,6 +14,11 @@ static const char *editor(int flag)
|
|||||||
return git_editor();
|
return git_editor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *sequence_editor(int flag)
|
||||||
|
{
|
||||||
|
return git_sequence_editor();
|
||||||
|
}
|
||||||
|
|
||||||
static const char *pager(int flag)
|
static const char *pager(int flag)
|
||||||
{
|
{
|
||||||
const char *pgm = git_pager(1);
|
const char *pgm = git_pager(1);
|
||||||
@ -36,6 +41,7 @@ static struct git_var git_vars[] = {
|
|||||||
{ "GIT_COMMITTER_IDENT", git_committer_info },
|
{ "GIT_COMMITTER_IDENT", git_committer_info },
|
||||||
{ "GIT_AUTHOR_IDENT", git_author_info },
|
{ "GIT_AUTHOR_IDENT", git_author_info },
|
||||||
{ "GIT_EDITOR", editor },
|
{ "GIT_EDITOR", editor },
|
||||||
|
{ "GIT_SEQUENCE_EDITOR", sequence_editor },
|
||||||
{ "GIT_PAGER", pager },
|
{ "GIT_PAGER", pager },
|
||||||
{ "GIT_DEFAULT_BRANCH", default_branch },
|
{ "GIT_DEFAULT_BRANCH", default_branch },
|
||||||
{ "", NULL },
|
{ "", NULL },
|
||||||
|
@ -109,6 +109,44 @@ test_expect_success 'get GIT_EDITOR with configuration and environment variable
|
|||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'get GIT_SEQUENCE_EDITOR without configuration' '
|
||||||
|
(
|
||||||
|
sane_unset GIT_SEQUENCE_EDITOR &&
|
||||||
|
git var GIT_EDITOR >expect &&
|
||||||
|
git var GIT_SEQUENCE_EDITOR >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'get GIT_SEQUENCE_EDITOR with configuration' '
|
||||||
|
test_config sequence.editor foo &&
|
||||||
|
(
|
||||||
|
sane_unset GIT_SEQUENCE_EDITOR &&
|
||||||
|
echo foo >expect &&
|
||||||
|
git var GIT_SEQUENCE_EDITOR >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'get GIT_SEQUENCE_EDITOR with environment variable' '
|
||||||
|
(
|
||||||
|
sane_unset GIT_SEQUENCE_EDITOR &&
|
||||||
|
echo bar >expect &&
|
||||||
|
GIT_SEQUENCE_EDITOR=bar git var GIT_SEQUENCE_EDITOR >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'get GIT_SEQUENCE_EDITOR with configuration and environment variable' '
|
||||||
|
test_config sequence.editor foo &&
|
||||||
|
(
|
||||||
|
sane_unset GIT_SEQUENCE_EDITOR &&
|
||||||
|
echo bar >expect &&
|
||||||
|
GIT_SEQUENCE_EDITOR=bar git var GIT_SEQUENCE_EDITOR >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
# For git var -l, we check only a representative variable;
|
# For git var -l, we check only a representative variable;
|
||||||
# testing the whole output would make our test too brittle with
|
# testing the whole output would make our test too brittle with
|
||||||
# respect to unrelated changes in the test suite's environment.
|
# respect to unrelated changes in the test suite's environment.
|
||||||
|
Loading…
Reference in New Issue
Block a user