Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stg import --reject should create empty commit #477

Merged
merged 1 commit into from
Aug 17, 2024

Conversation

dtor
Copy link
Contributor

@dtor dtor commented Jul 28, 2024

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

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 <dtor@google.com>
@jpgrayson jpgrayson merged commit 7e73d8b into stacked-git:master Aug 17, 2024
10 checks passed
@jpgrayson
Copy link
Collaborator

Thank you for this fix @dtor. It is very much appreciated. Apologies for taking so long to look at this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"stg import --reject" is broken
2 participants