{"thread":{"id":"3836","subject":"git-diff-tree -B broken","startedAt":"2006-04-09T00:46:05Z","lastAt":"2006-04-09T03:30:56Z","messageCount":3,"participants":["Petr Baudis","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"18488","messageId":"20060409004605.GU27689@pasky.or.cz","threadId":"3836","inReplyTo":null,"subject":"git-diff-tree -B broken","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2006-04-09T00:46:05Z","receivedAt":"2006-04-09T00:46:05Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"  Hi,\n\n  no pun intended in the $SUBJ, but git-diff-tree -B seems to be giving\nme bogus output\n\n\t$ git-diff-tree -r -p -B -M 916d8240bfc8ef5b80780b1a32ebb83ed055a178 \\\n\t\t3c9324ea16c345fc0bc0f11041905ba714797e4a cg-mkpatch\n\tdiff --git a/cg-mkpatch b/cg-mkpatch\n\tdissimilarity index 57%\n\tindex 74fe917..c932bc9 100755\n\t--- cg-mkpatch\n\t+++ cg-mkpatch\n\t@@ -0,0 +0,0 @@\n\nand nothing else. I'm too tired to debug or bisect this (xdiff\nintroduction is the obvious suspect, I guess), just didn't want this\nto slip into the looming 1.3.0 so reporting early.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nRight now I am having amnesia and deja-vu at the same time.  I think\nI have forgotten this before.\n"},{"id":"18489","messageId":"7vwtdzcvhb.fsf@assigned-by-dhcp.cox.net","threadId":"3836","inReplyTo":"20060409004605.GU27689@pasky.or.cz","subject":"Re: git-diff-tree -B broken","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-04-09T02:51:12Z","receivedAt":"2006-04-09T02:51:12Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Petr Baudis <pasky@ucw.cz> writes:\n\n> \t$ git-diff-tree -r -p -B -M 916d8240bfc8ef5b80780b1a32ebb83ed055a178 \\\n> \t\t3c9324ea16c345fc0bc0f11041905ba714797e4a cg-mkpatch\n> \tdiff --git a/cg-mkpatch b/cg-mkpatch\n> \tdissimilarity index 57%\n> \tindex 74fe917..c932bc9 100755\n> \t--- cg-mkpatch\n> \t+++ cg-mkpatch\n> \t@@ -0,0 +0,0 @@\n>\n> and nothing else. I'm too tired to debug or bisect this (xdiff\n> introduction is the obvious suspect, I guess), just didn't want this\n> to slip into the looming 1.3.0 so reporting early.\n\nThanks.\n\nThere are two issues.  One of them is addressed with the\nattached patch, which is just an artifact of the xdiff\nintroduction.\n\nAnother issue is a bit bigger.\n\nThe changes to the sample cg-mkpatch is estimated to be big\nenough to get broken, just in case if there is another file\nwhose postimage that is more similar than the postimage of\ncg-mkpatch itself, so that it can be matched up with the other\nfile, but it is _not_ dissimilar enough that diffcore_break()\ncode marks it to be merged back together if pieces of the broken\npair do not get matched up with other files.  And in this\nparticular case, since you are limiting the search space to a\nsingle file, there is no other files to match, so the broken\npair should survive the rename detection match-up, and they\nshould be shown as a normal diff without dissimilarity index at\nall.\n\nThe funny thing is, the broken pair are matched up with\nthemselves, with similarity index of 57% (they originally are\nfrom the same filepair, so that is natural).  So in this case,\nrename code _should_ take notice.  I'll work on a fix.\n\n-- >8 --\ndiff --git a/diff.c b/diff.c\nindex ce98a90..e887410 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -145,8 +145,9 @@ static void emit_rewrite_diff(const char\n \t\t\t      struct diff_filespec *one, \n \t\t\t      struct diff_filespec *two)\n {\n-\t/* Use temp[i].name as input, name_a and name_b as labels */\n \tint lc_a, lc_b;\n+\tdiff_populate_filespec(one, 0);\n+\tdiff_populate_filespec(two, 0);\n \tlc_a = count_lines(one->data, one->size);\n \tlc_b = count_lines(two->data, two->size);\n \tprintf(\"--- %s\\n+++ %s\\n@@ -\", name_a, name_b);\n"},{"id":"18490","messageId":"7vr747ctn3.fsf_-_@assigned-by-dhcp.cox.net","threadId":"3836","inReplyTo":"7vwtdzcvhb.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] diffcore-rename: fix merging back a broken pair.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-04-09T03:30:56Z","receivedAt":"2006-04-09T03:30:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When a broken pair is matched up by rename detector to be merged\nback, we do not want to say it is \"dissimilar\" with the\nsimilarity index.  The output should just say they were changed,\ntaking the break score left by the earlier diffcore-break run if\nany.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n diffcore-rename.c |   14 ++++++++++----\n 1 files changed, 10 insertions(+), 4 deletions(-)\n\nc17de73d793ff20fce6bcc8427e5f10ab8a2a7c5\ndiff --git a/diffcore-rename.c b/diffcore-rename.c\nindex e992698..d57e865 100644\n--- a/diffcore-rename.c\n+++ b/diffcore-rename.c\n@@ -54,12 +54,14 @@ static struct diff_rename_dst *locate_re\n /* Table of rename/copy src files */\n static struct diff_rename_src {\n \tstruct diff_filespec *one;\n+\tunsigned short score; /* to remember the break score */\n \tunsigned src_path_left : 1;\n } *rename_src;\n static int rename_src_nr, rename_src_alloc;\n \n static struct diff_rename_src *register_rename_src(struct diff_filespec *one,\n-\t\t\t\t\t\t   int src_path_left)\n+\t\t\t\t\t\t   int src_path_left,\n+\t\t\t\t\t\t   unsigned short score)\n {\n \tint first, last;\n \n@@ -89,6 +91,7 @@ static struct diff_rename_src *register_\n \t\tmemmove(rename_src + first + 1, rename_src + first,\n \t\t\t(rename_src_nr - first - 1) * sizeof(*rename_src));\n \trename_src[first].one = one;\n+\trename_src[first].score = score;\n \trename_src[first].src_path_left = src_path_left;\n \treturn &(rename_src[first]);\n }\n@@ -198,7 +201,10 @@ static void record_rename_pair(int dst_i\n \tfill_filespec(two, dst->sha1, dst->mode);\n \n \tdp = diff_queue(NULL, one, two);\n-\tdp->score = score;\n+\tif (!strcmp(src->path, dst->path))\n+\t\tdp->score = rename_src[src_index].score;\n+\telse\n+\t\tdp->score = score;\n \tdp->source_stays = rename_src[src_index].src_path_left;\n \trename_dst[dst_index].pair = dp;\n }\n@@ -256,10 +262,10 @@ void diffcore_rename(struct diff_options\n \t\t\t * that means the source actually stays.\n \t\t\t */\n \t\t\tint stays = (p->broken_pair && !p->score);\n-\t\t\tregister_rename_src(p->one, stays);\n+\t\t\tregister_rename_src(p->one, stays, p->score);\n \t\t}\n \t\telse if (detect_rename == DIFF_DETECT_COPY)\n-\t\t\tregister_rename_src(p->one, 1);\n+\t\t\tregister_rename_src(p->one, 1, p->score);\n \t}\n \tif (rename_dst_nr == 0 || rename_src_nr == 0 ||\n \t    (0 < rename_limit && rename_limit < rename_dst_nr))\n-- \n1.2.6.gad0b\n"}]}