aboutsummaryrefslogtreecommitdiff
path: root/builtin-branch.c
diff options
context:
space:
mode:
authorJulian Phillips <julian@quantumfyre.co.uk>2007-03-03 00:31:16 +0000
committerJunio C Hamano <junkio@cox.net>2007-03-02 16:38:47 -0800
commit43bc820db78be5e3230ae675018a7a7af50ccc88 (patch)
treef01d249967bb8c084b9bb1ceda21be83540b4766 /builtin-branch.c
parent62273826fe977d4c1fa445edf9d0e4ab02274fa2 (diff)
downloadgit-43bc820db78be5e3230ae675018a7a7af50ccc88.tar.gz
git-43bc820db78be5e3230ae675018a7a7af50ccc88.tar.xz
git-branch: improve abbreviation of sha1s in verbose mode
git-branch has an --abbrev= command line option, but it does no checking of the input. Take the argument parsing code from setup_revisions in revisions.c, and also the code for parsing the --no-abbrev option. Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-branch.c')
-rw-r--r--builtin-branch.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/builtin-branch.c b/builtin-branch.c
index d0179b00a..d37184965 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -12,7 +12,7 @@
#include "builtin.h"
static const char builtin_branch_usage[] =
- "git-branch [-r] (-d | -D) <branchname> | [-l] [-f] <branchname> [<start-point>] | (-m | -M) [<oldbranch>] <newbranch> | [--color | --no-color] [-r | -a] [-v [--abbrev=<length>]]";
+ "git-branch [-r] (-d | -D) <branchname> | [-l] [-f] <branchname> [<start-point>] | (-m | -M) [<oldbranch>] <newbranch> | [--color | --no-color] [-r | -a] [-v [--abbrev=<length> | --no-abbrev]]";
#define REF_UNKNOWN_TYPE 0x00
#define REF_LOCAL_BRANCH 0x01
@@ -446,8 +446,16 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
reflog = 1;
continue;
}
+ if (!prefixcmp(arg, "--no-abbrev")) {
+ abbrev = 0;
+ continue;
+ }
if (!prefixcmp(arg, "--abbrev=")) {
- abbrev = atoi(arg+9);
+ abbrev = strtoul(arg + 9, NULL, 10);
+ if (abbrev < MINIMUM_ABBREV)
+ abbrev = MINIMUM_ABBREV;
+ else if (abbrev > 40)
+ abbrev = 40;
continue;
}
if (!strcmp(arg, "-v")) {