X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=diff-helper.c;h=c9e287f652b9cba95dd6e181066c1efa1a73307c;hb=3b42a63cb5845ef1c818f6b00e693c61469ee966;hp=03ac9104cd3348eda69d626d33089753ac0d3ed0;hpb=367cec1c024c3849cb32eaac15884a4adfefe1de;p=git.git diff --git a/diff-helper.c b/diff-helper.c index 03ac9104..c9e287f6 100644 --- a/diff-helper.c +++ b/diff-helper.c @@ -15,6 +15,7 @@ static const char *diff_helper_usage = int main(int ac, const char **av) { struct strbuf sb; + const char *garbage_flush_format; strbuf_init(&sb); @@ -30,6 +31,8 @@ int main(int ac, const char **av) { usage(diff_helper_usage); ac--; av++; } + garbage_flush_format = (line_termination == 0) ? "%s" : "%s\n"; + /* the remaining parameters are paths patterns */ diff_setup(0); @@ -77,17 +80,16 @@ int main(int ac, const char **av) { if (!strchr("MCRNDU", status)) break; two_paths = score = 0; - if (status == 'R' || status == 'C') { + if (status == 'R' || status == 'C') two_paths = 1; - sscanf(cp, "%d", &score); - if (line_termination) { - cp = strchr(cp, - inter_name_termination); - if (!cp) - break; - } - } + /* pick up score if exists */ + if (sscanf(cp, "%d", &score) != 1) + score = 0; + cp = strchr(cp, + inter_name_termination); + if (!cp) + break; if (*cp++ != inter_name_termination) break; @@ -129,17 +131,17 @@ int main(int ac, const char **av) { new_path); continue; } - if (pickaxe) - diffcore_pickaxe(pickaxe, pickaxe_opts); if (1 < ac) diffcore_pathspec(av + 1); + if (pickaxe) + diffcore_pickaxe(pickaxe, pickaxe_opts); diff_flush(DIFF_FORMAT_PATCH, 0); - printf("%s\n", sb.buf); + printf(garbage_flush_format, sb.buf); } - if (pickaxe) - diffcore_pickaxe(pickaxe, pickaxe_opts); if (1 < ac) diffcore_pathspec(av + 1); + if (pickaxe) + diffcore_pickaxe(pickaxe, pickaxe_opts); diff_flush(DIFF_FORMAT_PATCH, 0); return 0; }