Skip to content

Commit

Permalink
branch -v: honor core.abbrev
Browse files Browse the repository at this point in the history
Use the value from 'core.abbrev' configuration variable unless user
specifies the length on command line when showing commit object name
in "branch -v" output.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Namhyung Kim authored and Junio C Hamano committed Jul 1, 2011
1 parent 76c82f9 commit b792c06
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Documentation/git-branch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ OPTIONS

--abbrev=<length>::
Alter the sha1's minimum display length in the output listing.
The default value is 7.
The default value is 7 and can be overridden by the `core.abbrev`
config option.

--no-abbrev::
Display the full sha1s in the output listing rather than abbreviating them.
Expand Down
5 changes: 4 additions & 1 deletion builtin/branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ static int opt_parse_merge_filter(const struct option *opt, const char *arg, int
int cmd_branch(int argc, const char **argv, const char *prefix)
{
int delete = 0, rename = 0, force_create = 0;
int verbose = 0, abbrev = DEFAULT_ABBREV, detached = 0;
int verbose = 0, abbrev = -1, detached = 0;
int reflog = 0;
enum branch_track track;
int kinds = REF_LOCAL_BRANCH;
Expand Down Expand Up @@ -696,6 +696,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
if (!!delete + !!rename + !!force_create > 1)
usage_with_options(builtin_branch_usage, options);

if (abbrev == -1)
abbrev = DEFAULT_ABBREV;

if (delete)
return delete_branches(argc, argv, delete > 1, kinds);
else if (argc == 0)
Expand Down

0 comments on commit b792c06

Please sign in to comment.