@@ -283,6 +283,7 @@ static int cmd_log(int argc, const char **argv, char **envp)
283283 char * buf = xmalloc (LOGSIZE );
284284 static enum cmit_fmt commit_format = CMIT_FMT_DEFAULT ;
285285 int abbrev = DEFAULT_ABBREV ;
286+ int abbrev_commit = 0 ;
286287 const char * commit_prefix = "commit " ;
287288
288289 argc = setup_revisions (argc , argv , & rev , "HEAD" );
@@ -296,6 +297,12 @@ static int cmd_log(int argc, const char **argv, char **envp)
296297 else if (!strcmp (arg , "--no-abbrev" )) {
297298 abbrev = 0 ;
298299 }
300+ else if (!strcmp (arg , "--abbrev" )) {
301+ abbrev = DEFAULT_ABBREV ;
302+ }
303+ else if (!strcmp (arg , "--abbrev-commit" )) {
304+ abbrev_commit = 1 ;
305+ }
299306 else if (!strncmp (arg , "--abbrev=" , 9 )) {
300307 abbrev = strtoul (arg + 9 , NULL , 10 );
301308 if (abbrev && abbrev < MINIMUM_ABBREV )
@@ -311,8 +318,12 @@ static int cmd_log(int argc, const char **argv, char **envp)
311318 prepare_revision_walk (& rev );
312319 setup_pager ();
313320 while ((commit = get_revision (& rev )) != NULL ) {
314- printf ("%s%s" , commit_prefix ,
315- sha1_to_hex (commit -> object .sha1 ));
321+ fputs (commit_prefix , stdout );
322+ if (abbrev_commit && abbrev )
323+ fputs (find_unique_abbrev (commit -> object .sha1 , abbrev ),
324+ stdout );
325+ else
326+ fputs (sha1_to_hex (commit -> object .sha1 ), stdout );
316327 if (rev .parents ) {
317328 struct commit_list * parents = commit -> parents ;
318329 while (parents ) {
0 commit comments