6 while getopts 'ns:' opt; do
12 if [ -f "$SHA1_FILE" ]; then
13 printf '%s: %s exists, so -s is invalid\n' "$0" "$SHA1_FILE" 1>&2
25 tools_dir=$(dirname "$0")
26 . "$tools_dir/common.sh"
30 echo "$@" | tee -a "$LOG_FILE"
38 echo "$_out" | tee -a "$LOG_FILE"
45 linux-next-notify "$1"
48 printf '%s\n' "$2" 1>&2
60 if [ -f "$SHA1_FILE" ]; then
61 previous_tree=$(tail -n1 "$SHA1_FILE" | cut -f1 -d"$_TAB")
62 elif [ -z "$start_from" ]; then
63 cp /dev/null "$LOG_FILE"
65 execute git checkout master
66 execute git reset --hard stable
67 printf 'Name\t\tSHA1\n----\t\t----\n' > "$SHA1_FILE"
72 $2=="git" { printf("git/%s/%s ", $3, $5); }
73 $2=="branch" { printf("branch/%s ", $1); }
74 $2=="switch" { printf("switch/%s/%s ", $3, $4); }' "$CTRL_FILE")
84 if [ -n "$previous_tree" ]; then
85 if [ "$op" = 'git' ] && [ "$arg1" = "$previous_tree" ]; then
89 elif [ -n "$start_from" ]; then
90 if [ "$op" = 'git' ] && [ "$arg1" = "$start_from" ]; then
97 if [ "$op" = "branch" ]; then
99 linux-next-notify "update branch $arg1"
103 if [ "$op" = 'switch' ]; then
105 if [ "$new_branch" = 'master' ]; then
106 old_branch=$(git branch --show-current)
107 if ! [ "$old_branch" = 'master' ]; then
108 if ! git checkout master; then
109 fix_up 'git checkout master failed'
114 if ! git checkout -B "$new_branch" "$base"; then
115 fix_up "git checkout $new_branch failed"
125 h="$tree${branch:+/$branch}"
126 hlog=$(git log -1 --oneline "$h") 2>/dev/null
127 old_head=$(git rev-parse HEAD)
128 if [ -f "../pre-merge/$tree" ]; then
129 while read -r p <&7; do
130 if ! "$bin_dir/do_patch" -n "$p"; then
131 fix_up "premerge patch failed"
133 done 7<"../pre-merge/$tree"
135 log Merging "$h" "($hlog)"
136 check_dups "$tree" HEAD "$h" | tee -a "$LOG_FILE"
137 msg=$(printf "Merge branch '%s' of %s" "${branch:-$tree}" "$(get_url "$tree")")
138 if ! execute git merge -m "$msg" "$h"; then
139 echo Merge failed 1>&2
140 echo "$h" >>../merge.debug
141 git diff >>../merge.debug 2>&1
143 check_unmerged_files "$tree"
145 if git diff 2>&1 | grep -E -q '<<<<<|^\*'; then
146 if [ -f "../merge-fixes/$tree" ]; then
147 echo "Merge fixes exist for this tree:"
148 cat "../merge-fixes/$tree"
150 fix_up "new conflict found merging $tree"
152 # if [ "$(git status --porcelain)" ]; then
153 if ! execute git commit --no-edit -v -a; then
154 fix_up "next commit failed for $tree"
156 execute git diff -M --stat --summary 'HEAD^..'
161 if [ "${#tree}" -lt 8 ]; then
164 printf '%s%s%s\n' "$tree" "$tab" "$(git rev-parse "$h^{}")" >> "$SHA1_FILE"
166 if [ -f "../merge-fixes/$tree" ]; then
167 while read -r p <&7; do
168 if ! "$bin_dir/merge_fix" -n "$p"; then
169 fix_up "merge fix failed for $tree"
171 done 7<"../merge-fixes/$tree"
178 if ! $need_build; then
179 # See if we need to build after merging this tree
180 if [ -n "$(git diff "$old_head"..)" ]; then
184 if ! $need_build; then
188 if [ "$(get_build_flag "$tree")" != "yes" ]; then
189 if ! [ -f "$top_dir/old-versions/$tree" ]; then
194 repo="${build_host:+$build_host:}${build_dir}"
195 if ! git push -f "$repo" HEAD:refs/heads/next; then
196 fix_up "push failed for $tree" "git push failed"
199 if [ -x "../pre-build/$tree" ] &&
200 ! "../pre-build/$tree"; then
201 fix_up "pre-build script failed for $tree" "Prebuild script failed"
203 if ! "$bin_dir/do_build" "$tree"; then
204 report "build failed for $tree" "Build failed - run do_merge when fixed"
208 rm -f "$top_dir/old-versions/$tree"