Skip to contentSkip to conversation

submodule modify/delete wrong message

DISCUSSION David Turner 2 participants 3 messages Dec 4, 2017 – Dec 11, 2017

lore
Share & tools
lore
#0 lore raw

When merging with a submodule modify/delete conflict (i.e. I've deleted the submodule, and I'm merging in a branch that modified it), git lies about what it is doing:

"CONFLICT (modify/delete): submodule deleted in HEAD and modified in submodules. Version submodules of submodule left in tree at submodule~submodules.
Automatic merge failed; fix conflicts and then commit the result."

In fact, the working tree does not contain anything named 'submodule~submodules'.

In addition, I would ordinarily resolve a conflict like this by using 'git rm'. Here, this gives a warning:

$ git rm submodule
submodule: needs merge
rm 'submodule'
warning: Could not find section in .gitmodules where path=submodule

Git's behavior here is significantly better than liggit2's (which tries to check out 'submodule' as if it were a blob, and fails to do so), but it's still confusing.

It's not clear to me what the correct behavior is here. Maybe it's sufficient to just fix the message?

#1 lore raw
Quoted 6 lines · David Turner

When merging with a submodule modify/delete conflict (i.e. I've deleted the submodule, and I'm merging in a branch that modified it), git lies about what it is doing:

"CONFLICT (modify/delete): submodule deleted in HEAD and modified in submodules.

Up to here the error message sounds correct, still?

Quoted 3 lines

Version submodules of submodule left in tree at submodule~submodules.
Automatic merge failed; fix conflicts and then commit the result."

This sounds as if the code assumed to handle only files.

Quoted 8 lines

In fact, the working tree does not contain anything named 'submodule~submodules'.

In addition, I would ordinarily resolve a conflict like this by using 'git rm'. Here, this gives a warning:

$ git rm submodule
submodule: needs merge

(Regarding submodule merges in general:)

Uh. We cannot add merge markers to a submodule or such.
More importantly we'd have to ask the question if the merge conflict is on the superproject level (Choose one of the commits of the submodule) or on the submodule level (perform a merge in the submodule between the two commits) or some hybrid approach thereof.

Quoted 2 lines

rm 'submodule'
warning: Could not find section in .gitmodules where path=submodule

The deletion of the submodule removed the .gitmodules entry, and the merge of the .gitmodules file presumably went fine. :/

I assume we need a special merge driver for the .gitmodules file to keep the submodule around when it is in at least one side.

Quoted 6 lines

Git's behavior here is significantly better than liggit2's (which tries to check out 'submodule' as if it were a blob, and fails to do so), but it's still confusing.

It's not clear to me what the correct behavior is here. Maybe it's sufficient to just fix the message?

I think the first step is to fix the message to reflect reality.

As alluded to above, I don't know what the correct merge behavior is (and where to put 'conflict markers').

Stefan

#2 lore raw
Quoted 8 lines · Stefan Beller
Quoted 6 lines · David Turner

When merging with a submodule modify/delete conflict (i.e. I've deleted
the submodule, and I'm merging in a branch that modified it), git lies
about what it is doing:

Quoted 5 lines
Quoted 3 lines

"CONFLICT (modify/delete): submodule deleted in HEAD and modified in
submodules.

Up to here the error message sounds correct, still?

Yep!

Quoted 5 lines
Quoted 3 lines

Version submodules of submodule left in tree at submodule~submodules.
Automatic merge failed; fix conflicts and then commit the result."

This sounds as if the code assumed to handle only files.

This assumption is unfortunately very common -- I just filed a PR to fix an instance of this in libgit2.

Quoted 12 lines
Quoted 9 lines

In fact, the working tree does not contain anything named 'submodule~submodules'.

In addition, I would ordinarily resolve a conflict like this by using
'git rm'. Here, this gives a warning:

$ git rm submodule
submodule: needs merge

(Regarding submodule merges in general:)

Quoted 7 lines

Uh. We cannot add merge markers to a submodule or such. More importantly we'd have to ask the question if the merge conflict is on the superproject level (Choose one of the commits of the submodule)
or on the submodule level (perform a merge in the submodule between the
two commits) or some hybrid approach thereof.

Yeah, that's a tricky thing in general. In this case, tho, the submodule is being removed, so git rm should work.

Quoted 5 lines
Quoted 2 lines

rm 'submodule'
warning: Could not find section in .gitmodules where path=submodule

The deletion of the submodule removed the .gitmodules entry, and the merge of the .gitmodules file presumably went fine. :/

Indeed.

Quoted 10 lines

I assume we need a special merge driver for the .gitmodules file to keep
the submodule around when it is in at least one side.

Quoted 6 lines

Git's behavior here is significantly better than liggit2's (which tries
to check out 'submodule' as if it were a blob, and fails to do so), but
it's still confusing.

Quoted 7 lines
Quoted 2 lines

It's not clear to me what the correct behavior is here.  Maybe it's sufficient to just fix the message?

I think the first step is to fix the message to reflect reality.

As alluded to above, I don't know what the correct merge behavior is (and where to put 'conflict markers').

The only case we need 'conflict markers' is in the {add,modify}/{add,modify} case (with different versions on each side). The delete/* and */delete case can be handled more simply. We might not want to do this until we can handle all cases -- but personally, I think a half-solution is better than a non-solution.