]>
git.ipfire.org Git - thirdparty/git.git/blob - builtin/range-diff.c
94c1f362cc4feec11c2ab622f9399c1dff7e2840
3 #include "parse-options.h"
4 #include "range-diff.h"
6 static const char * const builtin_range_diff_usage
[] = {
7 N_("git range-diff [<options>] <old-base>..<old-tip> <new-base>..<new-tip>"),
8 N_("git range-diff [<options>] <old-tip>...<new-tip>"),
9 N_("git range-diff [<options>] <base> <old-tip> <new-tip>"),
13 int cmd_range_diff(int argc
, const char **argv
, const char *prefix
)
15 int creation_factor
= 60;
16 struct option options
[] = {
17 OPT_INTEGER(0, "creation-factor", &creation_factor
,
18 N_("Percentage by which creation is weighted")),
22 struct strbuf range1
= STRBUF_INIT
, range2
= STRBUF_INIT
;
24 argc
= parse_options(argc
, argv
, NULL
, options
,
25 builtin_range_diff_usage
, 0);
28 if (!strstr(argv
[0], ".."))
29 die(_("no .. in range: '%s'"), argv
[0]);
30 strbuf_addstr(&range1
, argv
[0]);
32 if (!strstr(argv
[1], ".."))
33 die(_("no .. in range: '%s'"), argv
[1]);
34 strbuf_addstr(&range2
, argv
[1]);
35 } else if (argc
== 3) {
36 strbuf_addf(&range1
, "%s..%s", argv
[0], argv
[1]);
37 strbuf_addf(&range2
, "%s..%s", argv
[0], argv
[2]);
38 } else if (argc
== 1) {
39 const char *b
= strstr(argv
[0], "..."), *a
= argv
[0];
43 error(_("single arg format must be symmetric range"));
44 usage_with_options(builtin_range_diff_usage
, options
);
55 strbuf_addf(&range1
, "%s..%.*s", b
, a_len
, a
);
56 strbuf_addf(&range2
, "%.*s..%s", a_len
, a
, b
);
58 error(_("need two commit ranges"));
59 usage_with_options(builtin_range_diff_usage
, options
);
62 res
= show_range_diff(range1
.buf
, range2
.buf
, creation_factor
);
64 strbuf_release(&range1
);
65 strbuf_release(&range2
);