Created
May 19, 2016 20:24
-
-
Save wellington1993/64993816eab4e9d1e0e77f509c962e12 to your computer and use it in GitHub Desktop.
git-unique-abbrev calc from: How short can Git abbreviate?(Josh Stone)
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
#!/bin/bash | |
# git-unique-abbrev | |
OBJECTS="$(mktemp)" | |
git rev-list --all --objects | cut -c1-40 | sort >"$OBJECTS" | |
printf "%d objects\n" $(wc -l <"$OBJECTS") | |
for abbrev in $(seq 4 40); do | |
DUPES="$(mktemp)" | |
uniq -D -w $abbrev <"$OBJECTS" >"$DUPES" | |
count=$(wc -l <"$DUPES") | |
acount=$(uniq -w $abbrev <"$DUPES" | wc -l) | |
printf "%2d: %d / %d\n" $abbrev $count $acount | |
test $count -eq 0 && cat "$OBJECTS" | |
mv "$DUPES" "$OBJECTS" | |
test $count -eq 0 && break | |
done | |
rm -f "$OBJECTS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment