@@ -39,7 +39,8 @@ struct patch_util {
39
39
* as struct object_id (will need to be free()d).
40
40
*/
41
41
static 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 )
43
44
{
44
45
struct child_process cp = CHILD_PROCESS_INIT ;
45
46
struct strbuf buf = STRBUF_INIT , contents = STRBUF_INIT ;
@@ -50,7 +51,7 @@ static int read_patches(const char *range, struct string_list *list,
50
51
size_t size ;
51
52
int ret = -1 ;
52
53
53
- strvec_pushl (& cp .args , "log" , "--no-color" , "-p" , "--no-merges" ,
54
+ strvec_pushl (& cp .args , "log" , "--no-color" , "-p" ,
54
55
"--reverse" , "--date-order" , "--decorate=no" ,
55
56
"--no-prefix" , "--submodule=short" ,
56
57
/*
@@ -65,6 +66,8 @@ static int read_patches(const char *range, struct string_list *list,
65
66
"--pretty=medium" ,
66
67
"--show-notes-by-default" ,
67
68
NULL );
69
+ if (!include_merges )
70
+ strvec_push (& cp .args , "--no-merges" );
68
71
strvec_push (& cp .args , range );
69
72
if (other_arg )
70
73
strvec_pushv (& cp .args , other_arg -> v );
@@ -97,11 +100,14 @@ static int read_patches(const char *range, struct string_list *list,
97
100
}
98
101
99
102
if (skip_prefix (line , "commit " , & p )) {
103
+ char * q ;
100
104
if (util ) {
101
105
string_list_append (list , buf .buf )-> util = util ;
102
106
strbuf_reset (& buf );
103
107
}
104
108
CALLOC_ARRAY (util , 1 );
109
+ if (include_merges && (q = strstr (p , " (from " )))
110
+ * q = '\0' ;
105
111
if (repo_get_oid (the_repository , p , & util -> oid )) {
106
112
error (_ ("could not parse commit '%s'" ), p );
107
113
FREE_AND_NULL (util );
@@ -572,13 +578,14 @@ int show_range_diff(const char *range1, const char *range2,
572
578
573
579
struct string_list branch1 = STRING_LIST_INIT_DUP ;
574
580
struct string_list branch2 = STRING_LIST_INIT_DUP ;
581
+ unsigned int include_merges = range_diff_opts -> include_merges ;
575
582
576
583
if (range_diff_opts -> left_only && range_diff_opts -> right_only )
577
584
res = error (_ ("options '%s' and '%s' cannot be used together" ), "--left-only" , "--right-only" );
578
585
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 ))
580
587
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 ))
582
589
res = error (_ ("could not parse log for '%s'" ), range2 );
583
590
584
591
if (!res ) {
0 commit comments