git-blame --porcelain: quote filename in c-style when needed.
Otherwise a pathname that has funny characters such as LF would screw up the parsing programs of the output. Strictly speaking, this is not backward compatible, but the current output for pathnames that have embedded LF and such cannot be sanely parsed anyway, and pathnames that only use characters from the portable pathname character set won't be affected. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
717d1462ba
commit
46e5e69d5f
@ -1182,6 +1182,13 @@ static void get_commit_info(struct commit *commit,
|
|||||||
summary_buf[len] = 0;
|
summary_buf[len] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void write_filename_info(const char *path)
|
||||||
|
{
|
||||||
|
printf("filename ");
|
||||||
|
write_name_quoted(NULL, 0, path, 1, stdout);
|
||||||
|
putchar('\n');
|
||||||
|
}
|
||||||
|
|
||||||
static void found_guilty_entry(struct blame_entry *ent)
|
static void found_guilty_entry(struct blame_entry *ent)
|
||||||
{
|
{
|
||||||
if (ent->guilty)
|
if (ent->guilty)
|
||||||
@ -1209,9 +1216,7 @@ static void found_guilty_entry(struct blame_entry *ent)
|
|||||||
if (suspect->commit->object.flags & UNINTERESTING)
|
if (suspect->commit->object.flags & UNINTERESTING)
|
||||||
printf("boundary\n");
|
printf("boundary\n");
|
||||||
}
|
}
|
||||||
printf("filename ");
|
write_filename_info(suspect->path);
|
||||||
write_name_quoted(NULL, 0, suspect->path, 1, stdout);
|
|
||||||
putchar('\n');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1315,13 +1320,13 @@ static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent)
|
|||||||
printf("committer-mail %s\n", ci.committer_mail);
|
printf("committer-mail %s\n", ci.committer_mail);
|
||||||
printf("committer-time %lu\n", ci.committer_time);
|
printf("committer-time %lu\n", ci.committer_time);
|
||||||
printf("committer-tz %s\n", ci.committer_tz);
|
printf("committer-tz %s\n", ci.committer_tz);
|
||||||
printf("filename %s\n", suspect->path);
|
write_filename_info(suspect->path);
|
||||||
printf("summary %s\n", ci.summary);
|
printf("summary %s\n", ci.summary);
|
||||||
if (suspect->commit->object.flags & UNINTERESTING)
|
if (suspect->commit->object.flags & UNINTERESTING)
|
||||||
printf("boundary\n");
|
printf("boundary\n");
|
||||||
}
|
}
|
||||||
else if (suspect->commit->object.flags & MORE_THAN_ONE_PATH)
|
else if (suspect->commit->object.flags & MORE_THAN_ONE_PATH)
|
||||||
printf("filename %s\n", suspect->path);
|
write_filename_info(suspect->path);
|
||||||
|
|
||||||
cp = nth_line(sb, ent->lno);
|
cp = nth_line(sb, ent->lno);
|
||||||
for (cnt = 0; cnt < ent->num_lines; cnt++) {
|
for (cnt = 0; cnt < ent->num_lines; cnt++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user