From: Julian Phillips <julian@quantumfyre.co.uk>
To: git@vger.kernel.org
Cc: Julian Phillips <julian@quantumfyre.co.uk>
Subject: [PATCH 1/2] git-branch: improve abbreviation of sha1s in verbose mode
Date: Sat, 3 Mar 2007 00:31:16 +0000 [thread overview]
Message-ID: <11728818771064-git-send-email-julian@quantumfyre.co.uk> (raw)
Message-ID: <028df363480685d1fe1ab84a99b2573dda853440.1172881822.git.julian@quantumfyre.co.uk> (raw)
In-Reply-To: <11728818772136-git-send-email-julian@quantumfyre.co.uk>
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>
---
builtin-branch.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/builtin-branch.c b/builtin-branch.c
index d0179b0..d371849 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")) {
--
1.5.0.2
next prev parent reply other threads:[~2007-03-03 0:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-03 0:31 [PATCH 0/2] git-branch: improve command line handling of --abbrev= Julian Phillips
[not found] ` <028df363480685d1fe1ab84a99b2573dda853440.1172881822.git.julian@quantumfyre.co.uk>
2007-03-03 0:31 ` Julian Phillips [this message]
[not found] ` <4a1baac35d2826499a1fa4c1439b7740be23e7b5.1172881822.git.julian@quantumfyre.co.uk>
2007-03-03 0:31 ` [PATCH 2/2] git-branch: document new --no-abbrev option Julian Phillips
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11728818771064-git-send-email-julian@quantumfyre.co.uk \
--to=julian@quantumfyre.co.uk \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).