git: fix edit command when using extra args #748
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The user can include extra arguments to the git core.editor configuration
option or the GIT_EDITOR env var, however, in the current way that
editorCMD() is coded, all the extra arguments are passed to the actual
editor executable as a single argument: argv[0] == exec, argv[1] == all
arguments, instead of splitting them in separated argv[] fields. Although
some editors are fine with this behavior, because they split the argv array
before actually using it, some others don't.
Since splitting all the args, one per argv field, is the standard across the
industry, we should do the same. This patch refactors the editorCMD() code
to ease its understanding, split each arg in one argv field, and also to
solve an issue, found during the refactoring, for when the user hasn't set
neither git core.editor nor GIT_EDITOR.
Signed-off-by: Bruno Meneguele bmeneg@redhat.com
Fixes: #747