Bug: git-p4 edit_template() and P4EDITOR w/options

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Git Folks!

I recently had a user who was unable to perform a 'git p4 submit', with the following traceback:

========
Traceback (most recent call last):
  File "/usr/local/pixar/Cellar/git/2.2.2/libexec/git-core/git-p4", line 3302, in <module>
    main()
  File "/usr/local/pixar/Cellar/git/2.2.2/libexec/git-core/git-p4", line 3296, in main
    if not cmd.run(args):
  File "/usr/local/pixar/Cellar/git/2.2.2/libexec/git-core/git-p4", line 1723, in run
    ok = self.applyCommit(commit)
  File "/usr/local/pixar/Cellar/git/2.2.2/libexec/git-core/git-p4", line 1477, in applyCommit
    if self.edit_template(fileName):
  File "/usr/local/pixar/Cellar/git/2.2.2/libexec/git-core/git-p4", line 1228, in edit_template
    system([editor, template_file])
  File "/usr/local/pixar/Cellar/git/2.2.2/libexec/git-core/git-p4", line 196, in system
    retcode = subprocess.call(cmd, shell=expand)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 524, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1308, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
==========

This is running on OS X 10.9.5, with git 2.2.2 installed via homebrew, but we’ve replicated it with the version of git that comes with XCode
(which I believe is older, 1.9.x)

We chased this down to the fact that his P4EDITOR ( and GIT_EDITOR) values have a command-line option in them:  /path/to/mate -w,

The edit_template() function passes that value as-is to  system(), and then on to subprocess.call(), in such a way that the entirety of P4EDITOR is 
treated as the command name.

I have confirmed this by modifying the system() call in edit_template()  thus, and it works:

==========
if editor.split()[-1][0] == "-":
    cmd = editor.split() + [template_file]
    system(cmd)
 else:
    system([editor, template_file])
==========

Which results, if the last word of 'editor' begins with a hyphen,  in [ "/path/to/mate", "-w", "/path/to/template"]  being passed to system()  rather
than the non-funcional [ "/path/to/mate -w", "/path/to/template"].

Clearly my hack is not the best way to address this, especially since I’m not much of a python coder, nor am I familiar with the git-p4 source.
I was just confirming my suspicion and trying to get things working for the user.

Thank you!
-Chris Lasell

PS: 'mate' is the CLI invocation of the TextMate GUI editor for OS X. The -w is required in this instance, or the 'mate' command would return 
instantly when the document opens. The -w causes it to wait until the document window is closed.

I have noticed that the help output for mate says:
=======
By default mate will wait for files to be closed if the command name
has a "_wait" suffix (e.g. via a symbolic link)
=======

and I have instructed my user to do just that for now. However, options to EDITOR environment variables are not uncommon, so I wanted
to address this to the right people

-- 
Chris Lasell, Apple Peeler, MacTeam
Pixar Animation Studios, Emeryville, CA




--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]