git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Lehmann <Jens.Lehmann@web.de>
To: John Keeping <john@metanate.com>
Cc: git@vger.kernel.org
Subject: Re: Interactive rebase with submodules
Date: Tue, 17 Jan 2012 22:29:33 +0100	[thread overview]
Message-ID: <4F15E83D.10509@web.de> (raw)
In-Reply-To: <4F15C22C.3020902@metanate.com>

Am 17.01.2012 19:47, schrieb John Keeping:
> 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.

  reply	other threads:[~2012-01-17 21:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-17 18:47 Interactive rebase with submodules John Keeping
2012-01-17 21:29 ` Jens Lehmann [this message]
2012-01-18 11:21   ` John Keeping
2012-01-18 20:38     ` Jens Lehmann
2012-01-19 10:48       ` John Keeping

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F15E83D.10509@web.de \
    --to=jens.lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=john@metanate.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).