msiemens / PyGitUp

A nicer `git pull`

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash under cygwin with configured git-up.rebase.log-hook

fj128 opened this issue · comments

commented

When running under cygwin, with git and python from cygwin, and configured git-up.rebase.log-hook (echo "changes on $1:"; git lg $1..$2; git diff --stat $1..$2 for the record) git up crashes after rebasing because it tries to run the log hook from a batch file with no execute permission bit set (of course then it wouldn't work anyway because it's a windows batch file probably):

Fetching origin
feature fast-forwarding...
Traceback (most recent call last):
  File "/usr/bin/git-up", line 11, in <module>
    load_entry_point('git-up==1.5.0', 'console_scripts', 'git-up')()
  File "/usr/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/PyGitUp/gitup.py", line 658, in run
    gitup.run()
  File "/usr/lib/python2.7/site-packages/PyGitUp/gitup.py", line 201, in run
    self.rebase_all_branches()
  File "/usr/lib/python2.7/site-packages/PyGitUp/gitup.py", line 288, in rebase_all_branches
    self.log(branch, target)
  File "/usr/lib/python2.7/site-packages/PyGitUp/gitup.py", line 392, in log
    [bat_file.name, branch.name, remote.name]
  File "/usr/lib/python2.7/subprocess.py", line 168, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 390, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1025, in _execute_child
    raise child_exception
OSError: [Errno 13] Permission denied

This is because it's using the ON_WINDOWS flag https://github.com/msiemens/PyGitUp/blame/master/PyGitUp/gitup.py#L48 for two distinct purposes: 1) to work around the colorama bug(?) when running in Windows console (see #24), and 2) to execute the hook from a batch file when running from under cmd.exe shell. And while cygwin might count as windows for (1), it definitely doesn't for (2).

But I'm not sure that (1) is still relevant. I checked and replacing that line with ON_WINDOWS = sys.platform == 'win32' (or in ['win32'], but not in ('win32'), I did that at first) not only fixed this bug but also colorized the output! And it worked perfectly both in mintty and when starting cygwin bash from cmd.exe (note: use bash --login -i or weird things happen). So I'd do that unless there are other concerns.

Thanks for the comprehensive and helpful bug report! I've release v1.5.1 which applies the fix you described 🙂