summaryrefslogtreecommitdiff
path: root/range-diff.c
diff options
context:
space:
mode:
Diffstat (limited to 'range-diff.c')
-rw-r--r--range-diff.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/range-diff.c b/range-diff.c
index 10885ba301..8a2dcbee32 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "environment.h"
@@ -38,7 +39,8 @@ struct patch_util {
* as struct object_id (will need to be free()d).
*/
static int read_patches(const char *range, struct string_list *list,
- const struct strvec *other_arg)
+ const struct strvec *other_arg,
+ unsigned int include_merges)
{
struct child_process cp = CHILD_PROCESS_INIT;
struct strbuf buf = STRBUF_INIT, contents = STRBUF_INIT;
@@ -49,7 +51,7 @@ static int read_patches(const char *range, struct string_list *list,
size_t size;
int ret = -1;
- strvec_pushl(&cp.args, "log", "--no-color", "-p", "--no-merges",
+ strvec_pushl(&cp.args, "log", "--no-color", "-p",
"--reverse", "--date-order", "--decorate=no",
"--no-prefix", "--submodule=short",
/*
@@ -64,6 +66,8 @@ static int read_patches(const char *range, struct string_list *list,
"--pretty=medium",
"--show-notes-by-default",
NULL);
+ if (!include_merges)
+ strvec_push(&cp.args, "--no-merges");
strvec_push(&cp.args, range);
if (other_arg)
strvec_pushv(&cp.args, other_arg->v);
@@ -96,11 +100,14 @@ static int read_patches(const char *range, struct string_list *list,
}
if (skip_prefix(line, "commit ", &p)) {
+ char *q;
if (util) {
string_list_append(list, buf.buf)->util = util;
strbuf_reset(&buf);
}
CALLOC_ARRAY(util, 1);
+ if (include_merges && (q = strstr(p, " (from ")))
+ *q = '\0';
if (repo_get_oid(the_repository, p, &util->oid)) {
error(_("could not parse commit '%s'"), p);
FREE_AND_NULL(util);
@@ -460,7 +467,7 @@ static struct diff_filespec *get_filespec(const char *name, const char *p)
{
struct diff_filespec *spec = alloc_filespec(name);
- fill_filespec(spec, null_oid(), 0, 0100644);
+ fill_filespec(spec, null_oid(the_hash_algo), 0, 0100644);
spec->data = (char *)p;
spec->size = strlen(p);
spec->should_munmap = 0;
@@ -571,13 +578,14 @@ int show_range_diff(const char *range1, const char *range2,
struct string_list branch1 = STRING_LIST_INIT_DUP;
struct string_list branch2 = STRING_LIST_INIT_DUP;
+ unsigned int include_merges = range_diff_opts->include_merges;
if (range_diff_opts->left_only && range_diff_opts->right_only)
res = error(_("options '%s' and '%s' cannot be used together"), "--left-only", "--right-only");
- if (!res && read_patches(range1, &branch1, range_diff_opts->other_arg))
+ if (!res && read_patches(range1, &branch1, range_diff_opts->other_arg, include_merges))
res = error(_("could not parse log for '%s'"), range1);
- if (!res && read_patches(range2, &branch2, range_diff_opts->other_arg))
+ if (!res && read_patches(range2, &branch2, range_diff_opts->other_arg, include_merges))
res = error(_("could not parse log for '%s'"), range2);
if (!res) {