3 # Creates commitnumbers as lightweight tags named "r/X" where X increases
6 # Works by creating a GIT_DIR/commitnumbers file that is a list of all
7 # commit SHA1s where the commitnumber == the line number of the SHA1 in the
10 # If you're adding commitnumbers to an existing repo, you can jump start it
11 # (without the tags, but so you don't start at 0), by:
13 # git rev-list --all > $GIT_DIR/commitnumbers
15 # There is no real reason the tags are named "r/X"--feel free to substitute your
16 # own prefix or drop it all together. That should probably be a config variable.
19 . $(dirname $0)/functions
21 while read oldrev newrev refname ; do
23 echo "$new_commits" | git rev-list --reverse --stdin | while read commit ; do
24 if [[ $(grep "$commit" "$GIT_DIR/commitnumbers" 2>/dev/null) == "" ]] ; then
25 with_lock "$GIT_DIR/commitnumbers.lock" 'echo "$commit $refname" >> "$GIT_DIR/commitnumbers"'
26 number=$(grep --max-count=1 --line-number "$commit" "$GIT_DIR/commitnumbers" | grep -oP "^\d+(?=:)")
27 git tag "r/$number" "$commit"