@matheusbsbs / matheus-bagliano / commits / 5c51c98502
Fork 0

rev-list --abbrev-commit

This should make --pretty=oneline a whole lot more readable for people using 80-column terminals. Originally from Eric Wong. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Apr 6, 2006 at 21:32 UTC 5c51c98502bc885f6eda5046de00cdb3c976cad6
1 file changed +14 -1
rev-list.c
+14 -1
@@ -30,6 +30,7 @@ static const char rev_list_usage[] =
30 " --unpacked\n"
31 " --header | --pretty\n"
32 " --abbrev=nr | --no-abbrev\n"
33 +" --abbrev-commit\n"
34 " special purpose:\n"
35 " --bisect"
36 ;
@@ -39,6 +40,7 @@ struct rev_info revs;
40 static int bisect_list = 0;
41 static int verbose_header = 0;
42 static int abbrev = DEFAULT_ABBREV;
43 +static int abbrev_commit = 0;
44 static int show_timestamp = 0;
45 static int hdr_termination = 0;
46 static const char *commit_prefix = "";
@@ -52,7 +54,10 @@ static void show_commit(struct commit *commit)
54 fputs(commit_prefix, stdout);
55 if (commit->object.flags & BOUNDARY)
56 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);
61 if (revs.parents) {
62 struct commit_list *parents = commit->parents;
63 while (parents) {
@@ -319,6 +324,14 @@ int main(int argc, const char **argv)
324 abbrev = 0;
325 continue;
326 }
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 + }
335 if (!strncmp(arg, "--abbrev=", 9)) {
336 abbrev = strtoul(arg + 9, NULL, 10);
337 if (abbrev && abbrev < MINIMUM_ABBREV)