@@ -35,7 +35,8 @@ struct patch_util {
3535 * as struct object_id (will need to be free()d).
3636 */
3737static int read_patches (const char * range , struct string_list * list ,
38- const struct strvec * other_arg )
38+ const struct strvec * other_arg ,
39+ unsigned int include_merges )
3940{
4041 struct child_process cp = CHILD_PROCESS_INIT ;
4142 struct strbuf buf = STRBUF_INIT , contents = STRBUF_INIT ;
@@ -46,7 +47,7 @@ static int read_patches(const char *range, struct string_list *list,
4647 size_t size ;
4748 int ret = -1 ;
4849
49- strvec_pushl (& cp .args , "log" , "--no-color" , "-p" , "--no-merges" ,
50+ strvec_pushl (& cp .args , "log" , "--no-color" , "-p" ,
5051 "--reverse" , "--date-order" , "--decorate=no" ,
5152 "--no-prefix" , "--submodule=short" ,
5253 /*
@@ -61,6 +62,8 @@ static int read_patches(const char *range, struct string_list *list,
6162 "--pretty=medium" ,
6263 "--notes" ,
6364 NULL );
65+ if (!include_merges )
66+ strvec_push (& cp .args , "--no-merges" );
6467 strvec_push (& cp .args , range );
6568 if (other_arg )
6669 strvec_pushv (& cp .args , other_arg -> v );
@@ -93,11 +96,14 @@ static int read_patches(const char *range, struct string_list *list,
9396 }
9497
9598 if (skip_prefix (line , "commit " , & p )) {
99+ char * q ;
96100 if (util ) {
97101 string_list_append (list , buf .buf )-> util = util ;
98102 strbuf_reset (& buf );
99103 }
100104 CALLOC_ARRAY (util , 1 );
105+ if (include_merges && (q = strstr (p , " (from " )))
106+ * q = '\0' ;
101107 if (repo_get_oid (the_repository , p , & util -> oid )) {
102108 error (_ ("could not parse commit '%s'" ), p );
103109 FREE_AND_NULL (util );
@@ -563,13 +569,14 @@ int show_range_diff(const char *range1, const char *range2,
563569
564570 struct string_list branch1 = STRING_LIST_INIT_DUP ;
565571 struct string_list branch2 = STRING_LIST_INIT_DUP ;
572+ unsigned int include_merges = range_diff_opts -> include_merges ;
566573
567574 if (range_diff_opts -> left_only && range_diff_opts -> right_only )
568575 res = error (_ ("options '%s' and '%s' cannot be used together" ), "--left-only" , "--right-only" );
569576
570- if (!res && read_patches (range1 , & branch1 , range_diff_opts -> other_arg ))
577+ if (!res && read_patches (range1 , & branch1 , range_diff_opts -> other_arg , include_merges ))
571578 res = error (_ ("could not parse log for '%s'" ), range1 );
572- if (!res && read_patches (range2 , & branch2 , range_diff_opts -> other_arg ))
579+ if (!res && read_patches (range2 , & branch2 , range_diff_opts -> other_arg , include_merges ))
573580 res = error (_ ("could not parse log for '%s'" ), range2 );
574581
575582 if (!res ) {
0 commit comments