Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 32 lines (28 sloc) 1.105 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#!/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

Something went wrong with that request. Please try again.