blame: add --abbrev command line option
PATCH v2 1/3 blame: add --abbrev command line option
--- builtin/blame.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
builtin/blame.c +3 -1
@@ -41,6 +41,7 @@ static int reverse;static int blank_boundary;static int incremental;static int xdl_opts; +static int abbrev =8 ;static enum date_mode blame_date_mode =DATE_ISO8601 ;static size_t blame_date_width;
@@ -1670,7 +1671,7 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt) cp =nth_line (sb, ent->lno);for (cnt =0 ; cnt < ent->num_lines; cnt++) {char ch; -int length = (opt &OUTPUT_LONG_OBJECT_NAME ) ?40 :8 ; +int length = (opt &OUTPUT_LONG_OBJECT_NAME ) ?40 : abbrev;if (suspect->commit->object.flags &UNINTERESTING ) {if (blank_boundary)
@@ -2310,6 +2311,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix) { OPTION_CALLBACK, 'C', NULL, &opt, "score", "Find line copies within and across files", PARSE_OPT_OPTARG, blame_copy_callback }, { OPTION_CALLBACK, 'M', NULL, &opt, "score", "Find line movements within and across files", PARSE_OPT_OPTARG, blame_move_callback },OPT_CALLBACK ('L' ,NULL , &bottomtop,"n,m" ,"Process only line range n,m, counting from 1" , blame_bottomtop_callback), +OPT__ABBREV (&abbrev),OPT_END () };
Signature · 1 line
1.7.4
PATCH v2 2/3 blame: honor core.abbrev
If user sets config.abbrev option, use it as if --abbrev was given. This is the default value and user can override different abbrev length by specifing --abbrev=N command line option.
--- builtin/blame.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
builtin/blame.c +6 -1
@@ -41,7 +41,7 @@ static int reverse;static int blank_boundary;static int incremental;static int xdl_opts; -static int abbrev =8 ; +static int abbrev =-1 ;static enum date_mode blame_date_mode =DATE_ISO8601 ;static size_t blame_date_width;
@@ -2347,6 +2347,11 @@ int cmd_blame(int argc, const char **argv, const char *prefix) parse_done: argc =parse_options_end (&ctx); +if (abbrev ==-1 ) + abbrev = default_abbrev; +/* one more abbrev length is needed for the boundary commit */ + abbrev++; +if (revs_file &&read_ancestry (revs_file))die_errno ("reading graft file '%s' failed" , revs_file);
Signature · 1 line
1.7.4
PATCH v2 3/3 Documentation: add --abbrev option to the man page of git blame
In reply to Namhyung Kim--- Documentation/git-blame.txt | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
Documentation/git-blame.txt +7 -1
@@ -9,7 +9,7 @@ SYNOPSIS -------- [verse] 'git blame' [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-e] [-p] [-w] [--incremental] [-L n,m] - [-S <revs-file>] [-M] [-C] [-C] [-C] [--since=<date>] + [-S <revs-file>] [-M] [-C] [-C] [-C] [--since=<date>] [--abbrev=<n>] [<rev> | --contents <file> | --reverse <rev>] [--] <file> DESCRIPTION
@@ -73,6 +73,12 @@ include::blame-options.txt[] Ignore whitespace when comparing the parent's version and the child's to find where the lines came from. +--abbrev=<n>:: + Instead of using the default 7+1 hexadecimal digits as the + abbreviated object name, use <n>+1 digits. Note that git + will add 1 for the boundary commit to be distinguished (with + a caret at the beginning). + THE PORCELAIN FORMAT --------------------
Signature · 1 line
1.7.4
Thanks.
As the meaning of the option changes between 1/3 and 2/3, let's squash these three patches into a single commit. Here is what I've tentatively queued.
commit 84393bfd731c435120dc1dda63432a70124821cb
Author: Namhyung Kim <[email protected]> Date: Wed Apr 6 11:20:50 2011 +0900
blame: add --abbrev command line option and make it honor core.abbrev
If user sets config.abbrev option, use it as if --abbrev was given. This is the default value and user can override different abbrev length by specifying the --abbrev=N command line option.
2011-04-05 (화), 20:18 -0700, Junio C Hamano:
Quoted 6 lines
Thanks.
As the meaning of the option changes between 1/3 and 2/3, let's squash these three patches into a single commit. Here is what I've tentatively queued.
Great! Thanks.
Quoted 12 lines
commit
84393bfd731c435120dc1dda63432a70124821cbAuthor: Namhyung Kim <[email protected]> Date: Wed Apr 6 11:20:50 2011 +0900blame: add --abbrev command line option and make it honor core.abbrev
If user sets config.abbrev option, use it as if --abbrev was given. This is the default value and user can override different abbrev length by specifying the --abbrev=N command line option.
Signed-off-by Namhyung Kim <[email protected]>Signed-off-by Junio C Hamano <[email protected]>
Signature · 2 lines
Regards, Namhyung Kim
Quoted 18 lines · Namhyung Kim
Signed-off-by Namhyung Kim <[email protected]>---
builtin/blame.c | 4 +++-1 files changed, 3 insertions(+), 1 deletions(-)builtin/blame.c +1
-0@@ -41,6 +41,7 @@ static int reverse; static int blank_boundary; static int incremental; static int xdl_opts; +static int abbrev =8 ; static enum date_mode blame_date_mode = DATE_ISO8601; static size_t blame_date_width;
builtin/blame.c static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt) · line 1674
Quoted 5 lines
builtin/blame.c +1
-1@@ -1670,7 +1671,7 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt) cp = nth_line(sb, ent->lno); for (cnt = 0; cnt < ent->num_lines; cnt++) { char ch; - int length = (opt & OUTPUT_LONG_OBJECT_NAME) ? 40 : 8; + int length = (opt & OUTPUT_LONG_OBJECT_NAME) ? 40 : abbrev;
Should this 40 be a constant?