Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
Junio C Hamano | d64e6b0 | 2006-02-18 20:51:26 -0800 | [diff] [blame] | 3 | # Copyright (c) 2005, 2006 Junio C Hamano |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 4 | |
Jeff King | c149184 | 2008-03-01 01:22:55 -0500 | [diff] [blame] | 5 | SUBDIRECTORY_OK=Yes |
Pierre Habouzit | 78443d9 | 2007-11-04 11:30:57 +0100 | [diff] [blame] | 6 | OPTIONS_KEEPDASHDASH= |
| 7 | OPTIONS_SPEC="\ |
Junio C Hamano | 588c038 | 2008-07-16 17:22:50 -0700 | [diff] [blame] | 8 | git am [options] [<mbox>|<Maildir>...] |
Stephan Beyer | 09f8d05 | 2008-07-25 20:22:23 +0200 | [diff] [blame] | 9 | git am [options] (--resolved | --skip | --abort) |
Pierre Habouzit | 78443d9 | 2007-11-04 11:30:57 +0100 | [diff] [blame] | 10 | -- |
Junio C Hamano | 66006c6 | 2007-11-08 23:04:31 -0800 | [diff] [blame] | 11 | i,interactive run interactively |
Jay Soffian | 98ef23b | 2009-01-28 10:03:10 -0500 | [diff] [blame] | 12 | b,binary* (historical option -- no-op) |
Pierre Habouzit | 78443d9 | 2007-11-04 11:30:57 +0100 | [diff] [blame] | 13 | 3,3way allow fall back on 3way merging if needed |
| 14 | s,signoff add a Signed-off-by line to the commit message |
| 15 | u,utf8 recode into utf8 (default) |
Jörg Sommer | fe1fa94 | 2008-02-03 00:58:06 +0100 | [diff] [blame] | 16 | k,keep pass -k flag to git-mailinfo |
Pierre Habouzit | 78443d9 | 2007-11-04 11:30:57 +0100 | [diff] [blame] | 17 | whitespace= pass it through git-apply |
Junio C Hamano | b47dfe9 | 2009-01-11 22:21:48 -0800 | [diff] [blame] | 18 | directory= pass it through git-apply |
Pierre Habouzit | 78443d9 | 2007-11-04 11:30:57 +0100 | [diff] [blame] | 19 | C= pass it through git-apply |
| 20 | p= pass it through git-apply |
martin f. krafft | b80da42 | 2009-01-23 11:31:21 +1100 | [diff] [blame] | 21 | reject pass it through git-apply |
Pierre Habouzit | 78443d9 | 2007-11-04 11:30:57 +0100 | [diff] [blame] | 22 | resolvemsg= override error message when patch failure occurs |
| 23 | r,resolved to be used after a patch failure |
Junio C Hamano | 3041c32 | 2008-03-04 00:25:06 -0800 | [diff] [blame] | 24 | skip skip the current patch |
Nanako Shiraishi | 3e5057a | 2008-07-16 19:39:10 +0900 | [diff] [blame] | 25 | abort restore the original branch and abort the patching operation. |
Junio C Hamano | 3f01ad6 | 2009-01-22 16:14:58 -0800 | [diff] [blame] | 26 | committer-date-is-author-date lie about committer date |
Nanako Shiraishi | a79ec62 | 2009-01-24 10:18:02 +0900 | [diff] [blame] | 27 | ignore-date use current timestamp for author date |
Jay Soffian | 98ef23b | 2009-01-28 10:03:10 -0500 | [diff] [blame] | 28 | rebasing* (internal use for git-rebase)" |
Pierre Habouzit | 78443d9 | 2007-11-04 11:30:57 +0100 | [diff] [blame] | 29 | |
freku045@student.liu.se | cf1fe88 | 2005-12-13 23:30:31 +0100 | [diff] [blame] | 30 | . git-sh-setup |
Junio C Hamano | bb034f8 | 2008-03-04 00:25:04 -0800 | [diff] [blame] | 31 | prefix=$(git rev-parse --show-prefix) |
Shawn O. Pearce | f947413 | 2006-12-28 02:34:48 -0500 | [diff] [blame] | 32 | set_reflog_action am |
Shawn O. Pearce | 7eff28a | 2006-12-30 23:32:38 -0500 | [diff] [blame] | 33 | require_work_tree |
Jeff King | c149184 | 2008-03-01 01:22:55 -0500 | [diff] [blame] | 34 | cd_to_toplevel |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 35 | |
Stephan Beyer | 460abee | 2008-07-12 17:46:59 +0200 | [diff] [blame] | 36 | git var GIT_COMMITTER_IDENT >/dev/null || |
| 37 | die "You need to set your committer info first" |
Junio C Hamano | d64e6b0 | 2006-02-18 20:51:26 -0800 | [diff] [blame] | 38 | |
Nanako Shiraishi | f79d4c8 | 2009-04-10 09:34:42 +0900 | [diff] [blame] | 39 | if git rev-parse --verify -q HEAD >/dev/null |
| 40 | then |
| 41 | HAS_HEAD=yes |
| 42 | else |
| 43 | HAS_HEAD= |
| 44 | fi |
| 45 | |
Junio C Hamano | b47dfe9 | 2009-01-11 22:21:48 -0800 | [diff] [blame] | 46 | sq () { |
Christian Couder | 47c9739 | 2009-04-24 08:29:01 +0200 | [diff] [blame] | 47 | git rev-parse --sq-quote "$@" |
Junio C Hamano | b47dfe9 | 2009-01-11 22:21:48 -0800 | [diff] [blame] | 48 | } |
| 49 | |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 50 | stop_here () { |
| 51 | echo "$1" >"$dotest/next" |
| 52 | exit 1 |
| 53 | } |
| 54 | |
Robert Shearman | ced9456 | 2006-05-02 13:32:43 +0100 | [diff] [blame] | 55 | stop_here_user_resolve () { |
Sean | cc12005 | 2006-05-13 23:34:08 -0400 | [diff] [blame] | 56 | if [ -n "$resolvemsg" ]; then |
Jeff King | a23bfae | 2007-05-26 00:33:03 -0700 | [diff] [blame] | 57 | printf '%s\n' "$resolvemsg" |
Sean | cc12005 | 2006-05-13 23:34:08 -0400 | [diff] [blame] | 58 | stop_here $1 |
| 59 | fi |
Olivier Marin | 75e1645 | 2008-07-21 16:12:20 +0200 | [diff] [blame] | 60 | cmdline="git am" |
Robert Shearman | ced9456 | 2006-05-02 13:32:43 +0100 | [diff] [blame] | 61 | if test '' != "$interactive" |
| 62 | then |
| 63 | cmdline="$cmdline -i" |
| 64 | fi |
| 65 | if test '' != "$threeway" |
| 66 | then |
| 67 | cmdline="$cmdline -3" |
| 68 | fi |
Robert Shearman | ced9456 | 2006-05-02 13:32:43 +0100 | [diff] [blame] | 69 | echo "When you have resolved this problem run \"$cmdline --resolved\"." |
| 70 | echo "If you would prefer to skip this patch, instead run \"$cmdline --skip\"." |
Nanako Shiraishi | 3e5057a | 2008-07-16 19:39:10 +0900 | [diff] [blame] | 71 | echo "To restore the original branch and stop patching run \"$cmdline --abort\"." |
Robert Shearman | ced9456 | 2006-05-02 13:32:43 +0100 | [diff] [blame] | 72 | |
| 73 | stop_here $1 |
| 74 | } |
| 75 | |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 76 | go_next () { |
| 77 | rm -f "$dotest/$msgnum" "$dotest/msg" "$dotest/msg-clean" \ |
| 78 | "$dotest/patch" "$dotest/info" |
| 79 | echo "$next" >"$dotest/next" |
| 80 | this=$next |
| 81 | } |
| 82 | |
Junio C Hamano | fd7bcfb | 2006-08-12 16:16:47 -0700 | [diff] [blame] | 83 | cannot_fallback () { |
| 84 | echo "$1" |
| 85 | echo "Cannot fall back to three-way merge." |
| 86 | exit 1 |
| 87 | } |
| 88 | |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 89 | fall_back_3way () { |
| 90 | O_OBJECT=`cd "$GIT_OBJECT_DIRECTORY" && pwd` |
| 91 | |
| 92 | rm -fr "$dotest"/patch-merge-* |
| 93 | mkdir "$dotest/patch-merge-tmp-dir" |
| 94 | |
| 95 | # First see if the patch records the index info that we can use. |
Johannes Schindelin | 7a98869 | 2007-09-17 23:34:06 +0100 | [diff] [blame] | 96 | git apply --build-fake-ancestor "$dotest/patch-merge-tmp-index" \ |
| 97 | "$dotest/patch" && |
Junio C Hamano | fd7bcfb | 2006-08-12 16:16:47 -0700 | [diff] [blame] | 98 | GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \ |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 99 | git write-tree >"$dotest/patch-merge-base+" || |
Junio C Hamano | b1440cc | 2007-02-24 01:05:27 -0800 | [diff] [blame] | 100 | cannot_fallback "Repository lacks necessary blobs to fall back on 3-way merge." |
Junio C Hamano | fd7bcfb | 2006-08-12 16:16:47 -0700 | [diff] [blame] | 101 | |
| 102 | echo Using index info to reconstruct a base tree... |
| 103 | if GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \ |
Stephan Beyer | cb3a160 | 2008-08-09 01:28:54 +0200 | [diff] [blame] | 104 | git apply --cached <"$dotest/patch" |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 105 | then |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 106 | mv "$dotest/patch-merge-base+" "$dotest/patch-merge-base" |
| 107 | mv "$dotest/patch-merge-tmp-index" "$dotest/patch-merge-index" |
Junio C Hamano | fd7bcfb | 2006-08-12 16:16:47 -0700 | [diff] [blame] | 108 | else |
| 109 | cannot_fallback "Did you hand edit your patch? |
| 110 | It does not apply to blobs recorded in its index." |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 111 | fi |
| 112 | |
| 113 | test -f "$dotest/patch-merge-index" && |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 114 | his_tree=$(GIT_INDEX_FILE="$dotest/patch-merge-index" git write-tree) && |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 115 | orig_tree=$(cat "$dotest/patch-merge-base") && |
| 116 | rm -fr "$dotest"/patch-merge-* || exit 1 |
| 117 | |
| 118 | echo Falling back to patching base and 3-way merge... |
| 119 | |
| 120 | # This is not so wrong. Depending on which base we picked, |
| 121 | # orig_tree may be wildly different from ours, but his_tree |
| 122 | # has the same set of wildly different changes in parts the |
Shawn O. Pearce | 579c9bb | 2006-12-28 02:35:27 -0500 | [diff] [blame] | 123 | # patch did not touch, so recursive ends up canceling them, |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 124 | # saying that we reverted all those changes. |
| 125 | |
Linus Torvalds | 2e6e3e829 | 2008-04-15 12:56:50 -0700 | [diff] [blame] | 126 | eval GITHEAD_$his_tree='"$FIRSTLINE"' |
Shawn O. Pearce | 579c9bb | 2006-12-28 02:35:27 -0500 | [diff] [blame] | 127 | export GITHEAD_$his_tree |
| 128 | git-merge-recursive $orig_tree -- HEAD $his_tree || { |
Johannes Schindelin | b4372ef | 2007-07-06 13:05:59 +0100 | [diff] [blame] | 129 | git rerere |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 130 | echo Failed to merge in the changes. |
| 131 | exit 1 |
| 132 | } |
Shawn O. Pearce | 579c9bb | 2006-12-28 02:35:27 -0500 | [diff] [blame] | 133 | unset GITHEAD_$his_tree |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | prec=4 |
Johannes Schindelin | 51ef1da | 2008-07-21 12:51:02 +0200 | [diff] [blame] | 137 | dotest="$GIT_DIR/rebase-apply" |
Junio C Hamano | a200337 | 2008-12-04 15:38:27 -0800 | [diff] [blame] | 138 | sign= utf8=t keep= skip= interactive= resolved= rebasing= abort= |
Gerrit Pape | 3f0a8f3 | 2007-08-06 14:15:30 +0000 | [diff] [blame] | 139 | resolvemsg= resume= |
Michael S. Tsirkin | 67dad68 | 2007-02-08 15:57:08 +0200 | [diff] [blame] | 140 | git_apply_opt= |
Junio C Hamano | 3f01ad6 | 2009-01-22 16:14:58 -0800 | [diff] [blame] | 141 | committer_date_is_author_date= |
Nanako Shiraishi | a79ec62 | 2009-01-24 10:18:02 +0900 | [diff] [blame] | 142 | ignore_date= |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 143 | |
David Kastrup | 822f7c7 | 2007-09-23 22:42:08 +0200 | [diff] [blame] | 144 | while test $# != 0 |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 145 | do |
| 146 | case "$1" in |
Pierre Habouzit | 78443d9 | 2007-11-04 11:30:57 +0100 | [diff] [blame] | 147 | -i|--interactive) |
| 148 | interactive=t ;; |
| 149 | -b|--binary) |
Stephan Beyer | cb3a160 | 2008-08-09 01:28:54 +0200 | [diff] [blame] | 150 | : ;; |
Pierre Habouzit | 78443d9 | 2007-11-04 11:30:57 +0100 | [diff] [blame] | 151 | -3|--3way) |
| 152 | threeway=t ;; |
Johannes Sixt | dfdd7e6 | 2007-11-06 21:33:58 +0100 | [diff] [blame] | 153 | -s|--signoff) |
Pierre Habouzit | 78443d9 | 2007-11-04 11:30:57 +0100 | [diff] [blame] | 154 | sign=t ;; |
| 155 | -u|--utf8) |
| 156 | utf8=t ;; # this is now default |
| 157 | --no-utf8) |
| 158 | utf8= ;; |
| 159 | -k|--keep) |
| 160 | keep=t ;; |
| 161 | -r|--resolved) |
| 162 | resolved=t ;; |
| 163 | --skip) |
| 164 | skip=t ;; |
Nanako Shiraishi | 3e5057a | 2008-07-16 19:39:10 +0900 | [diff] [blame] | 165 | --abort) |
| 166 | abort=t ;; |
Junio C Hamano | 3041c32 | 2008-03-04 00:25:06 -0800 | [diff] [blame] | 167 | --rebasing) |
Stephan Beyer | cb3a160 | 2008-08-09 01:28:54 +0200 | [diff] [blame] | 168 | rebasing=t threeway=t keep=t ;; |
Pierre Habouzit | 78443d9 | 2007-11-04 11:30:57 +0100 | [diff] [blame] | 169 | -d|--dotest) |
Junio C Hamano | e72c740 | 2008-03-04 00:25:05 -0800 | [diff] [blame] | 170 | die "-d option is no longer supported. Do not use." |
| 171 | ;; |
Pierre Habouzit | 78443d9 | 2007-11-04 11:30:57 +0100 | [diff] [blame] | 172 | --resolvemsg) |
| 173 | shift; resolvemsg=$1 ;; |
Junio C Hamano | b47dfe9 | 2009-01-11 22:21:48 -0800 | [diff] [blame] | 174 | --whitespace|--directory) |
| 175 | git_apply_opt="$git_apply_opt $(sq "$1=$2")"; shift ;; |
Pierre Habouzit | 78443d9 | 2007-11-04 11:30:57 +0100 | [diff] [blame] | 176 | -C|-p) |
Junio C Hamano | b47dfe9 | 2009-01-11 22:21:48 -0800 | [diff] [blame] | 177 | git_apply_opt="$git_apply_opt $(sq "$1$2")"; shift ;; |
martin f. krafft | b80da42 | 2009-01-23 11:31:21 +1100 | [diff] [blame] | 178 | --reject) |
| 179 | git_apply_opt="$git_apply_opt $1" ;; |
Junio C Hamano | 3f01ad6 | 2009-01-22 16:14:58 -0800 | [diff] [blame] | 180 | --committer-date-is-author-date) |
| 181 | committer_date_is_author_date=t ;; |
Nanako Shiraishi | a79ec62 | 2009-01-24 10:18:02 +0900 | [diff] [blame] | 182 | --ignore-date) |
| 183 | ignore_date=t ;; |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 184 | --) |
Pierre Habouzit | 78443d9 | 2007-11-04 11:30:57 +0100 | [diff] [blame] | 185 | shift; break ;; |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 186 | *) |
Pierre Habouzit | 78443d9 | 2007-11-04 11:30:57 +0100 | [diff] [blame] | 187 | usage ;; |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 188 | esac |
Pierre Habouzit | 78443d9 | 2007-11-04 11:30:57 +0100 | [diff] [blame] | 189 | shift |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 190 | done |
| 191 | |
Junio C Hamano | 0c15cc9 | 2005-11-16 00:19:32 -0800 | [diff] [blame] | 192 | # If the dotest directory exists, but we have finished applying all the |
| 193 | # patches in them, clear it out. |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 194 | if test -d "$dotest" && |
| 195 | last=$(cat "$dotest/last") && |
| 196 | next=$(cat "$dotest/next") && |
| 197 | test $# != 0 && |
| 198 | test "$next" -gt "$last" |
| 199 | then |
| 200 | rm -fr "$dotest" |
| 201 | fi |
| 202 | |
| 203 | if test -d "$dotest" |
| 204 | then |
Nanako Shiraishi | 3e5057a | 2008-07-16 19:39:10 +0900 | [diff] [blame] | 205 | case "$#,$skip$resolved$abort" in |
Junio C Hamano | c95b138 | 2006-09-15 23:19:02 -0700 | [diff] [blame] | 206 | 0,*t*) |
| 207 | # Explicit resume command and we do not have file, so |
| 208 | # we are happy. |
| 209 | : ;; |
| 210 | 0,) |
| 211 | # No file input but without resume parameters; catch |
| 212 | # user error to feed us a patch from standard input |
Junio C Hamano | e72c740 | 2008-03-04 00:25:05 -0800 | [diff] [blame] | 213 | # when there is already $dotest. This is somewhat |
Junio C Hamano | c95b138 | 2006-09-15 23:19:02 -0700 | [diff] [blame] | 214 | # unreliable -- stdin could be /dev/null for example |
| 215 | # and the caller did not intend to feed us a patch but |
| 216 | # wanted to continue unattended. |
Jay Soffian | 98ef23b | 2009-01-28 10:03:10 -0500 | [diff] [blame] | 217 | test -t 0 |
Junio C Hamano | c95b138 | 2006-09-15 23:19:02 -0700 | [diff] [blame] | 218 | ;; |
| 219 | *) |
| 220 | false |
| 221 | ;; |
| 222 | esac || |
Johannes Schindelin | 28ed6e7 | 2008-07-16 03:33:44 +0200 | [diff] [blame] | 223 | die "previous rebase directory $dotest still exists but mbox given." |
Junio C Hamano | 271440e | 2005-10-25 23:35:37 -0700 | [diff] [blame] | 224 | resume=yes |
Nanako Shiraishi | 3e5057a | 2008-07-16 19:39:10 +0900 | [diff] [blame] | 225 | |
Olivier Marin | 95f8ebb | 2008-07-21 15:39:06 +0200 | [diff] [blame] | 226 | case "$skip,$abort" in |
Junio C Hamano | 2d56a13 | 2009-02-26 11:24:29 -0800 | [diff] [blame] | 227 | t,t) |
| 228 | die "Please make up your mind. --skip or --abort?" |
| 229 | ;; |
Olivier Marin | 95f8ebb | 2008-07-21 15:39:06 +0200 | [diff] [blame] | 230 | t,) |
| 231 | git rerere clear |
| 232 | git read-tree --reset -u HEAD HEAD |
| 233 | orig_head=$(cat "$GIT_DIR/ORIG_HEAD") |
| 234 | git reset HEAD |
| 235 | git update-ref ORIG_HEAD $orig_head |
| 236 | ;; |
| 237 | ,t) |
Junio C Hamano | 2d56a13 | 2009-02-26 11:24:29 -0800 | [diff] [blame] | 238 | if test -f "$dotest/rebasing" |
| 239 | then |
| 240 | exec git rebase --abort |
| 241 | fi |
Nanako Shiraishi | 3e5057a | 2008-07-16 19:39:10 +0900 | [diff] [blame] | 242 | git rerere clear |
Michael J Gruber | c767184 | 2009-02-26 10:52:53 +0100 | [diff] [blame] | 243 | test -f "$dotest/dirtyindex" || { |
| 244 | git read-tree --reset -u HEAD ORIG_HEAD |
| 245 | git reset ORIG_HEAD |
| 246 | } |
Nanako Shiraishi | 3e5057a | 2008-07-16 19:39:10 +0900 | [diff] [blame] | 247 | rm -fr "$dotest" |
| 248 | exit ;; |
| 249 | esac |
Michael J Gruber | c767184 | 2009-02-26 10:52:53 +0100 | [diff] [blame] | 250 | rm -f "$dotest/dirtyindex" |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 251 | else |
Nanako Shiraishi | 3e5057a | 2008-07-16 19:39:10 +0900 | [diff] [blame] | 252 | # Make sure we are not given --skip, --resolved, nor --abort |
| 253 | test "$skip$resolved$abort" = "" || |
Sean | cc12005 | 2006-05-13 23:34:08 -0400 | [diff] [blame] | 254 | die "Resolve operation not in progress, we are not resuming." |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 255 | |
| 256 | # Start afresh. |
| 257 | mkdir -p "$dotest" || exit |
| 258 | |
Junio C Hamano | bb034f8 | 2008-03-04 00:25:04 -0800 | [diff] [blame] | 259 | if test -n "$prefix" && test $# != 0 |
| 260 | then |
| 261 | first=t |
| 262 | for arg |
| 263 | do |
| 264 | test -n "$first" && { |
| 265 | set x |
| 266 | first= |
| 267 | } |
| 268 | case "$arg" in |
| 269 | /*) |
| 270 | set "$@" "$arg" ;; |
| 271 | *) |
| 272 | set "$@" "$prefix$arg" ;; |
| 273 | esac |
| 274 | done |
| 275 | shift |
| 276 | fi |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 277 | git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" || { |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 278 | rm -fr "$dotest" |
| 279 | exit 1 |
| 280 | } |
| 281 | |
Junio C Hamano | 22db240 | 2008-12-04 15:38:27 -0800 | [diff] [blame] | 282 | # -s, -u, -k, --whitespace, -3, -C and -p flags are kept |
Junio C Hamano | a200337 | 2008-12-04 15:38:27 -0800 | [diff] [blame] | 283 | # for the resuming session after a patch failure. |
Junio C Hamano | 22db240 | 2008-12-04 15:38:27 -0800 | [diff] [blame] | 284 | # -i can and must be given when resuming. |
Junio C Hamano | 9b9f5a2 | 2008-12-05 11:19:43 -0800 | [diff] [blame] | 285 | echo " $git_apply_opt" >"$dotest/apply-opt" |
Junio C Hamano | 22db240 | 2008-12-04 15:38:27 -0800 | [diff] [blame] | 286 | echo "$threeway" >"$dotest/threeway" |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 287 | echo "$sign" >"$dotest/sign" |
| 288 | echo "$utf8" >"$dotest/utf8" |
| 289 | echo "$keep" >"$dotest/keep" |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 290 | echo 1 >"$dotest/next" |
Junio C Hamano | 3041c32 | 2008-03-04 00:25:06 -0800 | [diff] [blame] | 291 | if test -n "$rebasing" |
| 292 | then |
| 293 | : >"$dotest/rebasing" |
| 294 | else |
| 295 | : >"$dotest/applying" |
Nanako Shiraishi | f79d4c8 | 2009-04-10 09:34:42 +0900 | [diff] [blame] | 296 | if test -n "$HAS_HEAD" |
| 297 | then |
| 298 | git update-ref ORIG_HEAD HEAD |
| 299 | else |
| 300 | git update-ref -d ORIG_HEAD >/dev/null 2>&1 |
| 301 | fi |
Junio C Hamano | 3041c32 | 2008-03-04 00:25:06 -0800 | [diff] [blame] | 302 | fi |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 303 | fi |
| 304 | |
Junio C Hamano | 0c15cc9 | 2005-11-16 00:19:32 -0800 | [diff] [blame] | 305 | case "$resolved" in |
| 306 | '') |
Nanako Shiraishi | f79d4c8 | 2009-04-10 09:34:42 +0900 | [diff] [blame] | 307 | case "$HAS_HEAD" in |
| 308 | '') |
| 309 | files=$(git ls-files) ;; |
| 310 | ?*) |
| 311 | files=$(git diff-index --cached --name-only HEAD --) ;; |
| 312 | esac || exit |
Michael J Gruber | c767184 | 2009-02-26 10:52:53 +0100 | [diff] [blame] | 313 | if test "$files" |
| 314 | then |
Nanako Shiraishi | f79d4c8 | 2009-04-10 09:34:42 +0900 | [diff] [blame] | 315 | test -n "$HAS_HEAD" && : >"$dotest/dirtyindex" |
Michael J Gruber | c767184 | 2009-02-26 10:52:53 +0100 | [diff] [blame] | 316 | die "Dirty index: cannot apply patches (dirty: $files)" |
| 317 | fi |
Junio C Hamano | 0c15cc9 | 2005-11-16 00:19:32 -0800 | [diff] [blame] | 318 | esac |
| 319 | |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 320 | if test "$(cat "$dotest/utf8")" = t |
| 321 | then |
| 322 | utf8=-u |
Junio C Hamano | bb1091a | 2007-01-09 21:31:36 -0800 | [diff] [blame] | 323 | else |
| 324 | utf8=-n |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 325 | fi |
| 326 | if test "$(cat "$dotest/keep")" = t |
| 327 | then |
| 328 | keep=-k |
| 329 | fi |
Junio C Hamano | 22db240 | 2008-12-04 15:38:27 -0800 | [diff] [blame] | 330 | if test "$(cat "$dotest/threeway")" = t |
| 331 | then |
| 332 | threeway=t |
| 333 | fi |
Junio C Hamano | 9b9f5a2 | 2008-12-05 11:19:43 -0800 | [diff] [blame] | 334 | git_apply_opt=$(cat "$dotest/apply-opt") |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 335 | if test "$(cat "$dotest/sign")" = t |
| 336 | then |
Todd Zullinger | 5354a56 | 2008-07-30 13:48:33 -0400 | [diff] [blame] | 337 | SIGNOFF=`git var GIT_COMMITTER_IDENT | sed -e ' |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 338 | s/>.*/>/ |
| 339 | s/^/Signed-off-by: /' |
| 340 | ` |
| 341 | else |
| 342 | SIGNOFF= |
| 343 | fi |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 344 | |
| 345 | last=`cat "$dotest/last"` |
| 346 | this=`cat "$dotest/next"` |
| 347 | if test "$skip" = t |
| 348 | then |
| 349 | this=`expr "$this" + 1` |
Jan Harkes | 6922471 | 2005-12-17 01:01:06 -0500 | [diff] [blame] | 350 | resume= |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 351 | fi |
| 352 | |
| 353 | if test "$this" -gt "$last" |
| 354 | then |
| 355 | echo Nothing to do. |
| 356 | rm -fr "$dotest" |
| 357 | exit |
| 358 | fi |
| 359 | |
| 360 | while test "$this" -le "$last" |
| 361 | do |
| 362 | msgnum=`printf "%0${prec}d" $this` |
| 363 | next=`expr "$this" + 1` |
| 364 | test -f "$dotest/$msgnum" || { |
Jan Harkes | 6922471 | 2005-12-17 01:01:06 -0500 | [diff] [blame] | 365 | resume= |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 366 | go_next |
| 367 | continue |
| 368 | } |
Junio C Hamano | 0c15cc9 | 2005-11-16 00:19:32 -0800 | [diff] [blame] | 369 | |
| 370 | # If we are not resuming, parse and extract the patch information |
| 371 | # into separate files: |
| 372 | # - info records the authorship and title |
| 373 | # - msg is the rest of commit log message |
| 374 | # - patch is the patch body. |
| 375 | # |
| 376 | # When we are resuming, these files are either already prepared |
| 377 | # by the user, or the user can tell us to do so by --resolved flag. |
Junio C Hamano | 271440e | 2005-10-25 23:35:37 -0700 | [diff] [blame] | 378 | case "$resume" in |
| 379 | '') |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 380 | git mailinfo $keep $utf8 "$dotest/msg" "$dotest/patch" \ |
Junio C Hamano | 271440e | 2005-10-25 23:35:37 -0700 | [diff] [blame] | 381 | <"$dotest/$msgnum" >"$dotest/info" || |
| 382 | stop_here $this |
Johannes Schindelin | ca193cf | 2007-07-24 01:02:25 +0100 | [diff] [blame] | 383 | |
| 384 | # skip pine's internal folder data |
| 385 | grep '^Author: Mail System Internal Data$' \ |
| 386 | <"$dotest"/info >/dev/null && |
| 387 | go_next && continue |
| 388 | |
Johannes Schindelin | 28ed6e7 | 2008-07-16 03:33:44 +0200 | [diff] [blame] | 389 | test -s "$dotest/patch" || { |
Josh Triplett | 6777c38 | 2007-04-23 17:32:04 -0700 | [diff] [blame] | 390 | echo "Patch is empty. Was it split wrong?" |
Don Zickus | 87ab799 | 2007-03-12 15:52:04 -0400 | [diff] [blame] | 391 | stop_here $this |
| 392 | } |
Junio C Hamano | 5e835ca | 2008-04-16 12:50:48 -0700 | [diff] [blame] | 393 | if test -f "$dotest/rebasing" && |
| 394 | commit=$(sed -e 's/^From \([0-9a-f]*\) .*/\1/' \ |
| 395 | -e q "$dotest/$msgnum") && |
| 396 | test "$(git cat-file -t "$commit")" = commit |
| 397 | then |
| 398 | git cat-file commit "$commit" | |
| 399 | sed -e '1,/^$/d' >"$dotest/msg-clean" |
| 400 | else |
| 401 | SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$dotest/info")" |
| 402 | case "$keep_subject" in -k) SUBJECT="[PATCH] $SUBJECT" ;; esac |
Linus Torvalds | 2e6e3e829 | 2008-04-15 12:56:50 -0700 | [diff] [blame] | 403 | |
Junio C Hamano | 41a3e3a | 2008-04-19 23:01:51 -0700 | [diff] [blame] | 404 | (printf '%s\n\n' "$SUBJECT"; cat "$dotest/msg") | |
Junio C Hamano | 5e835ca | 2008-04-16 12:50:48 -0700 | [diff] [blame] | 405 | git stripspace > "$dotest/msg-clean" |
| 406 | fi |
Junio C Hamano | 271440e | 2005-10-25 23:35:37 -0700 | [diff] [blame] | 407 | ;; |
| 408 | esac |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 409 | |
| 410 | GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$dotest/info")" |
| 411 | GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' "$dotest/info")" |
| 412 | GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")" |
Junio C Hamano | e0e3ba2 | 2005-12-14 16:31:06 -0800 | [diff] [blame] | 413 | |
Junio C Hamano | 3b78959 | 2007-12-05 13:16:35 -0800 | [diff] [blame] | 414 | if test -z "$GIT_AUTHOR_EMAIL" |
Junio C Hamano | e0e3ba2 | 2005-12-14 16:31:06 -0800 | [diff] [blame] | 415 | then |
Junio C Hamano | 3b78959 | 2007-12-05 13:16:35 -0800 | [diff] [blame] | 416 | echo "Patch does not have a valid e-mail address." |
Junio C Hamano | e0e3ba2 | 2005-12-14 16:31:06 -0800 | [diff] [blame] | 417 | stop_here $this |
| 418 | fi |
| 419 | |
Junio C Hamano | 2c67419 | 2005-10-20 22:31:56 -0700 | [diff] [blame] | 420 | export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 421 | |
Junio C Hamano | 4bfb6b6 | 2005-11-08 00:41:37 -0800 | [diff] [blame] | 422 | case "$resume" in |
| 423 | '') |
| 424 | if test '' != "$SIGNOFF" |
| 425 | then |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 426 | LAST_SIGNED_OFF_BY=` |
Junio C Hamano | 4bfb6b6 | 2005-11-08 00:41:37 -0800 | [diff] [blame] | 427 | sed -ne '/^Signed-off-by: /p' \ |
| 428 | "$dotest/msg-clean" | |
Jeff King | b4ce54f | 2008-03-12 17:34:34 -0400 | [diff] [blame] | 429 | sed -ne '$p' |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 430 | ` |
Junio C Hamano | 4bfb6b6 | 2005-11-08 00:41:37 -0800 | [diff] [blame] | 431 | ADD_SIGNOFF=` |
| 432 | test "$LAST_SIGNED_OFF_BY" = "$SIGNOFF" || { |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 433 | test '' = "$LAST_SIGNED_OFF_BY" && echo |
| 434 | echo "$SIGNOFF" |
Junio C Hamano | 4bfb6b6 | 2005-11-08 00:41:37 -0800 | [diff] [blame] | 435 | }` |
| 436 | else |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 437 | ADD_SIGNOFF= |
Junio C Hamano | 4bfb6b6 | 2005-11-08 00:41:37 -0800 | [diff] [blame] | 438 | fi |
| 439 | { |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 440 | if test -s "$dotest/msg-clean" |
| 441 | then |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 442 | cat "$dotest/msg-clean" |
| 443 | fi |
| 444 | if test '' != "$ADD_SIGNOFF" |
| 445 | then |
| 446 | echo "$ADD_SIGNOFF" |
| 447 | fi |
Junio C Hamano | 4bfb6b6 | 2005-11-08 00:41:37 -0800 | [diff] [blame] | 448 | } >"$dotest/final-commit" |
| 449 | ;; |
Junio C Hamano | 0c15cc9 | 2005-11-16 00:19:32 -0800 | [diff] [blame] | 450 | *) |
Junio C Hamano | 6d28644 | 2006-02-23 22:14:47 -0800 | [diff] [blame] | 451 | case "$resolved$interactive" in |
Junio C Hamano | 0c15cc9 | 2005-11-16 00:19:32 -0800 | [diff] [blame] | 452 | tt) |
| 453 | # This is used only for interactive view option. |
Junio C Hamano | 38762c4 | 2007-11-28 16:15:04 -0800 | [diff] [blame] | 454 | git diff-index -p --cached HEAD -- >"$dotest/patch" |
Junio C Hamano | 0c15cc9 | 2005-11-16 00:19:32 -0800 | [diff] [blame] | 455 | ;; |
| 456 | esac |
Junio C Hamano | 4bfb6b6 | 2005-11-08 00:41:37 -0800 | [diff] [blame] | 457 | esac |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 458 | |
Junio C Hamano | 4bfb6b6 | 2005-11-08 00:41:37 -0800 | [diff] [blame] | 459 | resume= |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 460 | if test "$interactive" = t |
| 461 | then |
Junio C Hamano | a145110 | 2005-10-12 18:31:41 -0700 | [diff] [blame] | 462 | test -t 0 || |
| 463 | die "cannot be interactive without stdin connected to a terminal." |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 464 | action=again |
| 465 | while test "$action" = again |
| 466 | do |
| 467 | echo "Commit Body is:" |
| 468 | echo "--------------------------" |
| 469 | cat "$dotest/final-commit" |
| 470 | echo "--------------------------" |
Jason Riedy | 9754563 | 2005-12-06 14:21:52 -0800 | [diff] [blame] | 471 | printf "Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all " |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 472 | read reply |
| 473 | case "$reply" in |
Junio C Hamano | f89ad67 | 2005-10-25 23:43:59 -0700 | [diff] [blame] | 474 | [yY]*) action=yes ;; |
| 475 | [aA]*) action=yes interactive= ;; |
| 476 | [nN]*) action=skip ;; |
Adam Roben | ef0c2ab | 2007-07-19 22:09:35 -0700 | [diff] [blame] | 477 | [eE]*) git_editor "$dotest/final-commit" |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 478 | action=again ;; |
Junio C Hamano | f89ad67 | 2005-10-25 23:43:59 -0700 | [diff] [blame] | 479 | [vV]*) action=again |
| 480 | LESS=-S ${PAGER:-less} "$dotest/patch" ;; |
| 481 | *) action=again ;; |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 482 | esac |
| 483 | done |
| 484 | else |
| 485 | action=yes |
| 486 | fi |
Alejandro Mery | 1d9b265 | 2008-06-17 13:43:57 +0200 | [diff] [blame] | 487 | FIRSTLINE=$(sed 1q "$dotest/final-commit") |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 488 | |
| 489 | if test $action = skip |
| 490 | then |
| 491 | go_next |
| 492 | continue |
| 493 | fi |
| 494 | |
| 495 | if test -x "$GIT_DIR"/hooks/applypatch-msg |
| 496 | then |
| 497 | "$GIT_DIR"/hooks/applypatch-msg "$dotest/final-commit" || |
| 498 | stop_here $this |
| 499 | fi |
| 500 | |
Stephan Beyer | c8fe198 | 2008-07-23 18:46:36 +0200 | [diff] [blame] | 501 | printf 'Applying: %s\n' "$FIRSTLINE" |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 502 | |
Junio C Hamano | 0c15cc9 | 2005-11-16 00:19:32 -0800 | [diff] [blame] | 503 | case "$resolved" in |
| 504 | '') |
Junio C Hamano | b47dfe9 | 2009-01-11 22:21:48 -0800 | [diff] [blame] | 505 | eval 'git apply '"$git_apply_opt"' --index "$dotest/patch"' |
Junio C Hamano | 0c15cc9 | 2005-11-16 00:19:32 -0800 | [diff] [blame] | 506 | apply_status=$? |
| 507 | ;; |
| 508 | t) |
| 509 | # Resolved means the user did all the hard work, and |
| 510 | # we do not have to do any patch application. Just |
| 511 | # trust what the user has in the index file and the |
| 512 | # working tree. |
| 513 | resolved= |
Junio C Hamano | 38762c4 | 2007-11-28 16:15:04 -0800 | [diff] [blame] | 514 | git diff-index --quiet --cached HEAD -- && { |
Shawn O. Pearce | 64646d1 | 2006-12-21 21:30:17 -0500 | [diff] [blame] | 515 | echo "No changes - did you forget to use 'git add'?" |
Robert Shearman | ced9456 | 2006-05-02 13:32:43 +0100 | [diff] [blame] | 516 | stop_here_user_resolve $this |
Alex Riesen | 06aff47 | 2007-03-25 01:56:13 +0100 | [diff] [blame] | 517 | } |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 518 | unmerged=$(git ls-files -u) |
Junio C Hamano | c1d1128 | 2006-04-28 02:32:44 -0700 | [diff] [blame] | 519 | if test -n "$unmerged" |
| 520 | then |
| 521 | echo "You still have unmerged paths in your index" |
Shawn O. Pearce | 64646d1 | 2006-12-21 21:30:17 -0500 | [diff] [blame] | 522 | echo "did you forget to use 'git add'?" |
Robert Shearman | ced9456 | 2006-05-02 13:32:43 +0100 | [diff] [blame] | 523 | stop_here_user_resolve $this |
Junio C Hamano | c1d1128 | 2006-04-28 02:32:44 -0700 | [diff] [blame] | 524 | fi |
Junio C Hamano | 0c15cc9 | 2005-11-16 00:19:32 -0800 | [diff] [blame] | 525 | apply_status=0 |
Johannes Schindelin | b4372ef | 2007-07-06 13:05:59 +0100 | [diff] [blame] | 526 | git rerere |
Junio C Hamano | 0c15cc9 | 2005-11-16 00:19:32 -0800 | [diff] [blame] | 527 | ;; |
| 528 | esac |
| 529 | |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 530 | if test $apply_status = 1 && test "$threeway" = t |
| 531 | then |
Junio C Hamano | 7331903 | 2005-10-13 11:46:43 -0700 | [diff] [blame] | 532 | if (fall_back_3way) |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 533 | then |
Junio C Hamano | 7331903 | 2005-10-13 11:46:43 -0700 | [diff] [blame] | 534 | # Applying the patch to an earlier tree and merging the |
| 535 | # result may have produced the same tree as ours. |
Junio C Hamano | 38762c4 | 2007-11-28 16:15:04 -0800 | [diff] [blame] | 536 | git diff-index --quiet --cached HEAD -- && { |
Alex Riesen | 06aff47 | 2007-03-25 01:56:13 +0100 | [diff] [blame] | 537 | echo No changes -- Patch already applied. |
| 538 | go_next |
| 539 | continue |
| 540 | } |
Junio C Hamano | 7331903 | 2005-10-13 11:46:43 -0700 | [diff] [blame] | 541 | # clear apply_status -- we have successfully merged. |
| 542 | apply_status=0 |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 543 | fi |
| 544 | fi |
| 545 | if test $apply_status != 0 |
| 546 | then |
Junio C Hamano | 4d2e283 | 2009-01-18 19:34:31 -0800 | [diff] [blame] | 547 | printf 'Patch failed at %s %s\n' "$msgnum" "$FIRSTLINE" |
Robert Shearman | ced9456 | 2006-05-02 13:32:43 +0100 | [diff] [blame] | 548 | stop_here_user_resolve $this |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 549 | fi |
| 550 | |
| 551 | if test -x "$GIT_DIR"/hooks/pre-applypatch |
| 552 | then |
| 553 | "$GIT_DIR"/hooks/pre-applypatch || stop_here $this |
| 554 | fi |
| 555 | |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 556 | tree=$(git write-tree) && |
Junio C Hamano | 3f01ad6 | 2009-01-22 16:14:58 -0800 | [diff] [blame] | 557 | commit=$( |
Nanako Shiraishi | a79ec62 | 2009-01-24 10:18:02 +0900 | [diff] [blame] | 558 | if test -n "$ignore_date" |
| 559 | then |
| 560 | GIT_AUTHOR_DATE= |
| 561 | fi |
Nanako Shiraishi | f79d4c8 | 2009-04-10 09:34:42 +0900 | [diff] [blame] | 562 | parent=$(git rev-parse --verify -q HEAD) || |
| 563 | echo >&2 "applying to an empty history" |
| 564 | |
Junio C Hamano | 3f01ad6 | 2009-01-22 16:14:58 -0800 | [diff] [blame] | 565 | if test -n "$committer_date_is_author_date" |
| 566 | then |
| 567 | GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" |
| 568 | export GIT_COMMITTER_DATE |
| 569 | fi && |
Ben Jackson | ea10b60 | 2009-04-18 20:42:07 -0700 | [diff] [blame] | 570 | git commit-tree $tree ${parent:+-p} $parent <"$dotest/final-commit" |
Junio C Hamano | 3f01ad6 | 2009-01-22 16:14:58 -0800 | [diff] [blame] | 571 | ) && |
Linus Torvalds | 2e6e3e829 | 2008-04-15 12:56:50 -0700 | [diff] [blame] | 572 | git update-ref -m "$GIT_REFLOG_ACTION: $FIRSTLINE" HEAD $commit $parent || |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 573 | stop_here $this |
| 574 | |
| 575 | if test -x "$GIT_DIR"/hooks/post-applypatch |
| 576 | then |
| 577 | "$GIT_DIR"/hooks/post-applypatch |
| 578 | fi |
| 579 | |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 580 | go_next |
| 581 | done |
| 582 | |
Michael Stefaniuc | e0cd252 | 2008-01-04 19:59:26 +0100 | [diff] [blame] | 583 | git gc --auto |
| 584 | |
Junio C Hamano | d1c5f2a | 2005-10-07 03:44:18 -0700 | [diff] [blame] | 585 | rm -fr "$dotest" |