while read oldrev newrev refname ; do
set_new_commits
echo "$new_commits" | git rev-list --reverse --stdin | while read commit ; do
- touch "$GIT_DIR/commitnumbers"
- cat "$GIT_DIR/commitnumbers" | grep --quiet "$commit"
- if [ $? -ne 0 ] ; then
- echo "$commit" >> "$GIT_DIR/commitnumbers"
- number=$(cat "$GIT_DIR/commitnumbers" | grep --line-number "$commit" | grep -oP "^\d+(?=:)")
+ 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