Skip to content

Commit

Permalink
Restore Windows compatibility, which my shell escaping fix would have…
Browse files Browse the repository at this point in the history
… broken.

Windows needs to go through the shell in order to find git on the PATH,
but it's OK to use the shell there because it will automatically escape
discrete arguments.

Warning: this is theoretical work. Untested on Windows.
  • Loading branch information
ashearer committed Dec 17, 2010
1 parent 91e0667 commit d8f9b8b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gitmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@

from settings import *

# Arguments are passed directly to git, not through the shell, to avoid the
# need for shell escaping. On Windows, however, commands need to go through the
# shell for git to be found on the PATH, but escaping is automatic there. So
# send git commands through the shell on Windows, and directly everywhere else.
USE_SHELL = os.name == 'nt'

class gitMark(object):

def __init__(self, options, args):
Expand Down Expand Up @@ -50,10 +56,10 @@ def __init__(self, options, args):
self.gitPush()

def gitAdd(self, files):
subprocess.call(['git', 'add'] + files)
subprocess.call(['git', 'add'] + files, shell=USE_SHELL)

def gitCommit(self, msg):
subprocess.call(['git', 'commit', '-m', msg])
subprocess.call(['git', 'commit', '-m', msg], shell=USE_SHELL)

def gitPush(self):
pipe = subprocess.Popen("git push origin master", shell=True)
Expand Down

0 comments on commit d8f9b8b

Please sign in to comment.