Skip to content

Commit 348ae56

Browse files
dschogitster
authored andcommitted
Introduce range-diff to compare iterations of a topic branch
This command 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 `range-branch` into a full-blown replacement for `tbdiff`. At this point, we ignore tbdiff's color options, as they will all be implemented later using diff_options. Since f318d73 (generate-cmds.sh: export all commands to command-list.h, 2018-05-10), every new command *requires* a man page to build right away, so let's also add a blank man page, too. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 22d8733 commit 348ae56

File tree

7 files changed

+40
-0
lines changed

7 files changed

+40
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
/git-pull
114114
/git-push
115115
/git-quiltimport
116+
/git-range-diff
116117
/git-read-tree
117118
/git-rebase
118119
/git-rebase--am

Documentation/git-range-diff.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
git-range-diff(1)
2+
=================
3+
4+
NAME
5+
----
6+
git-range-diff - Compare two commit ranges (e.g. two versions of a branch)
7+
8+
GIT
9+
---
10+
Part of the linkgit:git[1] suite

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,7 @@ BUILTIN_OBJS += builtin/prune-packed.o
10631063
BUILTIN_OBJS += builtin/prune.o
10641064
BUILTIN_OBJS += builtin/pull.o
10651065
BUILTIN_OBJS += builtin/push.o
1066+
BUILTIN_OBJS += builtin/range-diff.o
10661067
BUILTIN_OBJS += builtin/read-tree.o
10671068
BUILTIN_OBJS += builtin/rebase--helper.o
10681069
BUILTIN_OBJS += builtin/receive-pack.o

builtin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ extern int cmd_prune(int argc, const char **argv, const char *prefix);
201201
extern int cmd_prune_packed(int argc, const char **argv, const char *prefix);
202202
extern int cmd_pull(int argc, const char **argv, const char *prefix);
203203
extern int cmd_push(int argc, const char **argv, const char *prefix);
204+
extern int cmd_range_diff(int argc, const char **argv, const char *prefix);
204205
extern int cmd_read_tree(int argc, const char **argv, const char *prefix);
205206
extern int cmd_rebase__helper(int argc, const char **argv, const char *prefix);
206207
extern int cmd_receive_pack(int argc, const char **argv, const char *prefix);

builtin/range-diff.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "cache.h"
2+
#include "builtin.h"
3+
#include "parse-options.h"
4+
5+
static const char * const builtin_range_diff_usage[] = {
6+
N_("git range-diff [<options>] <old-base>..<old-tip> <new-base>..<new-tip>"),
7+
N_("git range-diff [<options>] <old-tip>...<new-tip>"),
8+
N_("git range-diff [<options>] <base> <old-tip> <new-tip>"),
9+
NULL
10+
};
11+
12+
int cmd_range_diff(int argc, const char **argv, const char *prefix)
13+
{
14+
int creation_factor = 60;
15+
struct option options[] = {
16+
OPT_INTEGER(0, "creation-factor", &creation_factor,
17+
N_("Percentage by which creation is weighted")),
18+
OPT_END()
19+
};
20+
21+
argc = parse_options(argc, argv, NULL, options,
22+
builtin_range_diff_usage, 0);
23+
24+
return 0;
25+
}

command-list.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ git-prune-packed plumbingmanipulators
139139
git-pull mainporcelain remote
140140
git-push mainporcelain remote
141141
git-quiltimport foreignscminterface
142+
git-range-diff mainporcelain
142143
git-read-tree plumbingmanipulators
143144
git-rebase mainporcelain history
144145
git-receive-pack synchelpers

git.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ static struct cmd_struct commands[] = {
520520
{ "prune-packed", cmd_prune_packed, RUN_SETUP },
521521
{ "pull", cmd_pull, RUN_SETUP | NEED_WORK_TREE },
522522
{ "push", cmd_push, RUN_SETUP },
523+
{ "range-diff", cmd_range_diff, RUN_SETUP | USE_PAGER },
523524
{ "read-tree", cmd_read_tree, RUN_SETUP | SUPPORT_SUPER_PREFIX},
524525
{ "rebase--helper", cmd_rebase__helper, RUN_SETUP | NEED_WORK_TREE },
525526
{ "receive-pack", cmd_receive_pack },

0 commit comments

Comments
 (0)