summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 46a6c26)
raw | patch | inline | side by side (parent: 46a6c26)
author | Junio C Hamano <junkio@cox.net> | |
Wed, 25 Jan 2006 09:35:38 +0000 (01:35 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 28 Jan 2006 08:09:38 +0000 (00:09 -0800) |
The new option behaves just like --verify, but outputs an
abbreviated object name that is unique within the repository.
Signed-off-by: Junio C Hamano <junkio@cox.net>
abbreviated object name that is unique within the repository.
Signed-off-by: Junio C Hamano <junkio@cox.net>
rev-parse.c | patch | blob | history |
diff --git a/rev-parse.c b/rev-parse.c
index 7abad35de90b190c5d5e5456661853cf8167954a..42969a6fc1b7591b13a2fc664421e4f1da465cdb 100644 (file)
--- a/rev-parse.c
+++ b/rev-parse.c
#define REVERSED 1
static int show_type = NORMAL;
static int symbolic = 0;
+static int abbrev = 0;
static int output_sq = 0;
static int revs_count = 0;
putchar('^');
if (symbolic && name)
show(name);
+ else if (abbrev)
+ show(find_unique_abbrev(sha1, abbrev));
else
show(sha1_to_hex(sha1));
}
verify = 1;
continue;
}
+ if (!strcmp(arg, "--abbrev") ||
+ !strncmp(arg, "--abbrev=", 9)) {
+ filter &= ~(DO_FLAGS|DO_NOREV);
+ verify = 1;
+ abbrev = DEFAULT_ABBREV;
+ if (arg[8] == '=')
+ abbrev = strtoul(arg + 9, NULL, 10);
+ if (abbrev < 0 || 40 <= abbrev)
+ abbrev = DEFAULT_ABBREV;
+ continue;
+ }
if (!strcmp(arg, "--sq")) {
output_sq = 1;
continue;