summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 975bf9c)
raw | patch | inline | side by side (parent: 975bf9c)
author | Junio C Hamano <junkio@cox.net> | |
Mon, 15 May 2006 05:07:28 +0000 (22:07 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 15 May 2006 05:07:28 +0000 (22:07 -0700) |
When renaming leading/a/filename to leading/b/filename (and
"filename" is sufficiently long), we tried to squash the rename
to "leading/{a => b}/filename". However, when "/a" or "/b" part
is empty, we underflowed and tried to print a substring of
length -1.
Signed-off-by: Junio C Hamano <junkio@cox.net>
"filename" is sufficiently long), we tried to squash the rename
to "leading/{a => b}/filename". However, when "/a" or "/b" part
is empty, we underflowed and tried to print a substring of
length -1.
Signed-off-by: Junio C Hamano <junkio@cox.net>
diff.c | patch | blob | history |
index 7a7b839e56ac1ba2ed0b770a047aaf07bce23722..5285c0366738a9a6ff8fd116f74da099a5da2ae4 100644 (file)
--- a/diff.c
+++ b/diff.c
* name-a => name-b
*/
if (pfx_length + sfx_length) {
+ int a_midlen = len_a - pfx_length - sfx_length;
+ int b_midlen = len_b - pfx_length - sfx_length;
+ if (a_midlen < 0) a_midlen = 0;
+ if (b_midlen < 0) b_midlen = 0;
+
name = xmalloc(len_a + len_b - pfx_length - sfx_length + 7);
sprintf(name, "%.*s{%.*s => %.*s}%s",
pfx_length, a,
- len_a - pfx_length - sfx_length, a + pfx_length,
- len_b - pfx_length - sfx_length, b + pfx_length,
+ a_midlen, a + pfx_length,
+ b_midlen, b + pfx_length,
a + len_a - sfx_length);
}
else {