X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=git-applypatch.sh;h=14635d9bce2b496984f56a656d52cf75523a208e;hb=a24e658649170c99fdcb4aaa41545679ad02f755;hp=fd594ed4e48a1aee7f4e9c0a6bbb3a44f1bb2120;hpb=215a7ad1ef790467a4cd3f0dcffbd6e5f04c38f7;p=git.git diff --git a/git-applypatch.sh b/git-applypatch.sh index fd594ed4..14635d9b 100755 --- a/git-applypatch.sh +++ b/git-applypatch.sh @@ -29,10 +29,10 @@ INFO=$3 SIGNOFF=$4 EDIT=${VISUAL:-${EDITOR:-vi}} -export GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' .dotest/info)" -export GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' .dotest/info)" -export GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' .dotest/info)" -export SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' .dotest/info)" +export GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$INFO")" +export GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' "$INFO")" +export GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$INFO")" +export SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$INFO")" if test '' != "$SIGNOFF" then @@ -54,8 +54,10 @@ then sed -ne '/^Signed-off-by: /p' "$MSGFILE" | tail -n 1 ` - test "$LAST_SIGNED_OFF_BY" = "$SIGNOFF" || - echo "$SIGNOFF" >>"$MSGFILE" + test "$LAST_SIGNED_OFF_BY" = "$SIGNOFF" || { + test '' = "$LAST_SIGNED_OFF_BY" && echo + echo "$SIGNOFF" + } >>"$MSGFILE" fi fi @@ -99,7 +101,12 @@ echo echo Applying "'$SUBJECT'" echo -git-apply --index "$PATCHFILE" || exit 1 +git-apply --index "$PATCHFILE" || { + # Here if we know which revision the patch applies to, + # we create a temporary working tree and index, apply the + # patch, and attempt 3-way merge with the resulting tree. + exit 1 +} if test -x "$GIT_DIR"/hooks/pre-applypatch then @@ -108,9 +115,10 @@ fi tree=$(git-write-tree) || exit 1 echo Wrote tree $tree -commit=$(git-commit-tree $tree -p $(cat "$GIT_DIR"/HEAD) < "$final") || exit 1 +parent=$(git-rev-parse --verify HEAD) && +commit=$(git-commit-tree $tree -p $parent <"$final") || exit 1 echo Committed: $commit -echo $commit > "$GIT_DIR"/HEAD +git-update-ref HEAD $commit $parent || exit if test -x "$GIT_DIR"/hooks/post-applypatch then