summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 429608f)
raw | patch | inline | side by side (parent: 429608f)
author | Junio C Hamano <junkio@cox.net> | |
Thu, 12 Jan 2006 07:07:27 +0000 (23:07 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 14 Jan 2006 00:52:37 +0000 (16:52 -0800) |
When switching branches, if the working tree has a local
modification at paths that are different between current and new
branches, we refused the operation saying "cannot merge." This
attempts to do an automerge for such paths.
This is still experimental.
Signed-off-by: Junio C Hamano <junkio@cox.net>
modification at paths that are different between current and new
branches, we refused the operation saying "cannot merge." This
attempts to do an automerge for such paths.
This is still experimental.
Signed-off-by: Junio C Hamano <junkio@cox.net>
git-checkout.sh | patch | blob | history |
diff --git a/git-checkout.sh b/git-checkout.sh
index 3bbd1117739b02572aece86030bb9f02f3110d34..76e6a41c6cd9a0e5c87b64132f6af02570f00983 100755 (executable)
--- a/git-checkout.sh
+++ b/git-checkout.sh
git-checkout-index -q -f -u -a
else
git-update-index --refresh >/dev/null
- git-read-tree -m -u $old $new
+ git-read-tree -m -u $old $new || (
+ echo >&2 -n "Try automerge [y/N]? "
+ read yesno
+ case "$yesno" in [yY]*) ;; *) exit 1 ;; esac
+
+ # NEEDSWORK: We may want to reset the index from the $new for
+ # these paths after the automerge happens, but it is not done
+ # yet. Probably we need to leave unmerged ones alone, and
+ # yank the object name & mode from $new for cleanly merged
+ # paths and stuff them in the index.
+
+ names=`git diff-files --name-only`
+ case "$names" in
+ '') ;;
+ *)
+ echo "$names" | git update-index --remove --stdin ;;
+ esac
+
+ work=`git write-tree` &&
+ git read-tree -m -u $old $work $new || exit
+ if result=`git write-tree 2>/dev/null`
+ then
+ echo >&2 "Trivially automerged." ;# can this even happen?
+ exit 0
+ fi
+ git merge-index -o git-merge-one-file -a
+ )
fi
#