Merge branch 'jc/maint-blame-unique-abbrev' into maint
"git blame" did not try to make sure that the abbreviated commit object names in its output are unique. * jc/maint-blame-unique-abbrev: blame: compute abbreviation width that ensures uniqueness
This commit is contained in:
commit
b700086d84
@ -1837,6 +1837,16 @@ static int read_ancestry(const char *graft_file)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int update_auto_abbrev(int auto_abbrev, struct origin *suspect)
|
||||||
|
{
|
||||||
|
const char *uniq = find_unique_abbrev(suspect->commit->object.sha1,
|
||||||
|
auto_abbrev);
|
||||||
|
int len = strlen(uniq);
|
||||||
|
if (auto_abbrev < len)
|
||||||
|
return len;
|
||||||
|
return auto_abbrev;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* How many columns do we need to show line numbers, authors,
|
* How many columns do we need to show line numbers, authors,
|
||||||
* and filenames?
|
* and filenames?
|
||||||
@ -1847,12 +1857,16 @@ static void find_alignment(struct scoreboard *sb, int *option)
|
|||||||
int longest_dst_lines = 0;
|
int longest_dst_lines = 0;
|
||||||
unsigned largest_score = 0;
|
unsigned largest_score = 0;
|
||||||
struct blame_entry *e;
|
struct blame_entry *e;
|
||||||
|
int compute_auto_abbrev = (abbrev < 0);
|
||||||
|
int auto_abbrev = default_abbrev;
|
||||||
|
|
||||||
for (e = sb->ent; e; e = e->next) {
|
for (e = sb->ent; e; e = e->next) {
|
||||||
struct origin *suspect = e->suspect;
|
struct origin *suspect = e->suspect;
|
||||||
struct commit_info ci;
|
struct commit_info ci;
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
|
if (compute_auto_abbrev)
|
||||||
|
auto_abbrev = update_auto_abbrev(auto_abbrev, suspect);
|
||||||
if (strcmp(suspect->path, sb->path))
|
if (strcmp(suspect->path, sb->path))
|
||||||
*option |= OUTPUT_SHOW_NAME;
|
*option |= OUTPUT_SHOW_NAME;
|
||||||
num = strlen(suspect->path);
|
num = strlen(suspect->path);
|
||||||
@ -1880,6 +1894,10 @@ static void find_alignment(struct scoreboard *sb, int *option)
|
|||||||
max_orig_digits = decimal_width(longest_src_lines);
|
max_orig_digits = decimal_width(longest_src_lines);
|
||||||
max_digits = decimal_width(longest_dst_lines);
|
max_digits = decimal_width(longest_dst_lines);
|
||||||
max_score_digits = decimal_width(largest_score);
|
max_score_digits = decimal_width(largest_score);
|
||||||
|
|
||||||
|
if (compute_auto_abbrev)
|
||||||
|
/* one more abbrev length is needed for the boundary commit */
|
||||||
|
abbrev = auto_abbrev + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2353,8 +2371,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
|
|||||||
parse_done:
|
parse_done:
|
||||||
argc = parse_options_end(&ctx);
|
argc = parse_options_end(&ctx);
|
||||||
|
|
||||||
if (abbrev == -1)
|
if (0 < abbrev)
|
||||||
abbrev = default_abbrev;
|
|
||||||
/* one more abbrev length is needed for the boundary commit */
|
/* one more abbrev length is needed for the boundary commit */
|
||||||
abbrev++;
|
abbrev++;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user