Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 32 lines (28 sloc) 1.08 KB
#!/bin/bash
#
# Creates commitnumbers as lightweight tags named "r/X" where X increases
# monotonically.
#
# Works by creating a GIT_DIR/commitnumbers file that is a list of all
# commit SHA1s where the commitnumber == the line number of the SHA1 in the
# file.
#
# If you're adding commitnumbers to an existing repo, you can jump start it
# (without the tags, but so you don't start at 0), by:
#
# git rev-list --all > $GIT_DIR/commitnumbers
#
# There is no real reason the tags are named "r/X"--feel free to substitute your
# own prefix or drop it all together. That should probably be a config variable.
#
. $(dirname $0)/functions
while read oldrev newrev refname ; do
set_new_commits
echo "$new_commits" | git rev-list --reverse --stdin | while read commit ; do
if [[ $(grep "$commit" "$GIT_DIR/commitnumbers" 2>/dev/null) == "" ]] ; then
with_lock "$GIT_DIR/commitnumbers.lock" 'echo "$commit $refname" >> "$GIT_DIR/commitnumbers"'
number=$(grep --max-count=1 --line-number "$commit" "$GIT_DIR/commitnumbers" | grep -oP "^\d+(?=:)")
git tag "r/$number" "$commit"
fi
done
done