1#!/bin/bash
2
3case $1 in
4    v*-dts) ;;
5    '')
6	echo >&2 "No version given"
7	exit 1
8	;;
9    *)
10	echo >&2 "Unexpected version: $1"
11	exit 1
12	;;
13esac
14
15v=$1
16
17set -e
18
19# Use the date of Linus' originally tagged commit for the merge. This might
20# differ from what the commit that the rewritten tag points to, since the
21# orignal commit may have been discarded.
22export GIT_AUTHOR_DATE=$(git log -1 --format=%ad "${v%-dts}")
23if [ ! "${GIT_AUTHOR_DATE}" ] ; then
24    echo >&2 "Unable to determine commit date for merge"
25    exit 1
26fi
27if [ "${v}" = "v2.6.12-rc2-dts" ] ; then
28    auh="--allow-unrelated-histories"
29fi
30git merge $auh --no-edit "${v}-raw"
31git clean -fdqx
32# Use the date of Linus' original tag for the tag.
33case "${v%-dts}" in
34    v2.6.12*|v2.6.13-rc[123])
35        # Commits from v2.6.12-rc2..v2.6.13-rc3 lacked the date. So use the commit's
36        # date.
37        export GIT_COMMITTER_DATE="${GIT_AUTHOR_DATE}"
38        ;;
39    *)
40        export GIT_COMMITTER_DATE="$(git for-each-ref --format='%(taggerdate)' "refs/tags/${v%-dts}")"
41        ;;
42esac
43if [ ! "${GIT_COMMITTER_DATE}" ] ; then
44    echo >&2 "Unable to determine date for tag"
45    exit 1
46fi
47git tag -s -m "Tagging ${v}" -u 695A46C6 "${v}"
48make -k -j12 -s
49