rebase: cherry-pick: add copyright
[git] / git-rebase--am.sh
1 # This shell script fragment is sourced by git-rebase to implement
2 # its default, fast, patch-based, non-interactive mode.
3 #
4 # Copyright (c) 2010 Junio C Hamano.
5 #
6
7 case "$action" in
8 continue)
9         git am --resolved --resolvemsg="$resolvemsg" &&
10         move_to_original_branch
11         return
12         ;;
13 skip)
14         git am --skip --resolvemsg="$resolvemsg" &&
15         move_to_original_branch
16         return
17         ;;
18 esac
19
20 test -n "$rebase_root" && root_flag=--root
21
22 ret=0
23
24         rm -f "$GIT_DIR/rebased-patches"
25
26         git format-patch -k --stdout --full-index --ignore-if-in-upstream \
27                 --src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter \
28                 $root_flag "$revisions" >"$GIT_DIR/rebased-patches"
29         ret=$?
30
31         if test 0 != $ret
32         then
33                 rm -f "$GIT_DIR/rebased-patches"
34                 case "$head_name" in
35                 refs/heads/*)
36                         git checkout -q "$head_name"
37                         ;;
38                 *)
39                         git checkout -q "$orig_head"
40                         ;;
41                 esac
42
43                 cat >&2 <<-EOF
44
45                 git encountered an error while preparing the patches to replay
46                 these revisions:
47
48                     $revisions
49
50                 As a result, git cannot rebase them.
51                 EOF
52                 return $?
53         fi
54
55         test -n "$GIT_QUIET" && git_am_opt="$git_am_opt -q"
56         git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" <"$GIT_DIR/rebased-patches"
57         ret=$?
58
59         rm -f "$GIT_DIR/rebased-patches"
60
61 if test 0 != $ret
62 then
63         test -d "$state_dir" && write_basic_state
64         return $ret
65 fi
66
67 move_to_original_branch