Skip to content

Instantly share code, notes, and snippets.

@capnslipp
Last active January 12, 2023 23:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save capnslipp/d0ac4dd125d66b6f42ed to your computer and use it in GitHub Desktop.
Save capnslipp/d0ac4dd125d66b6f42ed to your computer and use it in GitHub Desktop.
A small, inefficient, naïvely-written bash script to list all duplicate commits (those with the same patch-id) in a git repo.
#!/usr/bin/env bash
test ! -z "$1" && TARGET_COMMIT_SHA="$1" || TARGET_COMMIT_SHA="HEAD"
TARGET_COMMIT_PATCHID=$(
git show --patch-with-raw "$TARGET_COMMIT_SHA" |
git patch-id |
cut -d' ' -f1
)
MATCHING_COMMIT_SHAS=$(
for c in $(git rev-list --all); do
git show --patch-with-raw "$c" |
git patch-id
done |
fgrep "$TARGET_COMMIT_PATCHID" |
cut -d' ' -f2
)
echo "$MATCHING_COMMIT_SHAS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment