• S
    git-gui: Perform our own magic shbang detection on Windows · c136f2b8
    Shawn O. Pearce 提交于
    If we cannot locate a .exe for a git tool that we want to run than
    it may just be a Bourne shell script as these are popular in Git.
    In such a case the first line of the file will say "#!/bin/sh" so
    a UNIX kernel knows what program to start to parse and run that.
    But Windows doesn't support shbang lines, and neither does the Tcl
    that comes with Cygwin.
    
    We can pass control off to the git wrapper as that is a real Cygwin
    program and can therefore start the Bourne shell script, but that is
    at least two fork+exec calls to get the program running.  One to do
    the fork+exec of the git wrapper and another to start the Bourne shell
    script.  If the program is run multiple times it is rather expensive
    as the magic shbang detection won't be cached across executions.
    
    On MinGW/MSYS we don't have the luxury of such magic detection.  The
    MSYS team has taught some of this magic to the git wrapper, but again
    its slower than it needs to be as the git wrapper must still go and
    run the Bourne shell after it is called.
    
    We now attempt to guess the shbang line on Windows by reading the
    first line of the file and building our own command line path from
    it.  Currently we support Bourne shell (sh), Perl and Python.  That
    is the entire set of shbang lines that appear in git.git today.
    Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
    c136f2b8
git-gui.sh 62.1 KB