git: 9452c6943e - main - news: add the ports reset script
Kyle Evans <[email protected]> Fri, 24 Jul 2026 00:41:00 +0000
| Newsgroups | gmane.os.freebsd.devel.cvs.doc |
|---|---|
| Message-ID | <[email protected]> |
The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/doc/commit/?id=9452c6943ef868d8c00962ffe0e34c3a07fec25d commit 9452c6943ef868d8c00962ffe0e34c3a07fec25d Author: Kyle Evans <[email protected]> AuthorDate: 2026-07-23 16:39:51 +0000 Commit: Kyle Evans <[email protected]> CommitDate: 2026-07-24 00:31:04 +0000 news: add the ports reset script Following the freeze of the ports tree announced on 2026-07-22, this script may be used to correct branches that contain the offending object. Note that it contains some commit hashes that need to be replaced if your local branch has changes included that alter these; instructione are included inside. The script was originally written by glebius@, with slight modifications by kevans@ and dhw@. Reviewed by: adrian, dhw, glebius, lwhsu (all previous version) Differential Revision: https://reviews.freebsd.org/D58417 --- .../en/news/2026-ports-freeze/ports-reset.sh | 112 +++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/website/content/en/news/2026-ports-freeze/ports-reset.sh b/website/content/en/news/2026-ports-freeze/ports-reset.sh new file mode 100755 index 0000000000..6708d62a7a --- /dev/null +++ b/website/content/en/news/2026-ports-freeze/ports-reset.sh @@ -0,0 +1,112 @@ +#!/bin/sh -e + +# Note that the hash of this file is recorded in a signed announcement, please +# do not touch it without due consideration. + +cleanup() { + rc=$? + + if [ -n "$tmpf" ]; then + rm -f "$tmpf" + rm -f "$tmpf.import" + fi + + exit "$rc" +} + +me=${0##*/} +tmpf=$(mktemp -t ports-reset) +trap cleanup EXIT + +# +# REPLACE AS NEEDED: +# +# bad1 and bad2 correspond to the following two commits. If your tree or branch +# has local changes mixed in, confirm and replace the commits with your +# equivalent: +# +# commit bb14266f00bb1bac62900477b93e5a7be984cd2f +# Date: Mon Jul 20 22:03:39 2026 -0000 +# +# misc/github-copilot-cli: update 1.0.71 → 1.0.72 +# +# commit f208eb093cebb71adaec5861c76c8369139289d2 +# Date: Tue Jul 21 05:00:50 2026 +# +# misc/github-copilot-cli: Remove inadvertently added file +# +bad1=bb14266f00bb1bac62900477b93e5a7be984cd2f +bad2=f208eb093cebb71adaec5861c76c8369139289d2 +dry_run= +if [ $# -gt 0 ]; then + if [ $1 = "-h" ]; then + echo "Usage: $me [-h] [-n] [bad_hash1] [bad_hash2]" + echo "$me should be invoked while the ports repository to be fixed is the current working directory" + echo "bad_hash1 and bad_hash2 must be ordered exactly as they appear in commit history, with bad_hash1 being older" + exit 0 + fi + if [ $1 = "-n" ]; then + dry_run=echo + shift + fi +fi +if [ $# -gt 0 ]; then + bad1="$1" + shift +fi +if [ $# -gt 0 ]; then + bad2="$1" + shift +fi + +filter="$bad1|$bad2" + +# We use git-fast-export to dump all of the revisions that need to be replayed. +# We dump one revision before the first bad revision to be dropped because the +# first revision in the dump is magic to git-fast-export. +# Note that any commit signatures in the commits to be rewritten will be removed +# by this operation. This makes it reproducible. +/usr/local/bin/git fast-export \ + --show-original-ids \ + --signed-tags=strip \ + --reference-excluded-parents \ + --no-data \ + --mark-tags \ + --use-done-feature \ + ${bad1}~2..HEAD \ + > "$tmpf" + +# Sanity check: did we have the commit in the first place? +if ! grep -q "original-oid $bad1" "$tmpf"; then + 1>&2 echo "This branch does not seem to contain the commit that needs to be pruned." + 1>&2 echo "Please refer to the comments in '$0' for adjustments that may need to be made." + 1>&2 echo "Bailing out without modifying the current branch." + exit 1 +fi + +/usr/bin/sed -En ' +/^from :/d +H +/^$/!{ + $!d +} +x +/original-oid ('$filter')/!{ + s/^\n// + p +}' < "$tmpf" > "$tmpf.import" + +if [ -n "$dry_run" ]; then + echo Would have issued: /usr/local/bin/git fast-import --force --date-format=raw \< "$tmpf.import" + echo "Commits dropped can be inspected in the following somewhat noisy diff:" + echo diff -u "$tmpf" "$tmpf.import" + trap - EXIT +else + /usr/local/bin/git fast-import --force --date-format=raw < "$tmpf.import" + # git-fast-import leaves the contents of the bad commits in the index. + # Clean up to avoid accidents. + git checkout HEAD . + + # This shouldn't happen, but we'd rather be safe than sorry. + echo "Please review your tree for any staged changes that may have been left behind." +fi