aboutsummaryrefslogtreecommitdiffstats
path: root/rebase_damon_next_on_mm_unstable.sh
blob: 17db21ffd8aad682a3f97231ea95731769d10237 (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
#!/bin/bash

set -e

if [ $# -ne 1 ] && [ $# -ne 2 ]
then
	echo "Usage: $0 <mainline base> [old mm-unstable]"
	exit 1
fi

mainline_base=$1

if [ $# -eq 2 ]
then
	old_mm_unstable=$2
else
	guess=$(git rev-parse akpm.korg.mm/mm-unstable)
	if git log damon/next --pretty=%H | grep "$guess" --max-count 1
	then
		old_mm_unstable=$guess
	else
		echo "Can't find the old mm-unstable.  Pass it explicitly"
		exit 1
	fi
fi

new_mm_unstable=akpm.korg.mm/mm-unstable

bindir=$(dirname "$0")

if ! "$bindir/ensure_gpg_password.sh"
then
	echo "ensure_gpg_password failed, as expected"
fi
git fetch akpm.korg.mm

old_mm_unstable_commit=$(git rev-parse "$old_mm_unstable")
new_mm_unstable_commit=$(git rev-parse "$new_mm_unstable")
if [ "$old_mm_unstable" = "$new_mm_unstable_commit" ]
then
	echo "No update on mm-unstable"
	exit 0
fi

cp "$bindir/unmerged_commits.sh" ./
merged_commits=$(./unmerged_commits.sh --merged --human_readable \
	"$old_mm_unstable..damon/next" "$mainline_base..$new_mm_unstable")

git branch -M damon/next damon/next.old
git checkout akpm.korg.mm/mm-unstable -b damon/next.new
commits_to_pick=$(./unmerged_commits.sh "$old_mm_unstable..damon/next" \
	"$mainline_base..$new_mm_unstable")
if ! git cherry-pick --allow-empty $commits_to_pick
then
	echo "Cherry-pick failed."
	echo "Resolve it and do 'git branch -M damon/next.new damon/next'"
	exit 1
fi

git branch -M damon/next.new damon/next

echo "Below commits have merged"
echo "$merged_commits"