1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-02 15:28:21 +01:00
git/t/t4001-diff-rename.sh
Junio C Hamano ec1fcc16af Show original and resulting blob object info in diff output.
This adds more cruft to diff --git header to record the blob SHA1 and
the mode the patch/diff is intended to be applied against, to help the
receiving end fall back on a three-way merge.  The new header looks
like this:

    diff --git a/apply.c b/apply.c
    index 7be5041..8366082 100644
    --- a/apply.c
    +++ b/apply.c
    @@ -14,6 +14,7 @@
     //    files that are being modified, but doesn't apply the patch
     //  --stat does just a diffstat, and doesn't actually apply
    +//  --show-index-info shows the old and new index info for...
    ...

Upon receiving such a patch, if the patch did not apply cleanly to the
target tree, the recipient can try to find the matching old objects in
her object database and create a temporary tree, apply the patch to
that temporary tree, and attempt a 3-way merge between the patched
temporary tree and the target tree using the original temporary tree
as the common ancestor.

The patch lifts the code to compute the hash for an on-filesystem
object from update-index.c and makes it available to the diff output
routine.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-07 03:42:00 -07:00

67 lines
1 KiB
Bash
Executable file

#!/bin/sh
#
# Copyright (c) 2005 Junio C Hamano
#
test_description='Test rename detection in diff engine.
'
. ./test-lib.sh
. ../diff-lib.sh
echo >path0 'Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9
Line 10
line 11
Line 12
Line 13
Line 14
Line 15
'
test_expect_success \
'update-cache --add a file.' \
'git-update-index --add path0'
test_expect_success \
'write that tree.' \
'tree=$(git-write-tree) && echo $tree'
sed -e 's/line/Line/' <path0 >path1
rm -f path0
test_expect_success \
'renamed and edited the file.' \
'git-update-index --add --remove path0 path1'
test_expect_success \
'git-diff-index -p -M after rename and editing.' \
'git-diff-index -p -M $tree >current'
cat >expected <<\EOF
diff --git a/path0 b/path1
rename from path0
rename to path1
--- a/path0
+++ b/path1
@@ -8,7 +8,7 @@ Line 7
Line 8
Line 9
Line 10
-line 11
+Line 11
Line 12
Line 13
Line 14
EOF
test_expect_success \
'validate the output.' \
'compare_diff_patch current expected'
test_done