From 055aa7a9414b3efccd00db42e82e389f84f33207 Mon Sep 17 00:00:00 2001 From: Bryan Joshua Pedini Date: Fri, 2 Jan 2026 12:50:15 +0100 Subject: [PATCH] maybe fixed now with three way merge (again) --- update_child_repos.sh | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/update_child_repos.sh b/update_child_repos.sh index dc72dd4..5932f00 100755 --- a/update_child_repos.sh +++ b/update_child_repos.sh @@ -106,8 +106,34 @@ while IFS= read -r clone_url; do continue fi - echo "File ${file} has local changes in ${repo_name} - preserving local changes" - conflicted_files+=("${file}") + file_diff=$(git diff "${PREVIOUS_COMMIT_ID}" "${CURRENT_COMMIT_ID}" -- "${file}" 2>/dev/null || true) + + if [ -n "${file_diff}" ]; then + tmp_current=$(mktemp) + tmp_diff=$(mktemp) + echo "${current_content}" > "${tmp_current}" + echo "${file_diff}" > "${tmp_diff}" + + if patch --dry-run "${tmp_current}" "${tmp_diff}" >/dev/null 2>&1; then + patch "${tmp_current}" "${tmp_diff}" >/dev/null 2>&1 + patched_content=$(cat "${tmp_current}") + + if [ "${current_content}" != "${patched_content}" ]; then + echo "${patched_content}" > "${file}" + git add "${file}" + files_changed=true + echo "Merged updates for ${file} in ${repo_name}" + fi + else + echo "Merge conflict detected in ${repo_name}:${file} - preserving local changes" + conflicted_files+=("${file}") + fi + + rm -f "${tmp_current}" "${tmp_diff}" + else + echo "File ${file} has local changes in ${repo_name} - preserving local changes" + conflicted_files+=("${file}") + fi else echo "Adding new file ${file} from template to ${repo_name}" mkdir -p "$(dirname "${file}")"