Files
ports/Tools/scripts/git-diff-ports.sh
T
Yuri Victorovich 04f684d5fb Tools/scripts: Add git-diff-ports.sh
This script prints the list of ports with uncommitted changes.
It is called git-diff-ports because it prints the processed output of
'git diff'.

I found is useful while working on ports.
2026-04-23 15:10:32 -07:00

35 lines
884 B
Bash
Executable File

#!/bin/sh
#
# MAINTAINER: yuri@FreeBSD.org
set -o pipefail
export LC_ALL=C
# ----- Dependency check ----------------------------------------------
for dep in git; do
if ! command -v "$dep" >/dev/null 2>&1; then
echo "error: the '$dep' dependency is missing"
exit 1
fi
done
# ----- Repository check -----------------------------------------------
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1 || \
! [ -f "$(git rev-parse --show-toplevel)/Mk/bsd.port.mk" ]; then
echo "error: not a FreeBSD ports repository"
exit 1
fi
# ----- Main logic -------------------------------------------------------
# Output the list of ports with uncommitted changes. If no ports are
# changed the script exits cleanly with no output.
git diff HEAD "$@" |
grep '^diff ' |
grep -v Mk |
sed -E 's|diff --git a/||; s| .*||; s|([^/]+/[^/]+).*|\1|' |
sort |
uniq || true
exit 0