@@ -39,7 +39,8 @@ struct patch_util {
3939 * as struct object_id (will need to be free()d).
4040 */
4141static int read_patches (const char * range , struct string_list * list ,
42- const struct strvec * other_arg )
42+ const struct strvec * other_arg ,
43+ unsigned int include_merges )
4344{
4445 struct child_process cp = CHILD_PROCESS_INIT ;
4546 struct strbuf buf = STRBUF_INIT , contents = STRBUF_INIT ;
@@ -50,7 +51,7 @@ static int read_patches(const char *range, struct string_list *list,
5051 size_t size ;
5152 int ret = -1 ;
5253
53- strvec_pushl (& cp .args , "log" , "--no-color" , "-p" , "--no-merges" ,
54+ strvec_pushl (& cp .args , "log" , "--no-color" , "-p" ,
5455 "--reverse" , "--date-order" , "--decorate=no" ,
5556 "--no-prefix" , "--submodule=short" ,
5657 /*
@@ -65,6 +66,8 @@ static int read_patches(const char *range, struct string_list *list,
6566 "--pretty=medium" ,
6667 "--show-notes-by-default" ,
6768 NULL );
69+ if (!include_merges )
70+ strvec_push (& cp .args , "--no-merges" );
6871 strvec_push (& cp .args , range );
6972 if (other_arg )
7073 strvec_pushv (& cp .args , other_arg -> v );
@@ -97,11 +100,14 @@ static int read_patches(const char *range, struct string_list *list,
97100 }
98101
99102 if (skip_prefix (line , "commit " , & p )) {
103+ char * q ;
100104 if (util ) {
101105 string_list_append (list , buf .buf )-> util = util ;
102106 strbuf_reset (& buf );
103107 }
104108 CALLOC_ARRAY (util , 1 );
109+ if (include_merges && (q = strstr (p , " (from " )))
110+ * q = '\0' ;
105111 if (repo_get_oid (the_repository , p , & util -> oid )) {
106112 error (_ ("could not parse commit '%s'" ), p );
107113 FREE_AND_NULL (util );
@@ -572,13 +578,14 @@ int show_range_diff(const char *range1, const char *range2,
572578
573579 struct string_list branch1 = STRING_LIST_INIT_DUP ;
574580 struct string_list branch2 = STRING_LIST_INIT_DUP ;
581+ unsigned int include_merges = range_diff_opts -> include_merges ;
575582
576583 if (range_diff_opts -> left_only && range_diff_opts -> right_only )
577584 res = error (_ ("options '%s' and '%s' cannot be used together" ), "--left-only" , "--right-only" );
578585
579- if (!res && read_patches (range1 , & branch1 , range_diff_opts -> other_arg ))
586+ if (!res && read_patches (range1 , & branch1 , range_diff_opts -> other_arg , include_merges ))
580587 res = error (_ ("could not parse log for '%s'" ), range1 );
581- if (!res && read_patches (range2 , & branch2 , range_diff_opts -> other_arg ))
588+ if (!res && read_patches (range2 , & branch2 , range_diff_opts -> other_arg , include_merges ))
582589 res = error (_ ("could not parse log for '%s'" ), range2 );
583590
584591 if (!res ) {
0 commit comments