Re: [PATCH] Don't use cpio in git-clone when not installed
Mike Hommey <mh@glandium.org> writes:
Show 10 quoted lines
> On Wed, Oct 31, 2007 at 06:15:27PM -0700, Junio C Hamano wrote:
>> "Nguyen Thai Ngoc Duy" <pclouds@gmail.com> writes:
>>
>> > BTW, you have workaround for git-merge also? It uses cpio to save/restore state.
>>
>> Why do people want "workaround"? Is installing cpio such a
>> hassle?
>
> Note that to do what git-merge does with cpio, i wonder if it wouldn't
> be sensible to use git stash, now.
Like this? That's an excellent suggestion.
The patch uses the 'git stash create' which is in 'next' (jc/stash-create topic).
Having said that, the savestate()/restorestate() codepaths are only relevant to the "try multiple strategies and pick the best one" feature of git-merge, and that is where cpio is used (and the patch rewrites it to use stash). I am not sure if anybody ever used it in practice. I admit I am guilty of inventing it, but I certainly do not.
It might make sense to remove that try-multiple-strategies feature from git-merge and be done with it. It would certainly make the eventual rewrite to C much easier.
---
git-merge.sh | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
Show changes to git-merge.sh +5 −6
diff --git a/git-merge.sh b/git-merge.sh
index 3a01db0..e8916cc 100755
--- a/git-merge.sh
+++ b/git-merge.sh
@@ -28,20 +28,19 @@ allow_trivial_merge=t
dropsave() {
rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" \
- "$GIT_DIR/MERGE_SAVE" || exit 1
+ "$GIT_DIR/MERGE_STASH" || exit 1
}
savestate() {
# Stash away any local modifications.
- git diff-index -z --name-only $head |
- cpio -0 -o >"$GIT_DIR/MERGE_SAVE"
+ git stash create >"$GIT_DIR/MERGE_STASH"
}
restorestate() {
- if test -f "$GIT_DIR/MERGE_SAVE"
+ if test -f "$GIT_DIR/MERGE_STASH"
then
git reset --hard $head >/dev/null
- cpio -iuv <"$GIT_DIR/MERGE_SAVE"
+ git stash apply --index $(cat "$GIT_DIR/MERGE_STASH")
git update-index --refresh >/dev/null
fi
}
@@ -386,7 +385,7 @@ case "$use_strategies" in
single_strategy=no
;;
*)
- rm -f "$GIT_DIR/MERGE_SAVE"
+ rm -f "$GIT_DIR/MERGE_STASH"
single_strategy=yes
;;
esac