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-01-12 10:07:27 +0300
committerJunio C Hamano <junkio@cox.net>2006-01-14 03:52:37 +0300
commit19205acfc29b6d39b5643a7f9a2448f89df14355 (patch)
tree18c617363cfae6b12b36e659b424eefb85db1e46 /git-checkout.sh
parent429608fc365d4e6e0db9dee72a0b103dce578722 (diff)
checkout: automerge local changes while switching branches.
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>
Diffstat (limited to 'git-checkout.sh')
-rwxr-xr-xgit-checkout.sh28
1 files changed, 27 insertions, 1 deletions
diff --git a/git-checkout.sh b/git-checkout.sh
index 3bbd111773..76e6a41c6c 100755
--- a/git-checkout.sh
+++ b/git-checkout.sh
@@ -121,7 +121,33 @@ then
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
#