Fix upstream-pending: use git --grep instead of shell parsing

The first version read git log through a shell while-loop with a tab IFS, which make
mangled — every commit came out as an 'ambiguous argument' error. git's own --grep and
--invert-grep search the full commit message, including the trailer, and need no
parsing at all.

Upstream: no — tooling for forks.
main
Lasse Edfast 1 week ago
parent bc9f2efaa8
commit 5ad119d148
  1. 14
      Makefile

@ -46,14 +46,10 @@ check-fork-divergence: ## Verify the fork differs from upstream only under deplo
echo "Fork is clean: no differences outside deploy/prod/."; \ echo "Fork is clean: no differences outside deploy/prod/."; \
fi fi
upstream-pending: ## For a fork: list local commits marked "Upstream: yes" that upstream lacks upstream-pending: ## For a fork: list local commits owed upstream
@git fetch --quiet upstream 2>/dev/null || { echo "No 'upstream' remote."; exit 1; } @git fetch --quiet upstream 2>/dev/null || { echo "No 'upstream' remote."; exit 1; }
@echo "Marked for upstream, not yet there:" @echo "Marked 'Upstream: yes' and not yet upstream:"
@git log --format='%h %s%n%b' upstream/main..HEAD 2>/dev/null \ @git log --format=' %h %s' --grep='^Upstream: *[Yy]es' upstream/main..HEAD | grep . || echo " (none)"
| awk '/^[0-9a-f]{7,} /{h=$$0} /^Upstream: *[Yy]es/{print " " h}' \
| grep . || echo " (none)"
@echo @echo
@echo "Unmarked — decide and amend, or ignore:" @echo "No Upstream: marker — decide, then amend the message:"
@git log --format='%H%x09%h %s' upstream/main..HEAD 2>/dev/null | while IFS=$$'\t' read -r sha line; do \ @git log --format=' %h %s' --invert-grep --grep='^Upstream:' upstream/main..HEAD | grep . || echo " (none)"
git log -1 --format='%B' "$$sha" | grep -qi '^Upstream:' || echo " $$line"; \
done | grep . || echo " (none)"

Loading…
Cancel
Save