46cd45ac81d177def8df5e0b0980f1a67db482c4
[git-central.git] / server / post-receive-assign-commit-numbers
1 #!/bin/sh
2
3 . $(dirname $0)/functions
4
5 touch "$GIT_DIR/commitnumbers"
6
7 while read oldrev newrev refname ; do
8         set_new_commits
9         echo "$new_commits" | git rev-list --reverse --stdin | while read commit ; do
10                 if [[ $(grep "$commit" "$GIT_DIR/commitnumbers") == "" ]] ; then
11                         echo "$commit" >> "$GIT_DIR/commitnumbers"
12                         number=$(grep --max-count=1 --line-number "$commit" "$GIT_DIR/commitnumbers" | grep -oP "^\d+(?=:)")
13                         git tag "r/$number" "$commit"
14                 fi
15         done
16 done
17