1#!/bin/sh 2# 3# Copyright (c) 2005, 2006 Junio C Hamano 4 5SUBDIRECTORY_OK=Yes 6OPTIONS_KEEPDASHDASH= 7OPTIONS_SPEC="\ 8git am [options] [(<mbox>|<Maildir>)...] 9git am [options] (--resolved | --skip | --abort) 10-- 11i,interactive run interactively 12b,binary* (historical option -- no-op) 133,3way allow fall back on 3way merging if needed 14q,quiet be quiet 15s,signoff add a Signed-off-by line to the commit message 16u,utf8 recode into utf8 (default) 17k,keep pass -k flag to git-mailinfo 18keep-cr pass --keep-cr flag to git-mailsplit for mbox format 19no-keep-cr do not pass --keep-cr flag to git-mailsplit independent of am.keepcr 20c,scissors strip everything before a scissors line 21whitespace= pass it through git-apply 22ignore-space-change pass it through git-apply 23ignore-whitespace pass it through git-apply 24directory= pass it through git-apply 25exclude= pass it through git-apply 26C= pass it through git-apply 27p= pass it through git-apply 28patch-format= format the patch(es) are in 29reject pass it through git-apply 30resolvemsg= override error message when patch failure occurs 31continue continue applying patches after resolving a conflict 32r,resolved synonyms for --continue 33skip skip the current patch 34abort restore the original branch and abort the patching operation. 35committer-date-is-author-date lie about committer date 36ignore-date use current timestamp for author date 37rerere-autoupdate update the index with reused conflict resolution if possible 38rebasing* (internal use for git-rebase)" 39 40. git-sh-setup 41. git-sh-i18n 42prefix=$(git rev-parse --show-prefix) 43set_reflog_action am 44require_work_tree 45cd_to_toplevel 46 47git var GIT_COMMITTER_IDENT >/dev/null || 48 die "$(gettext "You need to set your committer info first")" 49 50if git rev-parse --verify -q HEAD >/dev/null 51then 52 HAS_HEAD=yes 53else 54 HAS_HEAD= 55fi 56 57cmdline="git am" 58iftest''!="$interactive" 59then 60 cmdline="$cmdline-i" 61fi 62iftest''!="$threeway" 63then 64 cmdline="$cmdline-3" 65fi 66 67sq() { 68 git rev-parse --sq-quote"$@" 69} 70 71stop_here () { 72echo"$1">"$dotest/next" 73 git rev-parse --verify -q HEAD >"$dotest/abort-safety" 74exit1 75} 76 77safe_to_abort () { 78iftest -f"$dotest/dirtyindex" 79then 80return1 81fi 82 83if!test -s"$dotest/abort-safety" 84then 85return0 86fi 87 88 abort_safety=$(cat"$dotest/abort-safety") 89iftest"z$(git rev-parse --verify -q HEAD)"="z$abort_safety" 90then 91return0 92fi 93( 94gettext"You seem to have moved HEAD since the last 'am' failure. 95Not rewinding to ORIG_HEAD"&& 96echo 97) >&2 98return1 99} 100 101stop_here_user_resolve () { 102if[-n"$resolvemsg"];then 103printf'%s\n'"$resolvemsg" 104 stop_here $1 105fi 106 eval_gettext "When you have resolved this problem run\"\$cmdline--resolved\". 107If you would prefer to skip this patch, instead run\"\$cmdline--skip\". 108To restore the original branch and stop patching run\"\$cmdline--abort\".";echo 109 110 stop_here $1 111} 112 113go_next () { 114rm-f"$dotest/$msgnum""$dotest/msg""$dotest/msg-clean" \ 115"$dotest/patch""$dotest/info" 116echo"$next">"$dotest/next" 117 this=$next 118} 119 120cannot_fallback () { 121echo"$1" 122gettext"Cannot fall back to three-way merge.";echo 123exit1 124} 125 126fall_back_3way () { 127 O_OBJECT=`cd "$GIT_OBJECT_DIRECTORY" && pwd` 128 129rm-fr"$dotest"/patch-merge-* 130mkdir"$dotest/patch-merge-tmp-dir" 131 132# First see if the patch records the index info that we can use. 133 git apply --build-fake-ancestor"$dotest/patch-merge-tmp-index" \ 134"$dotest/patch"&& 135 GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \ 136 git write-tree >"$dotest/patch-merge-base+"|| 137 cannot_fallback "$(gettext "Repository lacks necessary blobs to fall back on 3-way merge.")" 138 139 say Using index info to reconstruct a base tree... 140if GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \ 141 git apply --cached<"$dotest/patch" 142then 143mv"$dotest/patch-merge-base+""$dotest/patch-merge-base" 144mv"$dotest/patch-merge-tmp-index""$dotest/patch-merge-index" 145else 146 cannot_fallback "$(gettext "Did you hand edit your patch? 147It does not apply to blobs recorded in its index.")" 148fi 149 150test -f"$dotest/patch-merge-index"&& 151 his_tree=$(GIT_INDEX_FILE="$dotest/patch-merge-index" git write-tree) && 152 orig_tree=$(cat"$dotest/patch-merge-base") && 153rm-fr"$dotest"/patch-merge-* ||exit1 154 155 say "$(gettext "Falling back to patching base and 3-way merge...")" 156 157# This is not so wrong. Depending on which base we picked, 158# orig_tree may be wildly different from ours, but his_tree 159# has the same set of wildly different changes in parts the 160# patch did not touch, so recursive ends up canceling them, 161# saying that we reverted all those changes. 162 163eval GITHEAD_$his_tree='"$FIRSTLINE"' 164export GITHEAD_$his_tree 165iftest -n"$GIT_QUIET" 166then 167 GIT_MERGE_VERBOSITY=0&&export GIT_MERGE_VERBOSITY 168fi 169 git-merge-recursive $orig_tree-- HEAD $his_tree|| { 170 git rerere $allow_rerere_autoupdate 171echo Failed to merge in the changes. 172exit1 173} 174unset GITHEAD_$his_tree 175} 176 177clean_abort () { 178test$#=0||echo>&2"$@" 179rm-fr"$dotest" 180exit1 181} 182 183patch_format= 184 185check_patch_format () { 186# early return if patch_format was set from the command line 187iftest -n"$patch_format" 188then 189return0 190fi 191 192# we default to mbox format if input is from stdin and for 193# directories 194iftest$#=0||test"x$1"="x-"||test -d"$1" 195then 196 patch_format=mbox 197return0 198fi 199 200# otherwise, check the first few non-blank lines of the first 201# patch to try to detect its format 202{ 203# Start from first line containing non-whitespace 204 l1= 205whiletest -z"$l1" 206do 207read l1 208done 209read l2 210read l3 211case"$l1"in 212"From "* |"From: "*) 213 patch_format=mbox 214;; 215'# This series applies on GIT commit'*) 216 patch_format=stgit-series 217;; 218"# HG changeset patch") 219 patch_format=hg 220;; 221*) 222# if the second line is empty and the third is 223# a From, Author or Date entry, this is very 224# likely an StGIT patch 225case"$l2,$l3"in 226,"From: "* | ,"Author: "* | ,"Date: "*) 227 patch_format=stgit 228;; 229*) 230;; 231esac 232;; 233esac 234iftest -z"$patch_format"&& 235test -n"$l1"&& 236test -n"$l2"&& 237test -n"$l3" 238then 239# This begins with three non-empty lines. Is this a 240# piece of e-mail a-la RFC2822? Grab all the headers, 241# discarding the indented remainder of folded lines, 242# and see if it looks like that they all begin with the 243# header field names... 244tr-d'\015'<"$1"| 245sed-n -e'/^$/q'-e'/^[ ]/d'-e p | 246 sane_egrep -v'^[!-9;-~]+:'>/dev/null || 247 patch_format=mbox 248fi 249} <"$1"|| clean_abort 250} 251 252split_patches () { 253case"$patch_format"in 254 mbox) 255iftest -n"$rebasing"||test t ="$keepcr" 256then 257 keep_cr=--keep-cr 258else 259 keep_cr= 260fi 261 git mailsplit -d"$prec"-o"$dotest"-b$keep_cr--"$@">"$dotest/last"|| 262 clean_abort 263;; 264 stgit-series) 265iftest$#-ne1 266then 267 clean_abort "$(gettext "Only one StGIT patch series can be applied at once")" 268fi 269 series_dir=`dirname "$1"` 270 series_file="$1" 271shift 272{ 273set x 274whileread filename 275do 276set"$@""$series_dir/$filename" 277done 278# remove the safety x 279shift 280# remove the arg coming from the first-line comment 281shift 282} <"$series_file"|| clean_abort 283# set the patch format appropriately 284 patch_format=stgit 285# now handle the actual StGIT patches 286 split_patches "$@" 287;; 288 stgit) 289 this=0 290for stgit in"$@" 291do 292 this=`expr "$this" + 1` 293 msgnum=`printf "%0${prec}d"$this` 294# Perl version of StGIT parse_patch. The first nonemptyline 295# not starting with Author, From or Date is the 296# subject, and the body starts with the next nonempty 297# line not starting with Author, From or Date 298 perl -ne'BEGIN {$subject= 0 } 299 if ($subject> 1) { print ; } 300 elsif (/^\s+$/) { next ; } 301 elsif (/^Author:/) { print s/Author/From/ ; } 302 elsif (/^(From|Date)/) { print ; } 303 elsif ($subject) { 304$subject= 2 ; 305 print "\n" ; 306 print ; 307 } else { 308 print "Subject: ",$_; 309$subject= 1; 310 } 311 '<"$stgit">"$dotest/$msgnum"|| clean_abort 312done 313echo"$this">"$dotest/last" 314 this= 315 msgnum= 316;; 317*) 318iftest -n"$parse_patch";then 319 clean_abort "$(eval_gettext "Patch format \$patch_format is not supported.")" 320else 321 clean_abort "$(gettext "Patch format detection failed.")" 322fi 323;; 324esac 325} 326 327prec=4 328dotest="$GIT_DIR/rebase-apply" 329sign= utf8=t keep= keepcr= skip= interactive= resolved= rebasing= abort= 330resolvemsg= resume= scissors= no_inbody_headers= 331git_apply_opt= 332committer_date_is_author_date= 333ignore_date= 334allow_rerere_autoupdate= 335 336iftest"$(git config --bool --get am.keepcr)"= true 337then 338 keepcr=t 339fi 340 341whiletest$#!=0 342do 343case"$1"in 344-i|--interactive) 345 interactive=t ;; 346-b|--binary) 347: ;; 348-3|--3way) 349 threeway=t ;; 350-s|--signoff) 351 sign=t ;; 352-u|--utf8) 353 utf8=t ;;# this is now default 354--no-utf8) 355 utf8= ;; 356-k|--keep) 357 keep=t ;; 358-c|--scissors) 359 scissors=t ;; 360--no-scissors) 361 scissors=f ;; 362-r|--resolved|--continue) 363 resolved=t ;; 364--skip) 365 skip=t ;; 366--abort) 367 abort=t ;; 368--rebasing) 369 rebasing=t threeway=t keep=t scissors=f no_inbody_headers=t ;; 370-d|--dotest) 371 die "$(gettext "-d option is no longer supported. Do not use.")" 372;; 373--resolvemsg) 374shift; resolvemsg=$1;; 375--whitespace|--directory|--exclude) 376 git_apply_opt="$git_apply_opt$(sq "$1=$2")";shift;; 377-C|-p) 378 git_apply_opt="$git_apply_opt$(sq "$1$2")";shift;; 379--patch-format) 380shift; patch_format="$1";; 381--reject|--ignore-whitespace|--ignore-space-change) 382 git_apply_opt="$git_apply_opt$1";; 383--committer-date-is-author-date) 384 committer_date_is_author_date=t ;; 385--ignore-date) 386 ignore_date=t ;; 387--rerere-autoupdate|--no-rerere-autoupdate) 388 allow_rerere_autoupdate="$1";; 389-q|--quiet) 390 GIT_QUIET=t ;; 391--keep-cr) 392 keepcr=t ;; 393--no-keep-cr) 394 keepcr=f ;; 395--) 396shift;break;; 397*) 398 usage ;; 399esac 400shift 401done 402 403# If the dotest directory exists, but we have finished applying all the 404# patches in them, clear it out. 405iftest -d"$dotest"&& 406 last=$(cat"$dotest/last") && 407 next=$(cat"$dotest/next") && 408test$#!=0&& 409test"$next"-gt"$last" 410then 411rm-fr"$dotest" 412fi 413 414iftest -d"$dotest" 415then 416case"$#,$skip$resolved$abort"in 4170,*t*) 418# Explicit resume command and we do not have file, so 419# we are happy. 420: ;; 4210,) 422# No file input but without resume parameters; catch 423# user error to feed us a patch from standard input 424# when there is already $dotest. This is somewhat 425# unreliable -- stdin could be /dev/null for example 426# and the caller did not intend to feed us a patch but 427# wanted to continue unattended. 428test -t0 429;; 430*) 431 false 432;; 433esac|| 434 die "$(eval_gettext "previous rebase directory \$dotest still exists but mbox given.")" 435 resume=yes 436 437case"$skip,$abort"in 438 t,t) 439 die "$(gettext "Please make up your mind. --skip or --abort?")" 440;; 441 t,) 442 git rerere clear 443 git read-tree --reset -u HEAD HEAD 444 orig_head=$(cat"$GIT_DIR/ORIG_HEAD") 445 git reset HEAD 446 git update-ref ORIG_HEAD $orig_head 447;; 448,t) 449iftest -f"$dotest/rebasing" 450then 451exec git rebase --abort 452fi 453 git rerere clear 454if safe_to_abort 455then 456 git read-tree --reset -u HEAD ORIG_HEAD 457 git reset ORIG_HEAD 458fi 459rm-fr"$dotest" 460exit;; 461esac 462rm-f"$dotest/dirtyindex" 463else 464# Make sure we are not given --skip, --resolved, nor --abort 465test"$skip$resolved$abort"=""|| 466 die "$(gettext "Resolve operation not in progress, we are not resuming.")" 467 468# Start afresh. 469mkdir-p"$dotest"||exit 470 471iftest -n"$prefix"&&test$#!=0 472then 473 first=t 474for arg 475do 476test -n"$first"&& { 477set x 478 first= 479} 480if is_absolute_path "$arg" 481then 482set"$@""$arg" 483else 484set"$@""$prefix$arg" 485fi 486done 487shift 488fi 489 490 check_patch_format "$@" 491 492 split_patches "$@" 493 494# -i can and must be given when resuming; everything 495# else is kept 496echo"$git_apply_opt">"$dotest/apply-opt" 497echo"$threeway">"$dotest/threeway" 498echo"$sign">"$dotest/sign" 499echo"$utf8">"$dotest/utf8" 500echo"$keep">"$dotest/keep" 501echo"$keepcr">"$dotest/keepcr" 502echo"$scissors">"$dotest/scissors" 503echo"$no_inbody_headers">"$dotest/no_inbody_headers" 504echo"$GIT_QUIET">"$dotest/quiet" 505echo1>"$dotest/next" 506iftest -n"$rebasing" 507then 508: >"$dotest/rebasing" 509else 510: >"$dotest/applying" 511iftest -n"$HAS_HEAD" 512then 513 git update-ref ORIG_HEAD HEAD 514else 515 git update-ref -d ORIG_HEAD >/dev/null 2>&1 516fi 517fi 518fi 519 520git update-index -q --refresh 521 522case"$resolved"in 523'') 524case"$HAS_HEAD"in 525'') 526 files=$(git ls-files) ;; 527 ?*) 528 files=$(git diff-index --cached --name-only HEAD --) ;; 529esac||exit 530iftest"$files" 531then 532test -n"$HAS_HEAD"&& : >"$dotest/dirtyindex" 533 die "$(eval_gettext "Dirty index: cannot apply patches (dirty: \$files)")" 534fi 535esac 536 537iftest"$(cat "$dotest/utf8")"= t 538then 539 utf8=-u 540else 541 utf8=-n 542fi 543iftest"$(cat "$dotest/keep")"= t 544then 545 keep=-k 546fi 547case"$(cat "$dotest/keepcr")"in 548t) 549 keepcr=--keep-cr ;; 550f) 551 keepcr=--no-keep-cr ;; 552esac 553case"$(cat "$dotest/scissors")"in 554t) 555 scissors=--scissors ;; 556f) 557 scissors=--no-scissors ;; 558esac 559iftest"$(cat "$dotest/no_inbody_headers")"= t 560then 561 no_inbody_headers=--no-inbody-headers 562else 563 no_inbody_headers= 564fi 565iftest"$(cat "$dotest/quiet")"= t 566then 567 GIT_QUIET=t 568fi 569iftest"$(cat "$dotest/threeway")"= t 570then 571 threeway=t 572fi 573git_apply_opt=$(cat"$dotest/apply-opt") 574iftest"$(cat "$dotest/sign")"= t 575then 576 SIGNOFF=`git var GIT_COMMITTER_IDENT | sed -e ' 577 s/>.*/>/ 578 s/^/Signed-off-by: /' 579 ` 580else 581 SIGNOFF= 582fi 583 584last=`cat "$dotest/last"` 585this=`cat "$dotest/next"` 586iftest"$skip"= t 587then 588 this=`expr "$this" + 1` 589 resume= 590fi 591 592whiletest"$this"-le"$last" 593do 594 msgnum=`printf "%0${prec}d"$this` 595 next=`expr "$this" + 1` 596test -f"$dotest/$msgnum"|| { 597 resume= 598 go_next 599continue 600} 601 602# If we are not resuming, parse and extract the patch information 603# into separate files: 604# - info records the authorship and title 605# - msg is the rest of commit log message 606# - patch is the patch body. 607# 608# When we are resuming, these files are either already prepared 609# by the user, or the user can tell us to do so by --resolved flag. 610case"$resume"in 611'') 612 git mailinfo $keep $no_inbody_headers $scissors $utf8"$dotest/msg""$dotest/patch" \ 613<"$dotest/$msgnum">"$dotest/info"|| 614 stop_here $this 615 616# skip pine's internal folder data 617 sane_grep '^Author: Mail System Internal Data$' \ 618<"$dotest"/info >/dev/null && 619 go_next &&continue 620 621test -s"$dotest/patch"|| { 622 eval_gettext "Patch is empty. Was it split wrong? 623If you would prefer to skip this patch, instead run\"\$cmdline--skip\". 624To restore the original branch and stop patching run\"\$cmdline--abort\".";echo 625 stop_here $this 626} 627rm-f"$dotest/original-commit""$dotest/author-script" 628iftest -f"$dotest/rebasing"&& 629 commit=$(sed-e's/^From \([0-9a-f]*\) .*/\1/' \ 630-e q "$dotest/$msgnum") && 631test"$(git cat-file -t "$commit")"= commit 632then 633 git cat-file commit "$commit"| 634sed-e'1,/^$/d'>"$dotest/msg-clean" 635echo"$commit">"$dotest/original-commit" 636 get_author_ident_from_commit "$commit">"$dotest/author-script" 637else 638{ 639sed-n'/^Subject/ s/Subject: //p'"$dotest/info" 640echo 641cat"$dotest/msg" 642} | 643 git stripspace >"$dotest/msg-clean" 644fi 645;; 646esac 647 648iftest -f"$dotest/author-script" 649then 650eval $(cat"$dotest/author-script") 651else 652 GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$dotest/info")" 653 GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' "$dotest/info")" 654 GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")" 655fi 656 657iftest -z"$GIT_AUTHOR_EMAIL" 658then 659gettext"Patch does not have a valid e-mail address.";echo 660 stop_here $this 661fi 662 663export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE 664 665case"$resume"in 666'') 667iftest''!="$SIGNOFF" 668then 669 LAST_SIGNED_OFF_BY=` 670 sed -ne '/^Signed-off-by: /p' \ 671 "$dotest/msg-clean" | 672 sed -ne '$p' 673 ` 674 ADD_SIGNOFF=` 675 test "$LAST_SIGNED_OFF_BY" = "$SIGNOFF" || { 676 test '' = "$LAST_SIGNED_OFF_BY" && echo 677 echo "$SIGNOFF" 678 }` 679else 680 ADD_SIGNOFF= 681fi 682{ 683iftest -s"$dotest/msg-clean" 684then 685cat"$dotest/msg-clean" 686fi 687iftest''!="$ADD_SIGNOFF" 688then 689echo"$ADD_SIGNOFF" 690fi 691} >"$dotest/final-commit" 692;; 693*) 694case"$resolved$interactive"in 695 tt) 696# This is used only for interactive view option. 697 git diff-index -p --cached HEAD -->"$dotest/patch" 698;; 699esac 700esac 701 702 resume= 703iftest"$interactive"= t 704then 705test -t0|| 706 die "$(gettext "cannot be interactive without stdin connected to a terminal.")" 707 action=again 708whiletest"$action"= again 709do 710gettext"Commit Body is:";echo 711echo"--------------------------" 712cat"$dotest/final-commit" 713echo"--------------------------" 714# TRANSLATORS: Make sure to include [y], [n], [e], [v] and [a] 715# in your translation. The program will only accept English 716# input at this point. 717gettext"Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all " 718read reply 719case"$reply"in 720[yY]*) action=yes;; 721[aA]*) action=yes interactive= ;; 722[nN]*) action=skip ;; 723[eE]*) git_editor "$dotest/final-commit" 724 action=again ;; 725[vV]*) action=again 726 git_pager "$dotest/patch";; 727*) action=again ;; 728esac 729done 730else 731 action=yes 732fi 733 734iftest -f"$dotest/final-commit" 735then 736 FIRSTLINE=$(sed1q "$dotest/final-commit") 737else 738 FIRSTLINE="" 739fi 740 741iftest$action= skip 742then 743 go_next 744continue 745fi 746 747iftest -x"$GIT_DIR"/hooks/applypatch-msg 748then 749"$GIT_DIR"/hooks/applypatch-msg "$dotest/final-commit"|| 750 stop_here $this 751fi 752 753 say "$(eval_gettext "Applying: \$FIRSTLINE")" 754 755case"$resolved"in 756'') 757# When we are allowed to fall back to 3-way later, don't give 758# false errors during the initial attempt. 759 squelch= 760iftest"$threeway"= t 761then 762 squelch='>/dev/null 2>&1 ' 763fi 764eval"git apply$squelch$git_apply_opt"' --index "$dotest/patch"' 765 apply_status=$? 766;; 767 t) 768# Resolved means the user did all the hard work, and 769# we do not have to do any patch application. Just 770# trust what the user has in the index file and the 771# working tree. 772 resolved= 773 git diff-index --quiet --cached HEAD --&& { 774gettext"No changes - did you forget to use 'git add'? 775If there is nothing left to stage, chances are that something else 776already introduced the same changes; you might want to skip this patch.";echo 777 stop_here_user_resolve $this 778} 779 unmerged=$(git ls-files -u) 780iftest -n"$unmerged" 781then 782gettext"You still have unmerged paths in your index 783did you forget to use 'git add'?";echo 784 stop_here_user_resolve $this 785fi 786 apply_status=0 787 git rerere 788;; 789esac 790 791iftest$apply_status!=0&&test"$threeway"= t 792then 793if(fall_back_3way) 794then 795# Applying the patch to an earlier tree and merging the 796# result may have produced the same tree as ours. 797 git diff-index --quiet --cached HEAD --&& { 798 say "$(gettext "No changes -- Patch already applied.")" 799 go_next 800continue 801} 802# clear apply_status -- we have successfully merged. 803 apply_status=0 804fi 805fi 806iftest$apply_status!=0 807then 808 eval_gettext 'Patch failed at$msgnum$FIRSTLINE';echo 809 stop_here_user_resolve $this 810fi 811 812iftest -x"$GIT_DIR"/hooks/pre-applypatch 813then 814"$GIT_DIR"/hooks/pre-applypatch || stop_here $this 815fi 816 817 tree=$(git write-tree) && 818 commit=$( 819iftest -n"$ignore_date" 820then 821 GIT_AUTHOR_DATE= 822fi 823 parent=$(git rev-parse --verify -q HEAD) || 824 say >&2"$(gettext "applying to an empty history")" 825 826iftest -n"$committer_date_is_author_date" 827then 828 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" 829export GIT_COMMITTER_DATE 830fi&& 831 git commit-tree $tree ${parent:+-p} $parent<"$dotest/final-commit" 832) && 833 git update-ref -m"$GIT_REFLOG_ACTION:$FIRSTLINE" HEAD $commit $parent|| 834 stop_here $this 835 836iftest -f"$dotest/original-commit";then 837echo"$(cat "$dotest/original-commit")$commit">>"$dotest/rewritten" 838fi 839 840iftest -x"$GIT_DIR"/hooks/post-applypatch 841then 842"$GIT_DIR"/hooks/post-applypatch 843fi 844 845 go_next 846done 847 848iftest -s"$dotest"/rewritten;then 849 git notes copy --for-rewrite=rebase <"$dotest"/rewritten 850iftest -x"$GIT_DIR"/hooks/post-rewrite;then 851"$GIT_DIR"/hooks/post-rewrite rebase <"$dotest"/rewritten 852fi 853fi 854 855rm-fr"$dotest" 856git gc --auto