import: No empty commits without --allow-empty #245
Merged
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.
Description
This adds the --allow-empty option, which has the same meaning as
in
commit
andapply
.This behaviour mostly only affects
--replace-existing
,since
import
will never produce an empty commit if you're notreplacing anything.
Because import uses fast-import, this was a little tricky. fast-import will happily do empty commits and there's no easy way to stop it from doing so.
So instead, I made fast-import use a temporary branch to do its importing on. Then afterwards I checked whether the commit was empty before updating the original branch ref to the new commit.
Related links:
#243 did the same thing for
apply
Checklist: