engine/bin/engine-git.sh | 61 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
New commits:
commit 9d42eb554c580c34015709c4dfffe61b96597040
Author: Stephan Bergmann <
stephan....@collabora.com>
AuthorDate: Wed Apr 22 12:46:17 2026 +0200
Commit: Noel Grandin <
noel.g...@collabora.com>
CommitDate: Fri Apr 24 08:27:55 2026 +0000
Helper script to replay git commands across the engine subtree merge
See the comment at the top of engine/bin/engine-git.sh for details
Signed-off-by: Stephan Bergmann <
stephan....@collabora.com>
Change-Id: Ic3501afba7be004c3e846098e99843eac1ebd7d3
Reviewed-on:
https://gerrit.collaboraoffice.com/c/online/+/1378
Tested-by: Jenkins CPCI <
rel...@collaboraoffice.com>
Reviewed-by: Noel Grandin <
noel.g...@collabora.com>
diff --git a/engine/bin/engine-git.sh b/engine/bin/engine-git.sh
new file mode 100755
index 000000000000..f876938fdcc3
--- /dev/null
+++ b/engine/bin/engine-git.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+# Replay a git history-editing subcommand (cherry-pick, revert, ...) from the old core history onto
+# the subtree-merged online repo, rewriting all paths under engine/.
+#
+# The subcommand and its arguments are passed through to git unchanged, so flags like `cherry-pick
+# -x` or `revert -m 1` work without this wrapper knowing about them. The command runs in a
+# throwaway detached worktree based at merge-engine^2 (the old core tip at the time of the subtree
+# merge), so operations on old-core SHAs succeed there. The resulting commit(s) are then
+# format-patched, path-rewritten, and applied onto the current HEAD with git am.
+#
+# Usage: engine-git.sh <git-subcommand> [args...]
+# e.g. engine-git.sh cherry-pick 301320d53467
+# engine-git.sh cherry-pick -x 301320d53467
+# engine-git.sh revert 301320d53467
+
+set -euo pipefail
+
+if [ $# -lt 1 ]; then
+ printf "usage: %s <git-subcommand> [args...]\n" "$(basename "$0")" >&2
+ exit 1
+fi
+
+base=merge-engine^2
+
+tmp=$(mktemp -d)
+wt="$tmp/wt"
+cleanup() {
+ git worktree remove --force "$wt" >/dev/null 2>&1 || true
+ rm -rf "$tmp"
+}
+trap cleanup EXIT
+
+git worktree add --detach "$wt" "$base" >/dev/null
+
+pre=$(git -C "$wt" rev-parse HEAD)
+git -C "$wt" "$@"
+post=$(git -C "$wt" rev-parse HEAD)
+
+if [ "$pre" = "$post" ]; then
+ printf "%s produced no commits\n" "$1" >&2
+ exit 1
+fi
+
+git -C "$wt" format-patch -k --stdout "$pre..$post" \
+ | awk '
+ /^---$/ { in_diff = 1 }
+ in_diff {
+ if (/^diff --git a\/.* b\//) {
+ sub(/^diff --git a\//, "diff --git a/engine/")
+ sub(/ b\//, " b/engine/")
+ } else if (/^--- a\//) { sub(/^--- a\//, "--- a/engine/") }
+ else if (/^\+\+\+ b\//) { sub(/^\+\+\+ b\//, "+++ b/engine/") }
+ else if (/^rename from /) { sub(/^rename from /, "rename from engine/") }
+ else if (/^rename to /) { sub(/^rename to /, "rename to engine/") }
+ else if (/^copy from /) { sub(/^copy from /, "copy from engine/") }
+ else if (/^copy to /) { sub(/^copy to /, "copy to engine/") }
+ }
+ { print }
+ ' \
+ | git am -k