while read oldrev newrev refname ; do
set_new_commits
echo "$new_commits" | git rev-list --reverse --stdin | while read commit ; do
- cat $GIT_DIR/packed-refs | grep --quiet "$commit"
+ touch "$GIT_DIR/commitnumbers"
+ cat "$GIT_DIR/commitnumbers" | grep --quiet "$commit"
if [ $? -ne 0 ] ; then
- current=$(cat $GIT_DIR/packed-refs | grep "refs/tags/r/" | tail -n 1 | grep -oP "r\/\d+" | grep -oP "\d+")
- if [ $? -ne 0 ] ; then
- next="0"
- else
- next=$(($current + 1))
- fi
- echo "$commit refs/tags/r/$next" >> $GIT_DIR/packed-refs
+ echo "$commit" >> "$GIT_DIR/commitnumbers"
+ number=$(cat "$GIT_DIR/commitnumbers" | grep --line-number "$commit" | grep -oP "^\d+(?=:)")
+ git tag "r/$number" "$commit"
fi
done
done
git push origin master &&
git fetch &&
- test "$(git rev-parse HEAD)" = "$(git rev-parse r/0)"
- test "$(git describe --tags)" = "r/0"
+ test "$(git rev-parse HEAD)" = "$(git rev-parse r/1)"
+ test "$(git describe --tags)" = "r/1"
'
test_expect_success 'assign two new commits' '
git push origin master &&
git fetch &&
- test "$(git rev-parse HEAD)" = "$(git rev-parse r/2)"
- test "$(git describe --tags)" = "r/2"
+ test "$(git rev-parse HEAD)" = "$(git rev-parse r/3)"
+ test "$(git describe --tags)" = "r/3"
- test "$(git rev-parse HEAD^)" = "$(git rev-parse r/1)"
- test "$(git describe --tags HEAD^)" = "r/1"
+ test "$(git rev-parse HEAD^)" = "$(git rev-parse r/2)"
+ test "$(git describe --tags HEAD^)" = "r/2"
'
test_expect_success 'pushing commits to a new branch does not reassign' '
git push origin topica &&
git fetch &&
- ! git rev-parse r/3
+ ! git rev-parse r/4
'
test_done