Last active
January 12, 2023 23:27
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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