From: Junio C Hamano Date: Mon, 9 Jul 2012 16:01:37 +0000 (-0700) Subject: Merge branch 'jc/maint-blame-unique-abbrev' X-Git-Tag: v1.7.12-rc0~56 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3a335ee2da090e435bd771df56860496b570decc;p=git.git Merge branch 'jc/maint-blame-unique-abbrev' "git blame" did not try to make sure the abbreviated commit object names in its output are unique. * jc/maint-blame-unique-abbrev: blame: compute abbreviation width that ensures uniqueness --- 3a335ee2da090e435bd771df56860496b570decc diff --cc builtin/blame.c index 24d3dd529,f13ec327f..960c58d85 --- a/builtin/blame.c +++ b/builtin/blame.c @@@ -1837,6 -1828,28 +1837,16 @@@ static int read_ancestry(const char *gr 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 in decimal? - */ -static int lineno_width(int lines) -{ - int i, width; - - for (width = 1, i = 10; i <= lines; width++) - i *= 10; - return width; -} - /* * How many columns do we need to show line numbers, authors, * and filenames? @@@ -1877,9 -1894,13 +1891,13 @@@ static void find_alignment(struct score if (largest_score < ent_score(sb, e)) largest_score = ent_score(sb, e); } - max_orig_digits = lineno_width(longest_src_lines); - max_digits = lineno_width(longest_dst_lines); - max_score_digits = lineno_width(largest_score); + max_orig_digits = decimal_width(longest_src_lines); + max_digits = decimal_width(longest_dst_lines); + 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; } /*