Skip to content

Commit fcedc5a

Browse files
author
Junio C Hamano
committed
Merge branch 'ew/rev-abbrev' into next
* ew/rev-abbrev: rev-list --abbrev-commit
2 parents dd4bca3 + 5c51c98 commit fcedc5a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

rev-list.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ static const char rev_list_usage[] =
3030
" --unpacked\n"
3131
" --header | --pretty\n"
3232
" --abbrev=nr | --no-abbrev\n"
33+
" --abbrev-commit\n"
3334
" special purpose:\n"
3435
" --bisect"
3536
;
@@ -39,6 +40,7 @@ struct rev_info revs;
3940
static int bisect_list = 0;
4041
static int verbose_header = 0;
4142
static int abbrev = DEFAULT_ABBREV;
43+
static int abbrev_commit = 0;
4244
static int show_timestamp = 0;
4345
static int hdr_termination = 0;
4446
static const char *commit_prefix = "";
@@ -52,7 +54,10 @@ static void show_commit(struct commit *commit)
5254
fputs(commit_prefix, stdout);
5355
if (commit->object.flags & BOUNDARY)
5456
putchar('-');
55-
fputs(sha1_to_hex(commit->object.sha1), stdout);
57+
if (abbrev_commit && abbrev)
58+
fputs(find_unique_abbrev(commit->object.sha1, abbrev), stdout);
59+
else
60+
fputs(sha1_to_hex(commit->object.sha1), stdout);
5661
if (revs.parents) {
5762
struct commit_list *parents = commit->parents;
5863
while (parents) {
@@ -319,6 +324,14 @@ int main(int argc, const char **argv)
319324
abbrev = 0;
320325
continue;
321326
}
327+
if (!strcmp(arg, "--abbrev")) {
328+
abbrev = DEFAULT_ABBREV;
329+
continue;
330+
}
331+
if (!strcmp(arg, "--abbrev-commit")) {
332+
abbrev_commit = 1;
333+
continue;
334+
}
322335
if (!strncmp(arg, "--abbrev=", 9)) {
323336
abbrev = strtoul(arg + 9, NULL, 10);
324337
if (abbrev && abbrev < MINIMUM_ABBREV)

0 commit comments

Comments
 (0)