Stop adding patches to the Git index by default

Continue adding patches to the index before doing a 3-way merge to avoid the error "file does not match index"
This commit is contained in:
Matthew Lopez 2024-06-04 16:11:05 -04:00
parent 8b683c00cb
commit d7f6d366c4
No known key found for this signature in database
GPG Key ID: 302A6EE3D63B7E0E

View File

@ -4,8 +4,8 @@
source "$(dirname "$(realpath "$0")")/internal/framework.sh"
set_description "This configures, resets the contents of, and applies patches to the submodules in the repos directory."
add_option "-u --update-remote" "update_remote" "Updates the submodules from their remotes before applying patches. Only \
use this if you're trying to update the submodules to a newer version than is supported by this project. Patches will \
be applied first with --reject, and if that fails, a 3-way merge will be attempted."
use this if you're trying to update the submodules to a newer version than is supported by this project. If a patch \
fails to apply, a 3-way merge will be attempted."
parse_arguments "$@"
print_info "Resetting all submodules..."
@ -30,9 +30,9 @@ for dir in "$git_base_dir/patches/"*; do
for patch in "$git_base_dir/patches/$subdir"/*; do
if [[ -n "$update_remote" ]]; then
print_info "Applying patch $patch..."
if ! git apply --reject "$patch"; then
# Without --index, --3way will show the error "file: does not match index"
if ! git apply --index "$patch"; then
print_error "Failed to apply patch $patch! Attempting 3-way merge..."
git add .
if ! git apply --3way "$patch"; then
print_error "There are merge conflicts with the patch that need to be resolved manually."
else
@ -46,8 +46,6 @@ for dir in "$git_base_dir/patches/"*; do
fi
patch_count=$((patch_count + 1))
done
git add .
fi
done