blob: 3ba9ea52770031c680a433128f9518fa2fb85ef1 (
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
|
#!/bin/sh
list_branches() {
git for-each-ref --sort=-committerdate --format='
d=%(committerdate:short)
r=%(refname)
echo $d ${r#refs/heads}
' refs/heads
}
git update-index --refresh || exit 1
case "$(git diff-index --name-status HEAD)" in
'') ;;
*)
echo "there are local modifications"
exit 1
esac
# reset first
git fetch upstream --progress
git reset --hard upstream/trunk
# then merge branches
git fetch origin --progress
while list_branches && echo -n "> " && read line; do
if ORIGIN_HEAD=$(git rev-parse "origin/$line"); then
LOCAL_HEAD=$(git rev-parse "$line")
if [ "x$LOCAL_HEAD" != "x$ORIGIN_HEAD" ]; then
echo "origin and local differs?"
exit 1
fi
fi
echo "merging branch $line"
while :; do
if git merge --no-edit --no-ff "$line"; then
break
fi
echo -n "merge failed; press a key to retry"
read
done
done
|