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

Re: Interactive rebase with submodules

From
Jens Lehmann <jens.lehmann@web.de>
Date
Jan 17, 2012, 21:29 UTC
Message-ID
<4F15E83D.10509@web.de>
In-Reply-To
<4F15C22C.3020902@metanate.com>
Am 17.01.2012 19:47, schrieb John Keeping:
Show 19 quoted lines
> I've encountered a scenario where git rebase --interactive drops a commit which contains a modification to a submodule but no other changes.
> 
> This occurs when there is a conflict when applying the commit (for example if the submodule's history has been rewritten and you are rewriting the parent repository to match the new version of the submodule).
> 
> To clarify:
> 
> git rebase -i
> # Edit a commit, switching submodule to an unrelated commit
> git rebase --continue
> # Conflict in submodule, checkout the correct submodule commit
> git add path/to/submodule
> # Only change in index is updated submodule
> git rebase --continue
> # No commit is created for the submodule change
> 
> 
> This appears to be because the git-rebase--interactive script inspects whether there is anything to commit when `rebase --continue` is invoked by running:
> 
>     git diff-index --cached --quiet --ignore-submodules HEAD --
Thanks for pinning that down.
> Is there a reason for the `--ignore-submodules` in this command? Removing that option results in the expected behaviour.

Yes, removing it will help your use case but break others. The reason for that is that because submodules are not updated during a rebase it doesn't make sense to compare their HEAD to what is recorded in the superproject, as that might have been changed by an earlier commit. And as the submodules HEAD hasn't been updated back then, it is stale and will always show up as modified (even if it wasn't).

> I can understand not updating submodules while running the rebase, but I expected that having resolved a conflict and added my change to the index it would be applied by `git rebase --continue`, as indeed it is if there happen to be other (non-submodule) changes in the same commit.

The irony is that you would have to update submodules (or at least their HEAD and use "--ignore-submodules=dirty") while running rebase to make that work in all cases ;-)

But just updating the HEAD would be dangerous as you would have to be very careful to restore the submodules HEAD after the rebase, or the submodule's work tree will be out of sync.

I suspect in the long run a rebase should, e.g. when invoked with --recurse-submodules, update the submodules too and won't use the --ignore-submodule option for diff anymore ... then everything should Just Work. But until that happens, I don't see a solution for your problem.

Previous: John KeepingNext: John Keeping
Message 2 of 5 in “Interactive rebase with submodules”
  1. John KeepingJan 17, 2012
  2. Jens LehmannJan 17, 2012
  3. John KeepingJan 18, 2012
  4. Jens LehmannJan 18, 2012
  5. John KeepingJan 19, 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.