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