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