Merge branch 'jk/blame-fixes'
"git blame --porcelain" misidentified the "previous" <commit, path> pair (aka "source") when contents came from two or more files. * jk/blame-fixes: blame: output porcelain "previous" header for each file blame: handle --no-abbrev blame: fix alignment with --abbrev=40
This commit is contained in:
@ -1700,13 +1700,23 @@ static void get_commit_info(struct commit *commit,
|
||||
}
|
||||
|
||||
/*
|
||||
* Write out any suspect information which depends on the path. This must be
|
||||
* handled separately from emit_one_suspect_detail(), because a given commit
|
||||
* may have changes in multiple paths. So this needs to appear each time
|
||||
* we mention a new group.
|
||||
*
|
||||
* To allow LF and other nonportable characters in pathnames,
|
||||
* they are c-style quoted as needed.
|
||||
*/
|
||||
static void write_filename_info(const char *path)
|
||||
static void write_filename_info(struct origin *suspect)
|
||||
{
|
||||
if (suspect->previous) {
|
||||
struct origin *prev = suspect->previous;
|
||||
printf("previous %s ", oid_to_hex(&prev->commit->object.oid));
|
||||
write_name_quoted(prev->path, stdout, '\n');
|
||||
}
|
||||
printf("filename ");
|
||||
write_name_quoted(path, stdout, '\n');
|
||||
write_name_quoted(suspect->path, stdout, '\n');
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1735,11 +1745,6 @@ static int emit_one_suspect_detail(struct origin *suspect, int repeat)
|
||||
printf("summary %s\n", ci.summary.buf);
|
||||
if (suspect->commit->object.flags & UNINTERESTING)
|
||||
printf("boundary\n");
|
||||
if (suspect->previous) {
|
||||
struct origin *prev = suspect->previous;
|
||||
printf("previous %s ", oid_to_hex(&prev->commit->object.oid));
|
||||
write_name_quoted(prev->path, stdout, '\n');
|
||||
}
|
||||
|
||||
commit_info_destroy(&ci);
|
||||
|
||||
@ -1760,7 +1765,7 @@ static void found_guilty_entry(struct blame_entry *ent,
|
||||
oid_to_hex(&suspect->commit->object.oid),
|
||||
ent->s_lno + 1, ent->lno + 1, ent->num_lines);
|
||||
emit_one_suspect_detail(suspect, 0);
|
||||
write_filename_info(suspect->path);
|
||||
write_filename_info(suspect);
|
||||
maybe_flush_or_die(stdout, "stdout");
|
||||
}
|
||||
pi->blamed_lines += ent->num_lines;
|
||||
@ -1884,7 +1889,7 @@ static void emit_porcelain_details(struct origin *suspect, int repeat)
|
||||
{
|
||||
if (emit_one_suspect_detail(suspect, repeat) ||
|
||||
(suspect->commit->object.flags & MORE_THAN_ONE_PATH))
|
||||
write_filename_info(suspect->path);
|
||||
write_filename_info(suspect);
|
||||
}
|
||||
|
||||
static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent,
|
||||
@ -2655,9 +2660,11 @@ parse_done:
|
||||
} else if (show_progress < 0)
|
||||
show_progress = isatty(2);
|
||||
|
||||
if (0 < abbrev)
|
||||
if (0 < abbrev && abbrev < GIT_SHA1_HEXSZ)
|
||||
/* one more abbrev length is needed for the boundary commit */
|
||||
abbrev++;
|
||||
else if (!abbrev)
|
||||
abbrev = GIT_SHA1_HEXSZ;
|
||||
|
||||
if (revs_file && read_ancestry(revs_file))
|
||||
die_errno("reading graft file '%s' failed", revs_file);
|
||||
|
Reference in New Issue
Block a user