Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-08-13 03:16:47 +0400
committerJunio C Hamano <junkio@cox.net>2006-08-13 04:08:07 +0400
commitfd7bcfb524a3313ef5361bdd8493ba50635f50f0 (patch)
tree1e8d0aff82644caa330a7a552777c7b61768d6ee /git-am.sh
parent022f25e8d4bd3eaed6bb6d80a242f8930687d483 (diff)
git-am: give better diagnostics when the patch does not apply during --3way
If the user tries to apply a patch that was hand-edited in such a way that it does not apply to the original file recorded on its "index" line anymore, we did detect the situation but did not issue an error message that is specific enough. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-am.sh')
-rwxr-xr-xgit-am.sh28
1 files changed, 19 insertions, 9 deletions
diff --git a/git-am.sh b/git-am.sh
index 04f0119435..d0af786aec 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -45,6 +45,12 @@ go_next () {
this=$next
}
+cannot_fallback () {
+ echo "$1"
+ echo "Cannot fall back to three-way merge."
+ exit 1
+}
+
fall_back_3way () {
O_OBJECT=`cd "$GIT_OBJECT_DIRECTORY" && pwd`
@@ -52,19 +58,23 @@ fall_back_3way () {
mkdir "$dotest/patch-merge-tmp-dir"
# First see if the patch records the index info that we can use.
- if git-apply -z --index-info "$dotest/patch" \
- >"$dotest/patch-merge-index-info" 2>/dev/null &&
- GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
- git-update-index -z --index-info <"$dotest/patch-merge-index-info" &&
- GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
- git-write-tree >"$dotest/patch-merge-base+" &&
- # index has the base tree now.
- GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
+ git-apply -z --index-info "$dotest/patch" \
+ >"$dotest/patch-merge-index-info" &&
+ GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
+ git-update-index -z --index-info <"$dotest/patch-merge-index-info" &&
+ GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
+ git-write-tree >"$dotest/patch-merge-base+" ||
+ cannot_fallback "Patch does not record usable index information."
+
+ echo Using index info to reconstruct a base tree...
+ if GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
git-apply $binary --cached <"$dotest/patch"
then
- echo Using index info to reconstruct a base tree...
mv "$dotest/patch-merge-base+" "$dotest/patch-merge-base"
mv "$dotest/patch-merge-tmp-index" "$dotest/patch-merge-index"
+ else
+ cannot_fallback "Did you hand edit your patch?
+It does not apply to blobs recorded in its index."
fi
test -f "$dotest/patch-merge-index" &&