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