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

Re: git rebase -i --exec and changing directory

From
OMOndrej Mosnáček <omosnacek@gmail.com>
Date
May 27, 2018, 10:59 UTC
Message-ID
<CAAUqJDvsRBJWZh5_A2e2x-CqgXi5gLSjo6-P2sYxsKz3qfidSw@mail.gmail.com>
In-Reply-To
<CAAUqJDu_3DTyd1cFKaNRKOzo3AHosfxP1jjWpa=HGtyAyitTeA@mail.gmail.com>
Bump? Has anyone had time to look at this?
Thanks,
Ondrej Mosnacek
2018-05-19 18:38 GMT+02:00 Ondrej Mosnáček <omosnacek@gmail.com>:
Show 39 quoted lines
> Hello,
>
> I am trying to run a script to edit multiple commits using 'git rebase
> -i --exec ...' and I ran into a strange behavior when I run 'cd'
> inside the --exec command and subsequently run a git command. For
> example, if the command is 'cd src && git status', then git status
> reports as if all files in the repository are deleted.
>
> Example command sequence to reproduce the problem:
>
>     # Setup:
>     touch a
>     mkdir dir
>     touch dir/x
>
>     git init .
>     git add --all
>     git commit -m commit1
>     git tag base
>     touch b
>     git add --all
>     git commit -m commit2
>
>     # Here we go:
>     git rebase -i --exec 'cd dir && git status' base
>
>     # Spawning a sub-shell doesn't help:
>     git rebase -i --exec '(cd dir && git status)' base
>
> Is this expected behavior or did I found a bug? Is there any
> workaround, other than cd'ing to the toplevel directory every time I
> want to run a git command when I am inside a subdirectory?
>
> $ git --version
> git version 2.17.0
>
> Thanks,
>
> Ondrej Mosnacek
Previous: Ondrej MosnáčekNext: Philip Oakley
Message 2 of 8 in “git rebase -i --exec and changing directory”
  1. Ondrej MosnáčekMay 19, 2018
  2. Ondrej MosnáčekMay 27, 2018
  3. Philip OakleyMay 27, 2018
  4. Ondrej MosnáčekMay 27, 2018
  5. Phillip WoodMay 27, 2018
  6. Philip OakleyMay 27, 2018
  7. Philip OakleyMay 27, 2018
  8. Junio C HamanoMay 28, 2018

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.