git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Git commit path vs rebase path

From
Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Date
May 17, 2012, 18:30 UTC
Message-ID
<4FB543B7.6000506@ramsay1.demon.co.uk>
In-Reply-To
<4FB340A9.60607@viscovery.net>
Johannes Sixt wrote:
Show 13 quoted lines
> Am 5/15/2012 19:32, schrieb Ramsay Jones:
>>     ++ GIT_SEQUENCE_EDITOR=args
>>     ++ eval args '"$@"'
>>     +++ args /usr/home/ramsay/git/.git/rebase-merge/git-rebase-todo
>>     argv[0] = 'C:\msysgit\msysgit\home\ramsay\bin\args.exe'
>>     argv[1] = 'C:/msysgit/msysgit/home/ramsay/git/.git/rebase-merge/git-rebase-todo'
> ...
>> So, the msys "path munging" of program arguments saves the day!
> 
> Absolutely. This path munging is an essential detail in the process.
> 
> I don't know whether Cygwin has a similar feature, but I suppose not,
> otherwise we wouldn't have received this issue report.

Yes, but I keep forgetting about this msys feature (I don't know why!). I've had this "slap forehead" moment 3 or 4 times already (why do you think I have the args program close to hand? :-D ).

As you surmised, cygwin does not have this feature. On cygwin you are encouraged to use the cygpath utility in scripts. (Also, cygwin does provide an API to convert to/from POSIX/win32 paths from your own programs. eg. cygwin_conv_to_[full]_win32_path() and cygwin_conv_to_\ [full]_posix_path().)

>From the cygwin user guide, in a section titled "Using Cygwin effectively
with Windows", we find this:
    "Windows programs do not understand POSIX pathnames, so any arguments
    that reference the filesystem must be in Windows (or DOS) format or
    translated. Cygwin provides the cygpath utility for converting
    between Windows and POSIX paths. A complete description of its options
    and examples of its usage are in Section 3.7.2, including a shell script
    for starting Windows Explorer in any directory. The same format works
    for most Windows programs, for example
        notepad.exe "$(cygpath -aw "Desktop/Phone Numbers.txt")"
    A few programs require a Windows-style, semicolon-delimited path list,
    which cygpath can translate from a POSIX path with the -p option. For
    example, a Java compilation from bash might look like this:
        javac -cp "$(cygpath -pw "$CLASSPATH")" hello.java
    Since using quoting and subshells is somewhat awkward, it is often
    preferable to use cygpath in shell scripts."

Just as an exercise, I created a script to use the windows PSPad editor (included below), using it to create a commit and also run this rebase:

    GIT_EDITOR=pspad git rebase -i master uname
Both git commands launched the editor (and completed their task) just fine.

Note that the script can be improved greatly, but it only took ten minutes to create and is sufficient to this task. (PSPad supports more than one file on the command line, despite what it's help file says, although all options apply to all files. You should be able to "bundle" the options ...).

ATB, Ramsay Jones

-- >8 -- #!/bin/sh

file= opts=

while test $# != 0
do
    case "$1" in
	-[hH])
	    # open file in hex editor
	    opts="$opts /H"
	    ;;
	-[rR])
	    # open file in read-only mode
	    opts="$opts /R"
	    ;;
	-[0-9]*)
	    # open file and goto line n
	    opts="$opts /${1:1}"
	    ;;
	-*)
	    echo "option '$1' not supported"
	    exit 1
	    ;;
	*)
	    if test -n "$file"; then
		    echo "only one filename allowed"
		    exit 1
	    fi
	    file="$1"
	    ;;
    esac
    shift
done
if test -n "$file"; then
	file="$(cygpath -aw "$file")"
fi
"C:/Program Files/PSPad editor/PSPad.exe" "$file" $opts
-- 8< --
Previous: Johannes SixtNext: Junio C Hamano
Message 19 of 32 in “Git commit path vs rebase path”
  1. Steven PennyMay 6, 2012
  2. Junio C HamanoMay 7, 2012
  3. Johannes SixtMay 8, 2012
  4. Steven PennyMay 8, 2012
  5. Johannes SixtMay 8, 2012
  6. Steven PennyMay 8, 2012
  7. Junio C HamanoMay 8, 2012
  8. Junio C HamanoMay 8, 2012
  9. Steven PennyMay 8, 2012
  10. Junio C HamanoMay 9, 2012
  11. Steven PennyMay 9, 2012
  12. Ramsay JonesMay 10, 2012
  13. Steven PennyMay 11, 2012
  14. Ramsay JonesMay 13, 2012
  15. Steven PennyMay 13, 2012
  16. Johannes SixtMay 14, 2012
  17. Ramsay JonesMay 15, 2012
  18. Johannes SixtMay 16, 2012
  19. Ramsay JonesMay 17, 2012
  20. Junio C HamanoMay 17, 2012
  21. 0/2 Re: Git commit path vs rebase pathJunio C Hamano, May 16, 2012
  22. 1/2 git-sh-setup: define workaround wrappers before they are usedJunio C Hamano, May 16, 2012
  23. Ramsay JonesMay 17, 2012
  24. 2/2 git-sh-setup: work around Cygwin path handling gotchasJunio C Hamano, May 16, 2012
  25. Steven PennyMay 16, 2012
  26. Junio C HamanoMay 16, 2012
  27. Ramsay JonesMay 17, 2012
  28. Junio C HamanoMay 18, 2012
  29. Steven PennyMay 19, 2012
  30. Ramsay JonesMay 21, 2012
  31. Junio C HamanoMay 21, 2012
  32. Ramsay JonesMay 24, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.