@@ -35,7 +35,8 @@ struct patch_util {
35
35
* as struct object_id (will need to be free()d).
36
36
*/
37
37
static 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 )
39
40
{
40
41
struct child_process cp = CHILD_PROCESS_INIT ;
41
42
struct strbuf buf = STRBUF_INIT , contents = STRBUF_INIT ;
@@ -46,7 +47,7 @@ static int read_patches(const char *range, struct string_list *list,
46
47
size_t size ;
47
48
int ret = -1 ;
48
49
49
- strvec_pushl (& cp .args , "log" , "--no-color" , "-p" , "--no-merges" ,
50
+ strvec_pushl (& cp .args , "log" , "--no-color" , "-p" ,
50
51
"--reverse" , "--date-order" , "--decorate=no" ,
51
52
"--no-prefix" , "--submodule=short" ,
52
53
/*
@@ -61,6 +62,8 @@ static int read_patches(const char *range, struct string_list *list,
61
62
"--pretty=medium" ,
62
63
"--notes" ,
63
64
NULL );
65
+ if (!include_merges )
66
+ strvec_push (& cp .args , "--no-merges" );
64
67
strvec_push (& cp .args , range );
65
68
if (other_arg )
66
69
strvec_pushv (& cp .args , other_arg -> v );
@@ -93,11 +96,14 @@ static int read_patches(const char *range, struct string_list *list,
93
96
}
94
97
95
98
if (skip_prefix (line , "commit " , & p )) {
99
+ char * q ;
96
100
if (util ) {
97
101
string_list_append (list , buf .buf )-> util = util ;
98
102
strbuf_reset (& buf );
99
103
}
100
104
CALLOC_ARRAY (util , 1 );
105
+ if (include_merges && (q = strstr (p , " (from " )))
106
+ * q = '\0' ;
101
107
if (repo_get_oid (the_repository , p , & util -> oid )) {
102
108
error (_ ("could not parse commit '%s'" ), p );
103
109
FREE_AND_NULL (util );
@@ -563,13 +569,14 @@ int show_range_diff(const char *range1, const char *range2,
563
569
564
570
struct string_list branch1 = STRING_LIST_INIT_DUP ;
565
571
struct string_list branch2 = STRING_LIST_INIT_DUP ;
572
+ unsigned int include_merges = range_diff_opts -> include_merges ;
566
573
567
574
if (range_diff_opts -> left_only && range_diff_opts -> right_only )
568
575
res = error (_ ("options '%s' and '%s' cannot be used together" ), "--left-only" , "--right-only" );
569
576
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 ))
571
578
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 ))
573
580
res = error (_ ("could not parse log for '%s'" ), range2 );
574
581
575
582
if (!res ) {
0 commit comments