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 15, 2012, 17:32 UTC
Message-ID
<4FB2931A.1080504@ramsay1.demon.co.uk>
In-Reply-To
<4FB09FF2.70309@viscovery.net>
Johannes Sixt wrote:
Show 17 quoted lines
> Am 5/14/2012 0:58, schrieb Ramsay Jones:
>> BTW, Johannes, earlier you said commit be39048 ("git-sh-setup.sh: Add an pwd()
>> function for MinGW", 17-04-2012) would fix the problem on MinGW; I'm not so
>> sure it will. 
> 
>> [...] problem (*which MinGW shares*) is that the
>> pwd() function is defined *after* the code that sets $GIT_DIR from which the
>> rebase state directory name is derived (see git-sh-setup.sh lines 223-239).
> 
> Good catch!
> 
> Nevertheless, if I set GIT_EDITOR to "notepad", 'git rebase -i' works to
> some degree. Leaving aside that it does not understand LF line endings, it
> opens the git-rebase-todo file; I can edit and save it. That is, it looks
> like a usable Windows style path was passed to Notepad. (This is with
> MinGW git, of course.)
> 

I was about to, confidently, proclaim that it should fail when you run that rebase from a subdirectory ... Unfortunately, it seems to work! *ahem*

The reason I was confident, is simply that I have seen this pattern:

    p= ...some path...
    p=$(cd "$p" && pwd)

many times while debugging scripts on MinGW, so I 'know' that if p is initially a relative path, then the result is an absolute windows path. For example, while cwd is /home/ramsay/git then:

    .git => C:/msysgit/msysgit/home/ramsay/git/.git

Whereas if p is initially an absolute windows path, then the result is a POSIX-like path, viz:

    C:/msysgit/msysgit/home/ramsay/git/.git => /usr/home/ramsay/git/.git
If you combine that with the behaviour of 'git rev-parse', thus:
    $ cd /home/ramsay/git
    $ git rev-parse --git-dir
    .git
    $ cd xdiff
    $ git rev-parse --git-dir
    C:/msysgit/msysgit/home/ramsay/git/.git
    $

you should see "git rebase -i" invoking the editor with a POSIX path.

[BTW, I have noticed that I sometimes get different behaviour when I type this stuff into an interactive shell. :(]

Anyway, a bit of debugging shows that I was right, kinda! :-D

I placed a "set -x" in git-sh-setup (line 222) just before the code to set up GIT_DIR and ran git-rebase like so:

    $ cd /home/ramsay/git
    $ GIT_EDITOR=false ./bin-wrappers/git rebase -i master uname >ttt 2>&1
    $ cd xdiff
    $ GIT_EDITOR=false ../bin-wrappers/git rebase -i master uname >sss 2>&1
    $ diff ../ttt sss | more

which showed that in the subdirectory case, git was indeed invoking the editor with a POSIX-like path. (The output files, ttt and sss, show some other interesting/odd behaviour).

['uname' is an old branch of mine that, currently, is based on v1.7.10]
The reason it works, despite the above, is clear if you now run:
    $ GIT_EDITOR=args ../bin-wrappers/git rebase -i master uname
    ...
    +++ git var GIT_EDITOR
    ++ 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'
    ++ die_abort 'Could not execute editor'
    ++ rm -rf /usr/home/ramsay/git/.git/rebase-merge
    ++ die 'Could not execute editor'
    ++ die_with_status 1 'Could not execute editor'
    ++ status=1
    ++ shift
    ++ echo 'Could not execute editor'
    Could not execute editor
    ++ exit 1
[I'm sure you can guess what the args program looks like!]
So, the msys "path munging" of program arguments saves the day!
HTH

ATB, Ramsay Jones

Previous: Johannes SixtNext: Johannes Sixt
Message 17 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.