summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 364b852)
raw | patch | inline | side by side (parent: 364b852)
author | Junio C Hamano <junkio@cox.net> | |
Wed, 4 Apr 2007 21:12:03 +0000 (14:12 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 4 Apr 2007 21:12:03 +0000 (14:12 -0700) |
The earlier code does not swap hunks when the beginning of the
first side is identical to the whole of the second side. In
such a case, the first one should sort later.
Signed-off-by: Junio C Hamano <junkio@cox.net>
first side is identical to the whole of the second side. In
such a case, the first one should sort later.
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-rerere.c | patch | blob | history | |
t/t4200-rerere.sh | patch | blob | history |
diff --git a/builtin-rerere.c b/builtin-rerere.c
index b463c07f04b127ee3d1e17962813367fb4a5a588..8c2c8bdc18a69e4dff7386548e5f7ea78a133f7b 100644 (file)
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
else if (!prefixcmp(buf, "======="))
hunk = 2;
else if (!prefixcmp(buf, ">>>>>>> ")) {
+ int one_is_longer = (one->nr > two->nr);
+ int common_len = one_is_longer ? two->nr : one->nr;
+ int cmp = memcmp(one->ptr, two->ptr, common_len);
+
hunk_no++;
hunk = 0;
- if (memcmp(one->ptr, two->ptr, one->nr < two->nr ?
- one->nr : two->nr) > 0) {
+ if ((cmp > 0) || ((cmp == 0) && one_is_longer)) {
struct buffer *swap = one;
one = two;
two = swap;
diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index bc878d750dd526b38220bb6ab040c793946805a7..6ba63d7173ba5d333d80c017c4ef5a8c77b90a11 100755 (executable)
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
git checkout -b second master
git show first:a1 |
-sed -e 's/To die, t/To die! T/' -e 's/life;$/life./' > a1
+sed -e 's/To die, t/To die! T/' > a1
+echo "* END *" >>a1
git commit -q -a -m second
# activate rerere
test_expect_success 'preimage has right number of lines' '
cnt=$(sed -ne "/^<<<<<<</,/^>>>>>>>/p" $rr/preimage | wc -l) &&
- test $cnt = 10
+ test $cnt = 9
'
For in that sleep of death what dreams may come
When we have shuffled off this mortal coil,
Must give us pause: there's the respect
+ That makes calamity of so long life;
-<<<<<<<
--That makes calamity of so long life.
-=======
- That makes calamity of so long life;
+-* END *
->>>>>>>
EOF
git rerere diff > out