758134F5B415A037FAE34C4
    #ˆÆË„™p?ÀÉ ?÷    ##!/bin/sh
#
# Copyright (c) 2005, 2006 Junio C Hamano

SUBDIRECTORY_OK=Yes
OPTIONS_KEEPDASHDASH=
OPTIONS_SPEC="\
git am [options] [(<mbox>|<Maildir>)...]
git am [options] (--resolved | --skip | --abort)
--
i,interactive   run interactively
b,binary*       (historical option -- no-op)
3,3way          allow fall back on 3way merging if needed
q,quiet         be quiet
s,signoff       add a Signed-off-by line to the commit message
u,utf8          recode into utf8 (default)
k,keep          pass -k flag to git-mailinfo
keep-non-patch  pass -b flag to git-mailinfo
keep-cr         pass --keep-cr flag to git-mailsplit for mbox format
no-keep-cr      do not pass --keep-cr flag to git-mailsplit independent of am.keepcr
c,scissors      strip everything before a scissors line
whitespace=     pass it through git-apply
ignore-space-change pass it through git-apply
ignore-whitespace pass it through git-apply
directory=      pass it through git-apply
exclude=        pass it through git-apply
include=        pass it through git-apply
C=              pass it through git-apply
p=              pass it through git-apply
patch-format=   format the patch(es) are in
reject          pass it through git-apply
resolvemsg=     override error message when patch failure occurs
continue        continue applying patches after resolving a conflict
r,resolved      synonyms for --continue
skip            skip the current patch
abort           restore the original branch and abort the patching operation.
committer-date-is-author-date    lie about committer date
ignore-date     use current timestamp for author date
rerere-autoupdate update the index with reused conflict resolution if possible
rebasing*       (internal use for git-rebase)"

. git-sh-setup
. git-sh-i18n
prefix=$(git rev-parse --show-prefix)
set_reflog_action am
require_work_tree
cd_to_toplevel

git var GIT_COMMITTER_IDENT >/dev/null ||
	die "$(gettext "You need to set your committer info first")"

if git rev-parse --verify -q HEAD >/dev/null
then
	HAS_HEAD=yes
else
	HAS_HEAD=
fi

cmdline="git am"
if test '' != "$interactive"
then
	cmdline="$cmdline -i"
fi
if test '' != "$threeway"
then
	cmdline="$cmdline -3"
fi

sq () {
	git rev-parse --sq-quote "$@"
}

stop_here () {
    echo "$1" >"$dotest/next"
    git rev-parse --verify -q HEAD >"$dotest/abort-safety"
    exit 1
}

safe_to_abort () {
	if test -f "$dotest/dirtyindex"
	then
		return 1
	fi

	if ! test -s "$dotest/abort-safety"
	then
		return 0
	fi

	abort_safety=$(cat "$dotest/abort-safety")
	if test "z$(git rev-parse --verify -q HEAD)" = "z$abort_safety"
	then
		return 0
	fi
	gettextln "You seem to have moved HEAD since the last 'am' failure.
Not rewinding to ORIG_HEAD" >&2
	return 1
}

stop_here_user_resolve () {
    if [ -n "$resolvemsg" ]; then
	    printf '%s\n' "$resolvemsg"
	    stop_here $1
    fi
    eval_gettextln "When you have resolved this problem, run \"\$cmdline --resolved\".
If you prefer to skip this patch, run \"\$cmdline --skip\" instead.
To restore the original branch and stop patching, run \"\$cmdline --abort\"."

    stop_here $1
}

go_next () {
	rm -f "$dotest/$msgnum" "$dotest/msg" "$dotest/msg-clean" \
		"$dotest/patch" "$dotest/info"
	echo "$next" >"$dotest/next"
	this=$next
}

cannot_fallback () {
	echo "$1"
	gettextln "Cannot fall back to three-way merge."
	exit 1
}

fall_back_3way () {
    O_OBJECT=`cd "$GIT_OBJECT_DIRECTORY" && pwd`

    rm -fr "$dotest"/patch-merge-*
    mkdir "$dotest/patch-merge-tmp-dir"

    # First see if the patch records the index info that we can use.
    cmd="git apply $git_apply_opt --build-fake-ancestor" &&
    cmd="$cmd "'"$dotest/patch-merge-tmp-index" "$dotest/patch"' &&
    eval "$cmd" &&
    GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
    git write-tree >"$dotest/patch-merge-base+" ||
    cannot_fallback "$(gettext "Repository lacks necessary blobs to fall back on 3-way merge.")"

    say "$(gettext "Using index info to reconstruct a base tree...")"

    cmd='GIT_INDEX_FILE="$dotest/patch-merge-tmp-index"'

    if test -z 