Code

Merge branch 'jk/merge-one-file-working-tree' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 13 May 2011 17:44:19 +0000 (10:44 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 13 May 2011 17:44:19 +0000 (10:44 -0700)
* jk/merge-one-file-working-tree:
  merge-one-file: fix broken merges with alternate work trees
  add tests for merge-index / merge-one-file

1  2 
git-merge-one-file.sh

diff --combined git-merge-one-file.sh
index b86402afa5d079df8d1cf6eebb15e5727cc8a5de,bb64a72ad3b8db6f43fafc5af87a1697b4bf2989..7aeb96952f668baef2fd18383806e13a20415f19
@@@ -22,6 -22,11 +22,11 @@@ LONG_USAGE="Usage: git merge-one-file $
  
  Blob ids and modes should be empty for missing files."
  
+ SUBDIRECTORY_OK=Yes
+ . git-sh-setup
+ cd_to_toplevel
+ require_work_tree
  if ! test "$#" -eq 7
  then
        echo "$LONG_USAGE"
@@@ -107,7 -112,7 +112,7 @@@ case "${1:-.}${2:-.}${3:-.}" i
                # remove lines that are unique to ours.
                orig=`git-unpack-file $2`
                sz0=`wc -c <"$orig"`
 -              diff -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add
 +              @@DIFF@@ -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add
                sz1=`wc -c <"$orig"`
  
                # If we do not have enough common material, it is not
  
        # Create the working tree file, using "our tree" version from the
        # index, and then store the result of the merge.
-       git checkout-index -f --stage=2 -- "$4" && cat "$src1" >"$4"
+       git checkout-index -f --stage=2 -- "$4" && cat "$src1" >"$4" || exit 1
        rm -f -- "$orig" "$src1" "$src2"
  
        if [ "$6" != "$7" ]; then