From faace01f2d9bb9555ff372ce0b40e97bf2ee3996 Mon Sep 17 00:00:00 2001 From: cproudlock Date: Sun, 30 Aug 2026 12:48:56 -0400 Subject: [PATCH] Do not offer to promote work that already landed Promotion cherry-picks, which gives the commit a new sha on main. wj-status compared by sha via main..wj, so after promoting ten commits it still listed all ten as unpromoted - and would have invited promoting the same work twice. git cherry compares patch content instead and marks an already-present commit with a leading '-'. When nothing is genuinely outstanding it now says so, counts what has already landed, and shows how far the branch is BEHIND main with the rebase to run. Behind was the state that mattered here and the tool could not express it at all. Scope: product --- tools/wj-status.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/wj-status.sh b/tools/wj-status.sh index d133cd53..f35fe110 100755 --- a/tools/wj-status.sh +++ b/tools/wj-status.sh @@ -44,10 +44,25 @@ if ! git rev-parse --verify --quiet refs/heads/wj >/dev/null; then exit 1 fi -COMMITS="$(git rev-list --reverse "$RANGE")" +# git cherry, not rev-list. Promotion CHERRY-PICKS, which gives the commit a new +# sha on main, so `main..wj` keeps listing work that already landed - and this +# tool would then invite you to promote it a second time. `git cherry` compares +# patch content and marks an already-present commit with a leading '-'. +COMMITS="$(git cherry main wj | awk '$1 == "+" { print $2 }')" + +ALREADY="$(git cherry main wj | awk '$1 == "-" { print $2 }' | wc -l)" if [ -z "$COMMITS" ]; then echo "Nothing on wj that main does not have." + if [ "$ALREADY" -gt 0 ]; then + echo "($ALREADY commit(s) here have already landed on main as cherry-picks.)" + fi + echo + echo "wj is behind main by:" + git log --oneline wj..main | sed 's/^/ /' | head -10 + echo + echo "Rebase it before starting new work:" + echo " git checkout wj && git rebase main" exit 0 fi