Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH] Don't use cpio in git-clone when not installed

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:46
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Mike Hommey [off-list ref] writes:
On Wed, Oct 31, 2007 at 06:15:27PM -0700, Junio C Hamano wrote:
quoted
"Nguyen Thai Ngoc Duy" [off-list ref] writes:
quoted
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(-)
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help