git-am: use apply --cached
Now 'git apply' can apply patch without working tree, preparation of pristine preimage and postimage trees that are done when falling back on 3-way merge by "git am" can do so without temporary files. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
May 15, 2006 at 17:25 UTC
b7627278e200d8a80df6ee437b1a01d88f2b4883
1 file changed
+2
-36
git-am.sh
+2
-36
@@ -55,46 +55,12 @@ fall_back_3way () {
55
GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
56
git-write-tree >"$dotest/patch-merge-base+" &&
57
# index has the base tree now.
58
- (
59
- cd "$dotest/patch-merge-tmp-dir" &&
60
- GIT_INDEX_FILE="../patch-merge-tmp-index" \
61
- GIT_OBJECT_DIRECTORY="$O_OBJECT" \
62
- git-apply $binary --index <../patch
63
- )
58
+ GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
59
+ git-apply $binary --cached <"$dotest/patch"
60
then
61
echo Using index info to reconstruct a base tree...
62
mv "$dotest/patch-merge-base+" "$dotest/patch-merge-base"
63
mv "$dotest/patch-merge-tmp-index" "$dotest/patch-merge-index"
68
- else
69
- # Otherwise, try nearby trees that can be used to apply the
70
- # patch.
71
- (
72
- N=10
73
-
74
- # Hoping the patch is against our recent commits...
75
- git-rev-list --max-count=$N HEAD
76
-
77
- # or hoping the patch is against known tags...
78
- git-ls-remote --tags .
79
- ) |
80
- while read base junk
81
- do
82
- # See if we have it as a tree...
83
- git-cat-file tree "$base" >/dev/null 2>&1 || continue
84
-
85
- rm -fr "$dotest"/patch-merge-* &&
86
- mkdir "$dotest/patch-merge-tmp-dir" || break
87
- (
88
- cd "$dotest/patch-merge-tmp-dir" &&
89
- GIT_INDEX_FILE=../patch-merge-tmp-index &&
90
- GIT_OBJECT_DIRECTORY="$O_OBJECT" &&
91
- export GIT_INDEX_FILE GIT_OBJECT_DIRECTORY &&
92
- git-read-tree "$base" &&
93
- git-apply $binary --index &&
94
- mv ../patch-merge-tmp-index ../patch-merge-index &&
95
- echo "$base" >../patch-merge-base
96
- ) <"$dotest/patch" 2>/dev/null && break
97
- done
64
fi
65
66
test -f "$dotest/patch-merge-index" &&