diff --git a/.crumb b/.crumb index fafbbfb..604b82d 100644 --- a/.crumb +++ b/.crumb @@ -22,7 +22,7 @@ "children": [ { "digest": "bccfc765e0a32a2e4a31cc84d1b5fad1047ac129def178f543c208afb9e7b3a9", - "last_commit": "cfe1c22", + "last_commit": "4913a67", "name": "docs", "purpose": "Directory docs. Purpose not yet described by a human." }, @@ -33,8 +33,8 @@ "purpose": "Directory doctrine. Purpose not yet described by a human." }, { - "digest": "8bb604d86df1aa3f433600354b036dab1734d921530cf48147886a6ebeeabca9", - "last_commit": "78a7014", + "digest": "0ef6bd47b5ed1c28c37208ce84a05a6fccbce4ba41e8b791374251de0562b067", + "last_commit": "ec1c8c3", "name": "scripts", "purpose": "Directory scripts. Purpose not yet described by a human." }, @@ -45,15 +45,15 @@ "purpose": "Directory tools. Purpose not yet described by a human." } ], - "children_root": "sha256:770180f54121cb55bfbc154efd4eb2cc2fca53dd7dd8fc43911a64c930f384b3", - "compiled_at": "2026-10-10T15:59:58Z", + "children_root": "sha256:ec62d5f0bbd2bedb8c2242dababcbd3ec36babd6d97bfd5afc505cca62a0c266", + "compiled_at": "2026-10-10T16:35:26Z", "compiler": "crumb-compile/1", - "digest": "sha256:1c66ac3d3cce9f995c4eb047efa11f56f126d9eb4fb48b0735b1ff5b29e1ec6f", + "digest": "sha256:12add1968290b1fb36dfe09205926457ce7f6adb2e0e84bac8dac26759cacc30", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 260, - "generated_at_commit": "78a7014095431bb50d5e718ab0035a2891e89513", - "source_tree": "sha256:31728b54e286db11569f4cc953d87ede8b3fef5e70827dac790150ff08c99177" + "generated_at_commit": "ec1c8c325064fa50113b1c5c6a6a7e23785f3181", + "source_tree": "sha256:d78d668dc483e55249f48a5c43e9e0f8fc89add266b0e0797236892029fa338d" }, "owner_lane": "", "provenance": { diff --git a/scripts/.crumb b/scripts/.crumb index 082d16d..037979b 100644 --- a/scripts/.crumb +++ b/scripts/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-10T15:59:58Z", + "compiled_at": "2026-10-10T16:35:26Z", "compiler": "crumb-compile/1", - "digest": "sha256:8bb604d86df1aa3f433600354b036dab1734d921530cf48147886a6ebeeabca9", + "digest": "sha256:0ef6bd47b5ed1c28c37208ce84a05a6fccbce4ba41e8b791374251de0562b067", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 11, - "generated_at_commit": "78a7014095431bb50d5e718ab0035a2891e89513", - "source_tree": "sha256:fc28f00940d1199ab2b6a930b0a59905bf4e9729b636d1ec11c1e333ceb858a2" + "generated_at_commit": "ec1c8c325064fa50113b1c5c6a6a7e23785f3181", + "source_tree": "sha256:65c0dbf4190b2a9711883fe00f9ed87f8ed7c5f9b50c76f73c85244141265a7a" }, "owner_lane": "", "provenance": { diff --git a/scripts/rebase-crumb.sh b/scripts/rebase-crumb.sh index 4918785..7354230 100755 --- a/scripts/rebase-crumb.sh +++ b/scripts/rebase-crumb.sh @@ -41,16 +41,29 @@ $GIT checkout -q -B "$B" "origin/$B" || { echo "checkout failed" >&2; exit 4; } rebasing() { [ -d "$($GIT rev-parse --git-path rebase-merge)" ] || [ -d "$($GIT rev-parse --git-path rebase-apply)" ]; } +# Advance past the commit that was just resolved. `rebase --continue` (and --skip) also exit non-zero +# when they stop at the NEXT commit's conflict; that is progress, not failure, so the loop must see it. +# Returns 0 when the loop should look again, 1 on a real failure. +advance() { + GIT_EDITOR=true $GIT rebase --continue >/dev/null 2>&1 && return 0 + rebasing || return 0 + [ -z "$($GIT diff --name-only --diff-filter=U)" ] || return 0 + # A resolved commit that became empty cannot be continued; skip it. + if [ -z "$($GIT diff --cached --name-only)" ]; then + $GIT rebase --skip >/dev/null 2>&1 && return 0 + rebasing || return 0 + [ -z "$($GIT diff --name-only --diff-filter=U)" ] || return 0 + fi + return 1 +} +fail_rebase() { echo "rebase continue failed" >&2; $GIT status --short | head; $GIT rebase --abort; exit 4; } + $GIT rebase -q origin/main >/dev/null 2>&1 while rebasing; do C=$($GIT diff --name-only --diff-filter=U) if [ -z "$C" ]; then - GIT_EDITOR=true $GIT rebase --continue >/dev/null 2>&1 && continue - # A resolved commit that became empty cannot be continued; skip it. - if [ -z "$($GIT diff --cached --name-only)" ]; then - $GIT rebase --skip >/dev/null 2>&1 && continue - fi - echo "rebase continue failed" >&2; $GIT status --short | head; $GIT rebase --abort; exit 4 + advance || fail_rebase + continue fi NONCRUMB=$(echo "$C" | grep -v '\.crumb$' || true) if [ -n "$NONCRUMB" ]; then @@ -66,10 +79,7 @@ while rebasing; do $GIT rm -q -f -- "$f" fi done - GIT_EDITOR=true $GIT rebase --continue >/dev/null 2>&1 || { - if [ -z "$($GIT diff --cached --name-only)" ] && $GIT rebase --skip >/dev/null 2>&1; then continue; fi - echo "rebase continue failed" >&2; $GIT status --short | head; $GIT rebase --abort; exit 4 - } + advance || fail_rebase done if $GIT ls-files '*.crumb' '**/.crumb' | grep -q .; then diff --git a/scripts/test_rebase_crumb.sh b/scripts/test_rebase_crumb.sh index 900ca55..582eb25 100755 --- a/scripts/test_rebase_crumb.sh +++ b/scripts/test_rebase_crumb.sh @@ -123,5 +123,53 @@ OUT=$(GIT="$tmp/bin/racegit" "$script" "$W" feat 2>&1); rc=$? if [ "$rc" = 4 ]; then ok; else no "lease violation exits 4 (rc=$rc): $OUT"; fi check "racer commit not overwritten" test "$(git -C "$O" log -1 --format=%s feat)" = "other" +# 14 branch history already holds a crumb-only commit that conflicts with main's .crumb change +mk t14 +( cd "$tmp/t14/w" && echo oldcompile > .crumb && git add -A && git commit -q -m "crumb compile" && git push -q origin feat ) +advance_main "$tmp/t14/seed" .crumb maincrumb +advance_main "$tmp/t14/seed" main-only.txt m +before=$(ohead) +expect 0 "prior crumb-only commit rebases" "$W" feat +check "t14 push reached origin" test "$(ohead)" = "$(git -C "$W" rev-parse HEAD)" +check "t14 origin head moved" test "$(ohead)" != "$before" +check "t14 rebased onto main" git -C "$W" merge-base --is-ancestor origin/main HEAD +check "t14 old crumb-only commit dropped" test "$(git -C "$W" log --format=%s origin/main..HEAD | grep -c '^crumb compile$')" = 0 +check "t14 last commit is fresh crumb compile" test "$(git -C "$W" log -1 --format=%s)" = "crumb compile (after rebase onto main)" +check "t14 crumb is main's copy plus compile" test "$(cat "$W/.crumb")" = "$(printf 'maincrumb\ncompiled')" +check "t14 feat source change kept" test -f "$W/feat.txt" +check "t14 no rebase left in progress" test ! -d "$W/.git/rebase-merge" + +# 15 two commits in a row conflict on .crumb (a source commit touching .crumb, then a crumb-only commit), +# so `rebase --continue` after the first resolution exits non-zero because it stops at the second conflict +mk t15 +( cd "$tmp/t15/w" && mkdir -p docs && echo d0 > docs/.crumb && echo f2 > feat2.txt && echo srcside > .crumb && git add -A && git commit -q -m "feat2" \ + && echo oc1 > .crumb && echo od1 > docs/.crumb && git add -A && git commit -q -m "crumb compile" \ + && echo oc2 > .crumb && echo od2 > docs/.crumb && git add -A && git commit -q -m "crumb compile" && git push -q origin feat ) +( cd "$tmp/t15/seed" && git checkout -q main && mkdir -p docs && echo mdoc > docs/.crumb && echo maincrumb > .crumb && git add -A && git commit -q -m m1 && git push -q origin main ) +before=$(ohead) +expect 0 "consecutive crumb conflicts rebase" "$W" feat +check "t15 push reached origin" test "$(ohead)" = "$(git -C "$W" rev-parse HEAD)" +check "t15 origin head moved" test "$(ohead)" != "$before" +check "t15 no old crumb compile commits left" test "$(git -C "$W" log --format=%s origin/main..HEAD | grep -c '^crumb compile$')" = 0 +check "t15 last commit is fresh crumb compile" test "$(git -C "$W" log -1 --format=%s)" = "crumb compile (after rebase onto main)" +check "t15 crumb is main's copy plus compile" test "$(cat "$W/.crumb")" = "$(printf 'maincrumb\ncompiled')" +check "t15 feat2 source change kept" test -f "$W/feat2.txt" +check "t15 no rebase left in progress" test ! -d "$W/.git/rebase-merge" + +# 16 stacked branch: feat sits on a base branch (source commit + crumb commit); base is squash-merged into main +mk t16 +( cd "$tmp/t16/w" && git checkout -q -B feat origin/main && echo b > base.txt && git add -A && git commit -q -m "base src" \ + && echo basecrumb > .crumb && git add -A && git commit -q -m "crumb compile" \ + && echo f3 > feat3.txt && git add -A && git commit -q -m "child src" \ + && echo childcrumb > .crumb && git add -A && git commit -q -m "crumb compile" && git push -q -f origin feat ) +( cd "$tmp/t16/seed" && git checkout -q main && echo b > base.txt && echo squashcrumb > .crumb && git add -A && git commit -q -m "squash of base" && git push -q origin main ) +before=$(ohead) +expect 0 "stacked branch after base squash rebases" "$W" feat +check "t16 origin head moved" test "$(ohead)" != "$before" +check "t16 base source not duplicated" test "$(git -C "$W" log --format=%s origin/main..HEAD | grep -c '^base src$')" = 0 +check "t16 child source kept" test -f "$W/feat3.txt" +check "t16 last commit is fresh crumb compile" test "$(git -C "$W" log -1 --format=%s)" = "crumb compile (after rebase onto main)" +check "t16 no old crumb compile commits left" test "$(git -C "$W" log --format=%s origin/main..HEAD | grep -c '^crumb compile$')" = 0 + echo "PASS $pass FAIL $bad" [ "$bad" -eq 0 ]