From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.3 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 46E7D200B9 for ; Fri, 4 May 2018 15:34:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751393AbeEDPes (ORCPT ); Fri, 4 May 2018 11:34:48 -0400 Received: from mout.gmx.net ([212.227.17.20]:33979 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751343AbeEDPep (ORCPT ); Fri, 4 May 2018 11:34:45 -0400 Received: from virtualbox.mshome.net ([37.201.195.116]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MbaS9-1ew7sF1hEz-00IzN2; Fri, 04 May 2018 17:34:36 +0200 From: Johannes Schindelin To: git@vger.kernel.org Cc: Johannes Schindelin , Junio C Hamano , Thomas Rast , Thomas Gummerer , =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= , Ramsay Jones , Stefan Beller , Jacob Keller , Eric Sunshine Subject: [PATCH v2 02/18] Add a new builtin: branch-diff Date: Fri, 4 May 2018 17:34:32 +0200 Message-Id: X-Mailer: git-send-email 2.17.0.409.g71698f11835 In-Reply-To: References: Fcc: Sent Content-Type: text/plain; charset=UTF-8 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:SqQzQL05axMvQKhIB0vCA0uoFnoZma/ttL2dVr7reH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Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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 well as the --no-patches option, as they will all be implemented later using diff_options. Signed-off-by: Johannes Schindelin --- .gitignore | 1 + Makefile | 1 + builtin.h | 1 + builtin/branch-diff.c | 38 ++++++++++++++++++++++++++++++++++++++ command-list.txt | 1 + git.c | 1 + 6 files changed, 43 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..60a4b4fbe30 --- /dev/null +++ b/builtin/branch-diff.c @@ -0,0 +1,38 @@ +#include "cache.h" +#include "builtin.h" +#include "parse-options.h" + +static const char * const builtin_branch_diff_usage[] = { +N_("git branch-diff [] .. .."), +N_("git branch-diff [] ..."), +N_("git branch-diff [] "), +NULL +}; + +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) +{ + double creation_weight = 0.6; + struct option options[] = { + { 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..d01b9063e81 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 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.409.g71698f11835