Skip to content

Commit 9ae7826

Browse files
author
Matthias Putz
committed
Portable: fix GIT_EDITOR call with spaces on Windows
1 parent 3bebba1 commit 9ae7826

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

editor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
from __future__ import print_function
1717
import os
18+
import portable
1819
import re
1920
import sys
2021
import subprocess
@@ -83,8 +84,9 @@ def EditString(cls, data):
8384
fd = None
8485

8586
if re.compile("^.*[$ \t'].*$").match(editor):
86-
args = [editor + ' "$@"', 'sh']
87-
shell = True
87+
# args = [editor + ' "$@"', 'sh']
88+
# shell = True
89+
(args, shell) = portable.prepare_editor_args(editor)
8890
else:
8991
args = [editor]
9092
shell = False

portable.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,14 @@ def WaitForProcess():
274274
if child_process:
275275
child_process.stdin.close()
276276
child_process.wait()
277+
278+
279+
def prepare_editor_args(editor):
280+
if isUnix():
281+
args = [editor + ' "$@"', 'sh']
282+
shell = True
283+
else:
284+
editor = re.sub('["\']', '', editor)
285+
args = editor.rsplit()
286+
shell = False
287+
return (args, shell)

0 commit comments

Comments
 (0)