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"$parse_patch";then 309 clean_abort "Patch format$patch_formatis not supported." 310else 311 clean_abort "Patch format detection failed." 312fi 313;; 314esac 315} 316 317prec=4 318dotest="$GIT_DIR/rebase-apply" 319sign= utf8=t keep= keepcr= skip= interactive= resolved= rebasing= abort= 320resolvemsg= resume= scissors= no_inbody_headers= 321git_apply_opt= 322committer_date_is_author_date= 323ignore_date= 324allow_rerere_autoupdate= 325 326iftest"$(git config --bool --get am.keepcr)"= true 327then 328 keepcr=t 329fi 330 331whiletest$#!=0 332do 333case"$1"in 334-i|--interactive) 335 interactive=t ;; 336-b|--binary) 337: ;; 338-3|--3way) 339 threeway=t ;; 340-s|--signoff) 341 sign=t ;; 342-u|--utf8) 343 utf8=t ;;# this is now default 344--no-utf8) 345 utf8= ;; 346-k|--keep) 347 keep=t ;; 348-c|--scissors) 349 scissors=t ;; 350--no-scissors) 351 scissors=f ;; 352-r|--resolved|--continue) 353 resolved=t ;; 354--skip) 355 skip=t ;; 356--abort) 357 abort=t ;; 358--rebasing) 359 rebasing=t threeway=t keep=t scissors=f no_inbody_headers=t ;; 360-d|--dotest) 361 die "-d option is no longer supported. Do not use." 362;; 363--resolvemsg) 364shift; resolvemsg=$1;; 365--whitespace|--directory) 366 git_apply_opt="$git_apply_opt$(sq "$1=$2")";shift;; 367-C|-p) 368 git_apply_opt="$git_apply_opt$(sq "$1$2")";shift;; 369--patch-format) 370shift; patch_format="$1";; 371--reject|--ignore-whitespace|--ignore-space-change) 372 git_apply_opt="$git_apply_opt$1";; 373--committer-date-is-author-date) 374 committer_date_is_author_date=t ;; 375--ignore-date) 376 ignore_date=t ;; 377--rerere-autoupdate|--no-rerere-autoupdate) 378 allow_rerere_autoupdate="$1";; 379-q|--quiet) 380 GIT_QUIET=t ;; 381--keep-cr) 382 keepcr=t ;; 383--no-keep-cr) 384 keepcr=f ;; 385--) 386shift;break;; 387*) 388 usage ;; 389esac 390shift 391done 392 393# If the dotest directory exists, but we have finished applying all the 394# patches in them, clear it out. 395iftest -d"$dotest"&& 396 last=$(cat "$dotest/last")&& 397 next=$(cat "$dotest/next")&& 398test$#!=0&& 399test"$next"-gt"$last" 400then 401rm-fr"$dotest" 402fi 403 404iftest -d"$dotest" 405then 406case"$#,$skip$resolved$abort"in 4070,*t*) 408# Explicit resume command and we do not have file, so 409# we are happy. 410: ;; 4110,) 412# No file input but without resume parameters; catch 413# user error to feed us a patch from standard input 414# when there is already $dotest. This is somewhat 415# unreliable -- stdin could be /dev/null for example 416# and the caller did not intend to feed us a patch but 417# wanted to continue unattended. 418test -t0 419;; 420*) 421 false 422;; 423esac|| 424 die "previous rebase directory$doteststill exists but mbox given." 425 resume=yes 426 427case"$skip,$abort"in 428 t,t) 429 die "Please make up your mind. --skip or --abort?" 430;; 431 t,) 432 git rerere clear 433 git read-tree --reset -u HEAD HEAD 434 orig_head=$(cat "$GIT_DIR/ORIG_HEAD") 435 git reset HEAD 436 git update-ref ORIG_HEAD $orig_head 437;; 438,t) 439iftest -f"$dotest/rebasing" 440then 441exec git rebase --abort 442fi 443 git rerere clear 444if safe_to_abort 445then 446 git read-tree --reset -u HEAD ORIG_HEAD 447 git reset ORIG_HEAD 448fi 449rm-fr"$dotest" 450exit;; 451esac 452rm-f"$dotest/dirtyindex" 453else 454# Make sure we are not given --skip, --resolved, nor --abort 455test"$skip$resolved$abort"=""|| 456 die "Resolve operation not in progress, we are not resuming." 457 458# Start afresh. 459mkdir-p"$dotest"||exit 460 461iftest -n"$prefix"&&test$#!=0 462then 463 first=t 464for arg 465do 466test -n"$first"&& { 467set x 468 first= 469} 470if is_absolute_path "$arg" 471then 472set"$@""$arg" 473else 474set"$@""$prefix$arg" 475fi 476done 477shift 478fi 479 480 check_patch_format "$@" 481 482 split_patches "$@" 483 484# -i can and must be given when resuming; everything 485# else is kept 486echo"$git_apply_opt">"$dotest/apply-opt" 487echo"$threeway">"$dotest/threeway" 488echo"$sign">"$dotest/sign" 489echo"$utf8">"$dotest/utf8" 490echo"$keep">"$dotest/keep" 491echo"$keepcr">"$dotest/keepcr" 492echo"$scissors">"$dotest/scissors" 493echo"$no_inbody_headers">"$dotest/no_inbody_headers" 494echo"$GIT_QUIET">"$dotest/quiet" 495echo1>"$dotest/next" 496iftest -n"$rebasing" 497then 498: >"$dotest/rebasing" 499else 500: >"$dotest/applying" 501iftest -n"$HAS_HEAD" 502then 503 git update-ref ORIG_HEAD HEAD 504else 505 git update-ref -d ORIG_HEAD >/dev/null 2>&1 506fi 507fi 508fi 509 510case"$resolved"in 511'') 512case"$HAS_HEAD"in 513'') 514 files=$(git ls-files);; 515 ?*) 516 files=$(git diff-index --cached --name-only HEAD --);; 517esac||exit 518iftest"$files" 519then 520test -n"$HAS_HEAD"&& : >"$dotest/dirtyindex" 521 die "Dirty index: cannot apply patches (dirty:$files)" 522fi 523esac 524 525iftest"$(cat "$dotest/utf8")"= t 526then 527 utf8=-u 528else 529 utf8=-n 530fi 531iftest"$(cat "$dotest/keep")"= t 532then 533 keep=-k 534fi 535case"$(cat "$dotest/keepcr")"in 536t) 537 keepcr=--keep-cr;; 538f) 539 keepcr=--no-keep-cr;; 540esac 541case"$(cat "$dotest/scissors")"in 542t) 543 scissors=--scissors;; 544f) 545 scissors=--no-scissors;; 546esac 547iftest"$(cat "$dotest/no_inbody_headers")"= t 548then 549 no_inbody_headers=--no-inbody-headers 550else 551 no_inbody_headers= 552fi 553iftest"$(cat "$dotest/quiet")"= t 554then 555 GIT_QUIET=t 556fi 557iftest"$(cat "$dotest/threeway")"= t 558then 559 threeway=t 560fi 561git_apply_opt=$(cat "$dotest/apply-opt") 562iftest"$(cat "$dotest/sign")"= t 563then 564 SIGNOFF=`git var GIT_COMMITTER_IDENT | sed -e ' 565 s/>.*/>/ 566 s/^/Signed-off-by: /' 567 ` 568else 569 SIGNOFF= 570fi 571 572last=`cat "$dotest/last"` 573this=`cat "$dotest/next"` 574iftest"$skip"= t 575then 576 this=`expr "$this" + 1` 577 resume= 578fi 579 580whiletest"$this"-le"$last" 581do 582 msgnum=`printf "%0${prec}d"$this` 583 next=`expr "$this" + 1` 584test -f"$dotest/$msgnum"|| { 585 resume= 586 go_next 587continue 588} 589 590# If we are not resuming, parse and extract the patch information 591# into separate files: 592# - info records the authorship and title 593# - msg is the rest of commit log message 594# - patch is the patch body. 595# 596# When we are resuming, these files are either already prepared 597# by the user, or the user can tell us to do so by --resolved flag. 598case"$resume"in 599'') 600 git mailinfo $keep $no_inbody_headers $scissors $utf8"$dotest/msg""$dotest/patch" \ 601<"$dotest/$msgnum">"$dotest/info"|| 602 stop_here $this 603 604# skip pine's internal folder data 605 sane_grep '^Author: Mail System Internal Data$' \ 606<"$dotest"/info >/dev/null && 607 go_next &&continue 608 609test -s"$dotest/patch"|| { 610echo"Patch is empty. Was it split wrong?" 611echo"If you would prefer to skip this patch, instead run\"$cmdline--skip\"." 612echo"To restore the original branch and stop patching run\"$cmdline--abort\"." 613 stop_here $this 614} 615rm-f"$dotest/original-commit""$dotest/author-script" 616iftest -f"$dotest/rebasing"&& 617 commit=$(sed -e 's/^From \([0-9a-f]*\) .*/\1/' \ 618 -e q "$dotest/$msgnum") && 619 test "$(git cat-file -t "$commit")" = commit 620 then 621 git cat-file commit "$commit" | 622 sed -e '1,/^$/d' >"$dotest/msg-clean" 623 echo "$commit" > "$dotest/original-commit" 624 get_author_ident_from_commit "$commit" > "$dotest/author-script" 625 else 626 { 627 sed -n '/^Subject/ s/Subject: //p' "$dotest/info" 628 echo 629 cat "$dotest/msg" 630 } | 631 git stripspace > "$dotest/msg-clean" 632 fi 633 ;; 634 esac 635 636 if test -f "$dotest/author-script" 637 then 638 eval$(cat "$dotest/author-script") 639 else 640 GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$dotest/info")" 641 GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' "$dotest/info")" 642 GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")" 643 fi 644 645 if test -z "$GIT_AUTHOR_EMAIL" 646 then 647 echo "Patch does not have a valid e-mail address." 648 stop_here$this 649 fi 650 651 export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE 652 653 case "$resume" in 654 '') 655 if test '' != "$SIGNOFF" 656 then 657 LAST_SIGNED_OFF_BY=` 658 sed -ne '/^Signed-off-by: /p' \ 659 "$dotest/msg-clean" | 660 sed -ne '$p' 661 ` 662 ADD_SIGNOFF=` 663 test "$LAST_SIGNED_OFF_BY" = "$SIGNOFF" || { 664 test '' = "$LAST_SIGNED_OFF_BY" && echo 665 echo "$SIGNOFF" 666 }` 667 else 668 ADD_SIGNOFF= 669 fi 670 { 671 if test -s "$dotest/msg-clean" 672 then 673 cat "$dotest/msg-clean" 674 fi 675 if test '' != "$ADD_SIGNOFF" 676 then 677 echo "$ADD_SIGNOFF" 678 fi 679 } >"$dotest/final-commit" 680 ;; 681 *) 682 case "$resolved$interactive" in 683 tt) 684 # This is used only for interactive view option. 685 git diff-index -p --cached HEAD -- >"$dotest/patch" 686 ;; 687 esac 688 esac 689 690 resume= 691 if test "$interactive" = t 692 then 693 test -t 0 || 694 die "cannot be interactive without stdin connected to a terminal." 695 action=again 696 while test "$action" = again 697 do 698 echo "Commit Body is:" 699 echo "--------------------------" 700 cat "$dotest/final-commit" 701 echo "--------------------------" 702 printf "Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all " 703 read reply 704 case "$reply" in 705 [yY]*) action=yes ;; 706 [aA]*) action=yes interactive= ;; 707 [nN]*) action=skip ;; 708 [eE]*) git_editor "$dotest/final-commit" 709 action=again ;; 710 [vV]*) action=again 711 git_pager "$dotest/patch" ;; 712 *) action=again ;; 713 esac 714 done 715 else 716 action=yes 717 fi 718 719 if test -f "$dotest/final-commit" 720 then 721 FIRSTLINE=$(sed 1q "$dotest/final-commit") 722 else 723 FIRSTLINE="" 724 fi 725 726 if test$action= skip 727 then 728 go_next 729 continue 730 fi 731 732 if test -x "$GIT_DIR"/hooks/applypatch-msg 733 then 734 "$GIT_DIR"/hooks/applypatch-msg "$dotest/final-commit" || 735 stop_here$this 736 fi 737 738 say "Applying:$FIRSTLINE" 739 740 case "$resolved" in 741 '') 742 # When we are allowed to fall back to 3-way later, don't give 743# false errors during the initial attempt. 744 squelch= 745iftest"$threeway"= t 746then 747 squelch='>/dev/null 2>&1 ' 748fi 749eval"git apply$squelch$git_apply_opt"' --index "$dotest/patch"' 750 apply_status=$? 751;; 752 t) 753# Resolved means the user did all the hard work, and 754# we do not have to do any patch application. Just 755# trust what the user has in the index file and the 756# working tree. 757 resolved= 758 git diff-index --quiet --cached HEAD --&& { 759echo"No changes - did you forget to use 'git add'?" 760echo"If there is nothing left to stage, chances are that something else" 761echo"already introduced the same changes; you might want to skip this patch." 762 stop_here_user_resolve $this 763} 764 unmerged=$(git ls-files -u) 765iftest -n"$unmerged" 766then 767echo"You still have unmerged paths in your index" 768echo"did you forget to use 'git add'?" 769 stop_here_user_resolve $this 770fi 771 apply_status=0 772 git rerere 773;; 774esac 775 776iftest$apply_status!=0&&test"$threeway"= t 777then 778if(fall_back_3way) 779then 780# Applying the patch to an earlier tree and merging the 781# result may have produced the same tree as ours. 782 git diff-index --quiet --cached HEAD --&& { 783 say No changes -- Patch already applied. 784 go_next 785continue 786} 787# clear apply_status -- we have successfully merged. 788 apply_status=0 789fi 790fi 791iftest$apply_status!=0 792then 793printf'Patch failed at %s %s\n'"$msgnum""$FIRSTLINE" 794 stop_here_user_resolve $this 795fi 796 797iftest -x"$GIT_DIR"/hooks/pre-applypatch 798then 799"$GIT_DIR"/hooks/pre-applypatch|| stop_here $this 800fi 801 802 tree=$(git write-tree)&& 803 commit=$( 804iftest -n"$ignore_date" 805then 806 GIT_AUTHOR_DATE= 807fi 808 parent=$(git rev-parse --verify -q HEAD)|| 809 say >&2"applying to an empty history" 810 811iftest -n"$committer_date_is_author_date" 812then 813 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" 814export GIT_COMMITTER_DATE 815fi&& 816 git commit-tree$tree ${parent:+-p} $parent<"$dotest/final-commit" 817) && 818 git update-ref -m"$GIT_REFLOG_ACTION:$FIRSTLINE" HEAD $commit $parent|| 819 stop_here $this 820 821iftest -f"$dotest/original-commit";then 822echo"$(cat "$dotest/original-commit")$commit">>"$dotest/rewritten" 823fi 824 825iftest -x"$GIT_DIR"/hooks/post-applypatch 826then 827"$GIT_DIR"/hooks/post-applypatch 828fi 829 830 go_next 831done 832 833iftest -s"$dotest"/rewritten;then 834 git notes copy --for-rewrite=rebase <"$dotest"/rewritten 835iftest -x"$GIT_DIR"/hooks/post-rewrite;then 836"$GIT_DIR"/hooks/post-rewrite rebase <"$dotest"/rewritten 837fi 838fi 839 840rm-fr"$dotest" 841git gc --auto