Fixes edge case with subrepo push failing on rebase #485
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We have found that in some cases, a subrepo push fails when rebasing.
Note that our use case is to publish a subdirectory of a monorepo to a public subrepo.
We only ever push, as there are never any other changes to the remote subrepo.
The subrepo push is automated as part of the build and can cross with other developer commits.
We propose starting the subrepo branch from the most recent subrepo.commit value instead of from the subrepo.commit value that was current at the time of the first commit to be included in the branch.
A simplified example of the situation:
Parent repo log
Remote repo log
Now we want to push E to remote:
Before this change:
The rev-list used in subrepo:branch starts from D and gives [E, F].
commit E has .gitrepo file (subrepo.parent=A, subrepo.commit=A')
so the subrepo branch process starts from A', and produces:
Note that C' has been omitted from the subrepo branch.
This can cause a conflict during rebase if E depends on C.
With this change:
We always use the most recent .gitrepo file (subrepo.parent=D, subrepo.commit=C')
to determine the initial commit for the subrepo branch.
Again, the rev-list used in subrepo:branch starts from D and gives [E, F].
This time, however, when processing E, which is the initial commit to the branch,
the subrepo branch process starts from C', and produces:
which will always rebase successfully.