This builtin does not do a whole lot so far, apart from showing a usage that is oddly similar to that of `git tbdiff`. And for a good reason: the next commits will turn `branch-diff` into a full-blown replacement for `tbdiff`. At this point, we ignore tbdiff's color options, as they will all be implemented later and require some patches to the diff machinery. Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx> --- .gitignore | 1 + Makefile | 1 + builtin.h | 1 + builtin/branch-diff.c | 40 ++++++++++++++++++++++++++++++++++++++++ command-list.txt | 1 + git.c | 1 + 6 files changed, 45 insertions(+) create mode 100644 builtin/branch-diff.c diff --git a/.gitignore b/.gitignore index 833ef3b0b78..1346a64492f 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ /git-bisect--helper /git-blame /git-branch +/git-branch-diff /git-bundle /git-cat-file /git-check-attr diff --git a/Makefile b/Makefile index 96f2e76a904..9b1984776d8 100644 --- a/Makefile +++ b/Makefile @@ -953,6 +953,7 @@ BUILTIN_OBJS += builtin/archive.o BUILTIN_OBJS += builtin/bisect--helper.o BUILTIN_OBJS += builtin/blame.o BUILTIN_OBJS += builtin/branch.o +BUILTIN_OBJS += builtin/branch-diff.o BUILTIN_OBJS += builtin/bundle.o BUILTIN_OBJS += builtin/cat-file.o BUILTIN_OBJS += builtin/check-attr.o diff --git a/builtin.h b/builtin.h index 42378f3aa47..e1c4d2a529a 100644 --- a/builtin.h +++ b/builtin.h @@ -135,6 +135,7 @@ extern int cmd_archive(int argc, const char **argv, const char *prefix); extern int cmd_bisect__helper(int argc, const char **argv, const char *prefix); extern int cmd_blame(int argc, const char **argv, const char *prefix); extern int cmd_branch(int argc, const char **argv, const char *prefix); +extern int cmd_branch_diff(int argc, const char **argv, const char *prefix); extern int cmd_bundle(int argc, const char **argv, const char *prefix); extern int cmd_cat_file(int argc, const char **argv, const char *prefix); extern int cmd_checkout(int argc, const char **argv, const char *prefix); diff --git a/builtin/branch-diff.c b/builtin/branch-diff.c new file mode 100644 index 00000000000..97266cd326d --- /dev/null +++ b/builtin/branch-diff.c @@ -0,0 +1,40 @@ +#include "cache.h" +#include "parse-options.h" + +static const char * const builtin_branch_diff_usage[] = { + N_("git rebase--helper [<options>] ( A..B C..D | A...B | base A B )"), + NULL +}; + +#define COLOR_DUAL_MODE 2 + +static int parse_creation_weight(const struct option *opt, const char *arg, + int unset) +{ + double *d = opt->value; + if (unset) + *d = 0.6; + else + *d = atof(arg); + return 0; +} + +int cmd_branch_diff(int argc, const char **argv, const char *prefix) +{ + int no_patches = 0; + double creation_weight = 0.6; + struct option options[] = { + OPT_BOOL(0, "no-patches", &no_patches, + N_("short format (no diffs)")), + { OPTION_CALLBACK, + 0, "creation-weight", &creation_weight, N_("factor"), + N_("Fudge factor by which creation is weighted [0.6]"), + 0, parse_creation_weight }, + OPT_END() + }; + + argc = parse_options(argc, argv, NULL, options, + builtin_branch_diff_usage, 0); + + return 0; +} diff --git a/command-list.txt b/command-list.txt index a1fad28fd82..c89ac8f417f 100644 --- a/command-list.txt +++ b/command-list.txt @@ -19,6 +19,7 @@ git-archive mainporcelain git-bisect mainporcelain info git-blame ancillaryinterrogators git-branch mainporcelain history +git-branch-diff mainporcelain info git-bundle mainporcelain git-cat-file plumbinginterrogators git-check-attr purehelpers diff --git a/git.c b/git.c index f598fae7b7a..d2794fb6f5d 100644 --- a/git.c +++ b/git.c @@ -377,6 +377,7 @@ static struct cmd_struct commands[] = { { "bisect--helper", cmd_bisect__helper, RUN_SETUP }, { "blame", cmd_blame, RUN_SETUP }, { "branch", cmd_branch, RUN_SETUP | DELAY_PAGER_CONFIG }, + { "branch-diff", cmd_branch_diff, RUN_SETUP | USE_PAGER }, { "bundle", cmd_bundle, RUN_SETUP_GENTLY | NO_PARSEOPT }, { "cat-file", cmd_cat_file, RUN_SETUP }, { "check-attr", cmd_check_attr, RUN_SETUP }, -- 2.17.0.395.g6a618d6010f.dirty