]> git.ozlabs.org Git - next-scripts/blob - import-akpm
import-akpm: use --no-edit and --no-stat on the merge
[next-scripts] / import-akpm
1 #!/bin/bash
2
3 log()
4 {
5         echo "$@" | tee -a ../akpm-import.log
6 }
7
8 execute()
9 {
10         log "$" $@
11         "$@" 2>&1 | tee -a ../akpm-import.log
12         [ ${PIPESTATUS[0]} -eq 0 ] || $SHELL -i || {
13                 [ -f "$sfile.orig" ] &&
14                         mv -f "$sfile.orig" "$sfile"
15                 exit 1
16         }
17 }
18
19 name="akpm"
20 mmotm="../../mmotm/text"
21 sfile="$mmotm/series"
22 cpwd=$(pwd)
23
24 base=$(sed -n '1s/^GIT *\([^ ]*\).*$/\1/p' "$mmotm/broken-out/origin.patch")
25 nbase=$(sed -n '1s/^GIT *\([^ ]*\).*$/\1/p' "$mmotm/broken-out/linux-next.patch")
26 log "Importing $name based on $base/$nbase"
27 git rev-parse --verify "$base" >/dev/null || {
28         log "Unknown origin BASE"
29         exit 1
30 }
31 git rev-parse --verify "$nbase" >/dev/null || {
32         log "Unknown linux-next BASE"
33         exit 1
34 }
35
36 mv -f "$sfile" "$sfile.orig"
37 do_echo=echo
38 grep -q NEXT_PATCHES "$sfile.orig" && do_echo=:
39 while read line; do
40         case $line in
41         *NEXT_PATCHES_START*)   do_echo=echo
42                                 ;;
43         *NEXT_PATCHES_END*)     do_echo=:
44                                 ;;
45         esac
46         $do_echo $line
47 done <"$sfile.orig" |
48         sed -e 's/[     ]*#.*$//' -e '/^[       ]*$/d' >"$sfile"
49
50 git show-ref --quiet --verify "refs/heads/quilt/$name" ||
51         execute git branch "quilt/$name" "$base"
52
53 [ -s "$sfile" ] || {
54         log "   quilt series is empty"
55         mv -f "$sfile.orig" "$sfile"
56         execute git update-ref "refs/heads/quilt/$name" "$nbase"
57         exit 0
58 }
59
60 [ -d "../quilt-tmp" ] ||
61         execute git clone -s -l -n -q . ../quilt-tmp
62
63 log '$' cd ../quilt-tmp
64 cd ../quilt-tmp
65 execute git reset --hard "$base"
66 execute git merge --no-edit --no-stat "$nbase" || bash -i || exit 1
67 git branch base
68
69 for f in $(cat "$mmotm/series"); do
70         [ "$f" = "origin.patch" ] && continue
71         [ "$f" = "linux-next.patch" ] && continue
72         execute git am "$mmotm/broken-out/$f" ||
73                 bash -i ||
74                 break
75 done
76
77 log '$' cd $cpwd
78 cd $cpwd
79
80 execute git fetch -f ../quilt-tmp master:"quilt/$name"
81 execute git fetch -f ../quilt-tmp base:"quilt/${name}-base"
82
83 mv -f "$sfile.orig" "$sfile"
84
85 [ -d "../quilt-tmp" ] &&
86         rm -rf ../quilt-tmp
87
88 exit 0