summaryrefslogtreecommitdiff
path: root/ML
blob: 35bf9b35b8e21019ff2f03d6809e3cfbc3af232c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/sh
# Merge later...
 
: ${MASTER:=master}
 
: "${target:=maint}" "${here:=$MASTER}"
 
# Read from RelNotes and find mergeable topics
search_topics () {
	tmp=/tmp/ML.$$
	trap 'rm -f "$tmp"' 0
	git rev-list --parents --first-parent $target..$here >"$tmp"
 
	x40='[0-9a-f]'
	x40="$x40$x40$x40$x40$x40"
	x40="$x40$x40$x40$x40$x40$x40$x40$x40"
	sed -n -e 's/^   (merge \([0-9a-f]*\) \([^ ]*\) later to maint.*/\1 \2/p' |
	while read sha1 topic
	do
		if ! full_sha1=$(git rev-parse --verify "$sha1")
		then
			echo >&2 "Not found: $sha1 $topic"
			continue
		fi
 
		comment=
		if ! git show-ref --quiet --verify "refs/heads/$topic"
		then
			comment="$topic gone"
			tip=$full_sha1 topic=$sha1
		elif tip=$(git rev-parse --verify "refs/heads/$topic") &&
		     test "$tip" != "$full_sha1"
		then
			echo >&2 "$topic # $tip moved from $sha1"
			continue
		fi
 
		ago= lg=0
		fp=$(
		    sed -ne "s/^\($x40\) $x40 $tip"'$/\1/p' "$tmp"
		) &&
		test -n "$fp" &&
		ago=$(
		    git show -s --format='%ad' --date=short $fp
		) &&
		lg=$(git log --oneline $target..$tip | wc -l)
		if test $lg != 0
		then
			echo "$topic # $lg${ago+ ($ago)}${comment+ $comment}"
		else
			echo "# $topic already merged${ago+ ($ago)}${comment+ $comment}"
		fi
	done
}
 
while	case "$#,$1" in
	0,*)
		break ;;
	*,-t)
		target=${2?"-t target???"}
		git show-ref --quiet --verify "refs/heads/$target" || {
			echo >&2 "$target: no such branch"
			exit 1
		}
		shift ;;
	*)
		break ;;
	esac
do
	shift
done
 
case $# in
0)
	search_topics
	exit $?
	;;
esac
 
for topic
do
	sha1=$(git rev-parse --short $topic)
	echo "   (merge $sha1 $topic later to maint)."
done