git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] git-branch: improve command line handling of --abbrev=
@ 2007-03-03  0:31 Julian Phillips
       [not found] ` <028df363480685d1fe1ab84a99b2573dda853440.1172881822.git.julian@quantumfyre.co.uk>
  0 siblings, 1 reply; 3+ messages in thread
From: Julian Phillips @ 2007-03-03  0:31 UTC (permalink / raw)
  To: git

When playing with git-branch I discovered that it handled the --abbrev= option
differently to other commands, which surprised me.

This update the parsing code in builtin_branch.c to be the same as
setup_revisions in revision.c, and documents the new --no-abbrev option.

-- 
Julian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] git-branch: improve abbreviation of sha1s in verbose mode
       [not found] ` <028df363480685d1fe1ab84a99b2573dda853440.1172881822.git.julian@quantumfyre.co.uk>
@ 2007-03-03  0:31   ` Julian Phillips
       [not found]   ` <4a1baac35d2826499a1fa4c1439b7740be23e7b5.1172881822.git.julian@quantumfyre.co.uk>
  1 sibling, 0 replies; 3+ messages in thread
From: Julian Phillips @ 2007-03-03  0:31 UTC (permalink / raw)
  To: git; +Cc: Julian Phillips

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] git-branch: document new --no-abbrev option
       [not found]   ` <4a1baac35d2826499a1fa4c1439b7740be23e7b5.1172881822.git.julian@quantumfyre.co.uk>
@ 2007-03-03  0:31     ` Julian Phillips
  0 siblings, 0 replies; 3+ messages in thread
From: Julian Phillips @ 2007-03-03  0:31 UTC (permalink / raw)
  To: git; +Cc: Julian Phillips

Add the new --no-abbrev option to the man page for the git-branch command.

Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk>
---
 Documentation/git-branch.txt |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index aa1fdd4..3ea3b80 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -8,7 +8,8 @@ git-branch - List, create, or delete branches
 SYNOPSIS
 --------
 [verse]
-'git-branch' [--color | --no-color] [-r | -a] [-v [--abbrev=<length>]]
+'git-branch' [--color | --no-color] [-r | -a]
+	   [-v [--abbrev=<length> | --no-abbrev]]
 'git-branch' [-l] [-f] <branchname> [<start-point>]
 'git-branch' (-m | -M) [<oldbranch>] <newbranch>
 'git-branch' (-d | -D) [-r] <branchname>...
@@ -80,6 +81,9 @@ OPTIONS
 	Alter minimum display length for sha1 in output listing,
 	default value is 7.
 
+--no-abbrev::
+	Display the full sha1s in output listing rather than abbreviating them.
+
 <branchname>::
 	The name of the branch to create or delete.
 	The new branch name must pass all checks defined by
-- 
1.5.0.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-03-03  0:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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   ` [PATCH 1/2] git-branch: improve abbreviation of sha1s in verbose mode Julian Phillips
     [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

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).