fix: stg import --reject should create empty commit#477
Merged
jpgrayson merged 1 commit intostacked-git:masterfrom Aug 17, 2024
Merged
fix: stg import --reject should create empty commit#477jpgrayson merged 1 commit intostacked-git:masterfrom
jpgrayson merged 1 commit intostacked-git:masterfrom
Conversation
When trying to import a patch that does not apply cleanly, and using --reject option, stg should apply what it can, leave the rest in .rej files, and create an empty commit. The work to apply the patch is outsourced to "git apply --reject" which exits with status code 1 if patch is applied partially and it is treated as error by stg import. Fix the issue by not treating return code of 1 from "git apply" as an error when "--reject" option is specified, but rather saving its output, printing it for the user, and continuing with the rest of the import logic. Exit with CONFLICT_ERROR rather than COMMAND_ERROR when the patch does not import/apply cleanly. "stg fold" reuses much of the same code so it has to be adjusted in the similar fashion. It will also exit with CONFLICT_ERROR when a patch does not apply cleanly. Also add a test case and fix up documentation for "stg import" and adjust test case for "stg fold". Closes: stacked-git#471 Signed-off-by: Dmitry Torokhov <[email protected]>
Collaborator
|
Thank you for this fix @dtor. It is very much appreciated. Apologies for taking so long to look at this PR. |
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.
When trying to import a patch that does not apply cleanly, and using --reject option, stg should apply what it can, leave the rest in .rej files, and create an empty commit. The work to apply the patch is outsourced to "git apply --reject" which exits with status code 1 if patch is applied partially and it is treated as error by stg import.
Fix the issue by not treating return code of 1 from "git apply" as an error when "--reject" option is specified, but rather saving its output, printing it for the user, and continuing with the rest of the import logic. Exit with CONFLICT_ERROR rather than COMMAND_ERROR when the patch does not import/apply cleanly.
"stg fold" reuses much of the same code so it has to be adjusted in the similar fashion. It will also exit with CONFLICT_ERROR when a patch does not apply cleanly.
Also add a test case and fix up documentation for "stg import" and adjust test case for "stg fold".
Closes: #471