Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 32 lines (28 sloc) 1.103 kb
1d48bd7 Stephen Haberman First pass at sequential commit numbers.
authored
1 #!/bin/sh
f123e6a Stephen Haberman Filling in docs.
authored
2 #
3 # Creates commitnumbers as lightweight tags named "r/X" where X increases
4 # monotonically.
5 #
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
8 # file.
9 #
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:
12 #
13 # git rev-list --all > $GIT_DIR/commitnumbers
14 #
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.
17 #
1d48bd7 Stephen Haberman First pass at sequential commit numbers.
authored
18
19 . $(dirname $0)/functions
20
21 while read oldrev newrev refname ; do
22 set_new_commits
23 echo "$new_commits" | git rev-list --reverse --stdin | while read commit ; do
ee0b664 Stephen Haberman Add a with_lock function to ensure commitnumber appends do not interweav...
authored
24 if [[ $(grep "$commit" "$GIT_DIR/commitnumbers" 2>/dev/null) == "" ]] ; then
3d0c424 Stephen Haberman Store the branch name for the lulz.
authored
25 with_lock "$GIT_DIR/commitnumbers.lock" 'echo "$commit $refname" >> "$GIT_DIR/commitnumbers"'
214d5d8 Stephen Haberman Consolidate cat+grep calls into just grep.
authored
26 number=$(grep --max-count=1 --line-number "$commit" "$GIT_DIR/commitnumbers" | grep -oP "^\d+(?=:)")
8f22e3b Stephen Haberman Append to a separate "commitnumbers" to avoid race conditions.
authored
27 git tag "r/$number" "$commit"
1d48bd7 Stephen Haberman First pass at sequential commit numbers.
authored
28 fi
29 done
30 done
31
Something went wrong with that request. Please try again.