Skip to content

Commit 48475f4

Browse files
committed
Merge branch 'sa/git-var-sequence-editor'
Just like "git var GIT_EDITOR" abstracts the complex logic to choose which editor gets used behind it, "git var" now give support to GIT_SEQUENCE_EDITOR. * sa/git-var-sequence-editor: var: add GIT_SEQUENCE_EDITOR variable
2 parents b3b9e5c + 4c3dd93 commit 48475f4

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

Documentation/git-var.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ ifdef::git-default-editor[]
5050
The build you are using chose '{git-default-editor}' as the default.
5151
endif::git-default-editor[]
5252

53+
GIT_SEQUENCE_EDITOR::
54+
Text editor used to edit the 'todo' file while running `git rebase
55+
-i`. Like `GIT_EDITOR`, the value is meant to be interpreted by
56+
the shell when it is used. The order of preference is the
57+
`$GIT_SEQUENCE_EDITOR` environment variable, then
58+
`sequence.editor` configuration, and then the value of `git var
59+
GIT_EDITOR`.
60+
5361
GIT_PAGER::
5462
Text viewer for use by Git commands (e.g., 'less'). The value
5563
is meant to be interpreted by the shell. The order of preference

builtin/var.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ static const char *editor(int flag)
1414
return git_editor();
1515
}
1616

17+
static const char *sequence_editor(int flag)
18+
{
19+
return git_sequence_editor();
20+
}
21+
1722
static const char *pager(int flag)
1823
{
1924
const char *pgm = git_pager(1);
@@ -36,6 +41,7 @@ static struct git_var git_vars[] = {
3641
{ "GIT_COMMITTER_IDENT", git_committer_info },
3742
{ "GIT_AUTHOR_IDENT", git_author_info },
3843
{ "GIT_EDITOR", editor },
44+
{ "GIT_SEQUENCE_EDITOR", sequence_editor },
3945
{ "GIT_PAGER", pager },
4046
{ "GIT_DEFAULT_BRANCH", default_branch },
4147
{ "", NULL },

t/t0007-git-var.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,44 @@ test_expect_success 'get GIT_EDITOR with configuration and environment variable
109109
)
110110
'
111111

112+
test_expect_success 'get GIT_SEQUENCE_EDITOR without configuration' '
113+
(
114+
sane_unset GIT_SEQUENCE_EDITOR &&
115+
git var GIT_EDITOR >expect &&
116+
git var GIT_SEQUENCE_EDITOR >actual &&
117+
test_cmp expect actual
118+
)
119+
'
120+
121+
test_expect_success 'get GIT_SEQUENCE_EDITOR with configuration' '
122+
test_config sequence.editor foo &&
123+
(
124+
sane_unset GIT_SEQUENCE_EDITOR &&
125+
echo foo >expect &&
126+
git var GIT_SEQUENCE_EDITOR >actual &&
127+
test_cmp expect actual
128+
)
129+
'
130+
131+
test_expect_success 'get GIT_SEQUENCE_EDITOR with environment variable' '
132+
(
133+
sane_unset GIT_SEQUENCE_EDITOR &&
134+
echo bar >expect &&
135+
GIT_SEQUENCE_EDITOR=bar git var GIT_SEQUENCE_EDITOR >actual &&
136+
test_cmp expect actual
137+
)
138+
'
139+
140+
test_expect_success 'get GIT_SEQUENCE_EDITOR with configuration and environment variable' '
141+
test_config sequence.editor foo &&
142+
(
143+
sane_unset GIT_SEQUENCE_EDITOR &&
144+
echo bar >expect &&
145+
GIT_SEQUENCE_EDITOR=bar git var GIT_SEQUENCE_EDITOR >actual &&
146+
test_cmp expect actual
147+
)
148+
'
149+
112150
# For git var -l, we check only a representative variable;
113151
# testing the whole output would make our test too brittle with
114152
# respect to unrelated changes in the test suite's environment.

0 commit comments

Comments
 (0)