Fixes edge case with subrepo push failing on rebase#485
Open
rhbradford wants to merge 1 commit intoingydotnet:masterfrom
Open
Fixes edge case with subrepo push failing on rebase#485rhbradford wants to merge 1 commit intoingydotnet:masterfrom
rhbradford wants to merge 1 commit intoingydotnet:masterfrom
Conversation
jameswalmsley
added a commit
to jameswalmsley/git-subrepo
that referenced
this pull request
Mar 20, 2021
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. That push is automated as
part of the build and can cross with other developer commits.
Start 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
A -> B -> C -> D -> E -> F -> G
F: commit of .gitrepo file (subrepo.parent=D, subrepo.commit=C')
E: commit in subrepo directory
D: some commit
C: commit in subrepo directory
B: commit of .gitrepo file (subrepo.parent=A, subrepo.commit=A')
A: commit in subrepo directory
[Whilst pushing C to remote, D and E were committed to parent,
then the result of the push was committed to parent in F]
Remote repo log
A' -> C'
C': commit corresponding to C
A': commit corresponding to A
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:
A' -> E''
(F'' is filtered out as it is empty after .gitrepo is removed)
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 .gitrepo file (subrepo.parent=D, subrepo.commit=C')
when processing E, so the subrepo branch process starts from C', and produces:
A' -> C' -> E''
which will always rebase successfully.
|
Just rebased this to upstream master, still curious to know whether it can be accepted by upstream although we are doing fine running off a fork for ourselves. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.