Skip to content

clean up some code around editors

D. Ben Knoble git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2t7005: sanitize test environment for subsequent testst/t7005-editor.sh+3 -40 replies
2/2editor: use standard strvec API to receive environment for external editorsbuiltin/commit.c editor.c editor.h+10 -90 replies

Reviews trailers per patch

None of the 2 patches has a Reviewed-by or Acked-by.

PatchJohannes Schindelin
SeriesHelped-by
1/2
2/2Helped-by

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] clean up some code around editors

This "v2" of the previous exec-path series is simplified to contain only the first 2 cleanup patches, which were largely acked by the list. Drop the controversial and broken PATH munging.

Also, this version is based on a later master 112648dd6b (Merge branch 'master' of https://github.com/j6t/git-gui, 2025-08-04) than the original from May.

These patches clean up some old code in the editor tests and subsystem that does not use our modern idioms. Patrick previously argued the test cleanup doesn't go far enough, and he may be right, but I think the preserving the semantics of the test for overrides /and/ automatically resetting the environment is tricky, unless we can use a subshell for the whole thing?

v1: https://lore.kernel.org/git/[email protected]/
Published-as: https://github.com/benknoble/tree/editor-cleanup

D. Ben Knoble (2):
t7005: sanitize test environment for subsequent tests
editor: use standard strvec API to receive environment for external
editors

 builtin/commit.c  |  2 +-
 editor.c          | 10 +++++-----
 editor.h          |  7 ++++---
 t/t7005-editor.sh |  7 +++----
 4 files changed, 13 insertions(+), 13 deletions(-)

Diff-intervalle :
1: da4fcc237b ! 1: a37db65107 t7005: sanitize test environment for subsequent tests
@@ Commit message
Some of the editor tests manipulate the environment or config in ways that affect future tests (because they test a sequence of overrides), but those modifications are visible to future tests and create a footgun
- for them. Use test_config and undo environment modifications once
- finished.
+ for them.
+
+ We can't make the environment-munging override tests undo their
+ modifications because they rely on editor variables overriding other
+ previously-set editor variables.
+
+ Use test_config and undo environment modifications once finished.

2: 7b3b6b08f0 ! 2: 5450c99f59 editor: use standard strvec API to receive environment for external editors
@@ Commit message
Going back to the introduction of the env parameter for the editor in
8babab95af (builtin-commit.c: export GIT_INDEX_FILE for launch_editor as
well., 2007-11-26), we pass a constant array of strings: as the
- surrounding APIs evolved to use strvecs, the editor code did not.
+ surrounding APIs evolved to use strvecs (see 8d7aa4ba6a
+ (builtin/commit.c: remove the PATH_MAX limitation via dynamic
+ allocation, 2017-01-13) and later 46b225f153 (Merge branch 'jk/strvec',
+ 2020-08-10)), the editor code did not.

There is only one caller of all 3 editor APIs that does not pass a NULL environment (the same caller for which this parameter was added), and it already has a strvec available to use.

- Signed-off-by: D. Ben Knoble <[email protected]>

+ Signed-off-by: D. Ben Knoble <[email protected]>

## builtin/commit.c ##
@@ builtin/commit.c: static int prepare_to_commit(const char *index_file, const char *prefix,

3:  cb48533115 < -:  ---------- run-command: prep_childenv on all platforms
4:  d2e54fdf75 < -:  ---------- drop git_exec_path() from non-Git commands' PATH

base-commit: 112648dd6bdd8e4f485cd0ae11636807959d48be

Signature · 1 line
2.48.1