Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-03-25 02:25:39 +0300
committerJunio C Hamano <gitster@pobox.com>2010-03-25 02:25:39 +0300
commit797d44343c831680aeae3392259fcadeb178bf61 (patch)
tree6639bf5dfb12eea0a67bd3b3323e3cabd79bc58e
parent954f7cfdac48b8d9fe91c29ecfa44ac0c639867c (diff)
parent2bf6587349e31b582dae47954b1a334052230e28 (diff)
Merge branch 'pb/log-first-parent-p-m'
* pb/log-first-parent-p-m: show --first-parent/-m: do not default to --cc show -c: show patch text revision: introduce setup_revision_opt t4013: add tests for log -p -m --first-parent git log -p -m: document -m and honor --first-parent
-rw-r--r--Documentation/diff-generate-patch.txt3
-rw-r--r--Documentation/git-log.txt9
-rw-r--r--Documentation/rev-list-options.txt13
-rw-r--r--builtin/diff-tree.c18
-rw-r--r--builtin/log.c49
-rw-r--r--diff-lib.c5
-rw-r--r--log-tree.c10
-rw-r--r--revision.c11
-rw-r--r--revision.h7
-rwxr-xr-xt/t4013-diff-various.sh6
-rw-r--r--t/t4013/diff.log_-m_-p_--first-parent_master100
-rw-r--r--t/t4013/diff.log_-m_-p_master200
-rw-r--r--t/t4013/diff.log_-p_--first-parent_master78
-rw-r--r--t/t4013/diff.show_--first-parent_master30
-rw-r--r--t/t4013/diff.show_-c_master36
-rw-r--r--t/t4013/diff.show_-m_master93
-rw-r--r--wt-status.c15
17 files changed, 653 insertions, 30 deletions
diff --git a/Documentation/diff-generate-patch.txt b/Documentation/diff-generate-patch.txt
index 0f25ba7e38..8f9a2412fd 100644
--- a/Documentation/diff-generate-patch.txt
+++ b/Documentation/diff-generate-patch.txt
@@ -56,7 +56,8 @@ combined diff format
"git-diff-tree", "git-diff-files" and "git-diff" can take '-c' or
'--cc' option to produce 'combined diff'. For showing a merge commit
-with "git log -p", this is the default format.
+with "git log -p", this is the default format; you can force showing
+full diff with the '-m' option.
A 'combined diff' format looks like this:
------------
diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
index 0e39bb61ee..fb184ba186 100644
--- a/Documentation/git-log.txt
+++ b/Documentation/git-log.txt
@@ -118,6 +118,15 @@ git log master --not --remotes=*/master::
Shows all commits that are in local master but not in any remote
repository master branches.
+git log -p -m --first-parent::
+
+ Shows the history including change diffs, but only from the
+ "main branch" perspective, skipping commits that come from merged
+ branches, and showing full diffs of changes introduced by the merges.
+ This makes sense only when following a strict policy of merging all
+ topic branches when staying on a single integration branch.
+
+
Discussion
----------
diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index 81c0e6f184..b9fb7a86bd 100644
--- a/Documentation/rev-list-options.txt
+++ b/Documentation/rev-list-options.txt
@@ -108,8 +108,8 @@ options may be given. See linkgit:git-diff-files[1] for more options.
-c::
- This flag changes the way a merge commit is displayed. It shows
- the differences from each of the parents to the merge result
+ With this option, diff output for a merge commit
+ shows the differences from each of the parents to the merge result
simultaneously instead of showing pairwise diff between a parent
and the result one at a time. Furthermore, it lists only files
which were modified from all parents.
@@ -121,6 +121,15 @@ options may be given. See linkgit:git-diff-files[1] for more options.
the parents have only two variants and the merge result picks
one of them without modification.
+-m::
+
+ This flag makes the merge commits show the full diff like
+ regular commits; for each merge parent, a separate log entry
+ and diff is generated. An exception is that only diff against
+ the first parent is shown when '--first-parent' option is given;
+ in that case, the output represents the changes the merge
+ brought _into_ the then-current branch.
+
-r::
Show recursive diffs.
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index 2380c21951..3c78bda566 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -92,12 +92,23 @@ static const char diff_tree_usage[] =
" --root include the initial commit as diff against /dev/null\n"
COMMON_DIFF_OPTIONS_HELP;
+static void diff_tree_tweak_rev(struct rev_info *rev, struct setup_revision_opt *opt)
+{
+ if (!rev->diffopt.output_format) {
+ if (rev->dense_combined_merges)
+ rev->diffopt.output_format = DIFF_FORMAT_PATCH;
+ else
+ rev->diffopt.output_format = DIFF_FORMAT_RAW;
+ }
+}
+
int cmd_diff_tree(int argc, const char **argv, const char *prefix)
{
int nr_sha1;
char line[1000];
struct object *tree1, *tree2;
static struct rev_info *opt = &log_tree_opt;
+ struct setup_revision_opt s_r_opt;
int read_stdin = 0;
init_revisions(opt, prefix);
@@ -105,7 +116,9 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
opt->abbrev = 0;
opt->diff = 1;
opt->disable_stdin = 1;
- argc = setup_revisions(argc, argv, opt, NULL);
+ memset(&s_r_opt, 0, sizeof(s_r_opt));
+ s_r_opt.tweak = diff_tree_tweak_rev;
+ argc = setup_revisions(argc, argv, opt, &s_r_opt);
while (--argc > 0) {
const char *arg = *++argv;
@@ -117,9 +130,6 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
usage(diff_tree_usage);
}
- if (!opt->diffopt.output_format)
- opt->diffopt.output_format = DIFF_FORMAT_RAW;
-
/*
* NOTE! We expect "a ^b" to be equal to "a..b", so we
* reverse the order of the objects if the second one
diff --git a/builtin/log.c b/builtin/log.c
index 9fbc7ab9ce..fade77200f 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -32,7 +32,7 @@ static const char * const builtin_log_usage =
" or: git show [options] <object>...";
static void cmd_log_init(int argc, const char **argv, const char *prefix,
- struct rev_info *rev)
+ struct rev_info *rev, struct setup_revision_opt *opt)
{
int i;
int decoration_style = 0;
@@ -56,7 +56,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
*/
if (argc == 2 && !strcmp(argv[1], "-h"))
usage(builtin_log_usage);
- argc = setup_revisions(argc, argv, rev, "HEAD");
+ argc = setup_revisions(argc, argv, rev, opt);
if (!rev->show_notes_given && !rev->pretty_given)
rev->show_notes = 1;
@@ -262,6 +262,7 @@ static int git_log_config(const char *var, const char *value, void *cb)
int cmd_whatchanged(int argc, const char **argv, const char *prefix)
{
struct rev_info rev;
+ struct setup_revision_opt opt;
git_config(git_log_config, NULL);
@@ -271,7 +272,9 @@ int cmd_whatchanged(int argc, const char **argv, const char *prefix)
init_revisions(&rev, prefix);
rev.diff = 1;
rev.simplify_history = 0;
- cmd_log_init(argc, argv, prefix, &rev);
+ memset(&opt, 0, sizeof(opt));
+ opt.def = "HEAD";
+ cmd_log_init(argc, argv, prefix, &rev, &opt);
if (!rev.diffopt.output_format)
rev.diffopt.output_format = DIFF_FORMAT_RAW;
return cmd_log_walk(&rev);
@@ -324,10 +327,26 @@ static int show_tree_object(const unsigned char *sha1,
return 0;
}
+static void show_rev_tweak_rev(struct rev_info *rev, struct setup_revision_opt *opt)
+{
+ if (rev->ignore_merges) {
+ /* There was no "-m" on the command line */
+ rev->ignore_merges = 0;
+ if (!rev->first_parent_only && !rev->combine_merges) {
+ /* No "--first-parent", "-c", nor "--cc" */
+ rev->combine_merges = 1;
+ rev->dense_combined_merges = 1;
+ }
+ }
+ if (!rev->diffopt.output_format)
+ rev->diffopt.output_format = DIFF_FORMAT_PATCH;
+}
+
int cmd_show(int argc, const char **argv, const char *prefix)
{
struct rev_info rev;
struct object_array_entry *objects;
+ struct setup_revision_opt opt;
int i, count, ret = 0;
git_config(git_log_config, NULL);
@@ -337,12 +356,12 @@ int cmd_show(int argc, const char **argv, const char *prefix)
init_revisions(&rev, prefix);
rev.diff = 1;
- rev.combine_merges = 1;
- rev.dense_combined_merges = 1;
rev.always_show_header = 1;
- rev.ignore_merges = 0;
rev.no_walk = 1;
- cmd_log_init(argc, argv, prefix, &rev);
+ memset(&opt, 0, sizeof(opt));
+ opt.def = "HEAD";
+ opt.tweak = show_rev_tweak_rev;
+ cmd_log_init(argc, argv, prefix, &rev, &opt);
count = rev.pending.nr;
objects = rev.pending.objects;
@@ -405,6 +424,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
int cmd_log_reflog(int argc, const char **argv, const char *prefix)
{
struct rev_info rev;
+ struct setup_revision_opt opt;
git_config(git_log_config, NULL);
@@ -415,7 +435,9 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
init_reflog_walk(&rev.reflog_info);
rev.abbrev_commit = 1;
rev.verbose_header = 1;
- cmd_log_init(argc, argv, prefix, &rev);
+ memset(&opt, 0, sizeof(opt));
+ opt.def = "HEAD";
+ cmd_log_init(argc, argv, prefix, &rev, &opt);
/*
* This means that we override whatever commit format the user gave
@@ -438,6 +460,7 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
int cmd_log(int argc, const char **argv, const char *prefix)
{
struct rev_info rev;
+ struct setup_revision_opt opt;
git_config(git_log_config, NULL);
@@ -446,7 +469,9 @@ int cmd_log(int argc, const char **argv, const char *prefix)
init_revisions(&rev, prefix);
rev.always_show_header = 1;
- cmd_log_init(argc, argv, prefix, &rev);
+ memset(&opt, 0, sizeof(opt));
+ opt.def = "HEAD";
+ cmd_log_init(argc, argv, prefix, &rev, &opt);
return cmd_log_walk(&rev);
}
@@ -902,6 +927,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
struct commit *commit;
struct commit **list = NULL;
struct rev_info rev;
+ struct setup_revision_opt s_r_opt;
int nr = 0, total, i;
int use_stdout = 0;
int start_number = -1;
@@ -983,8 +1009,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
rev.combine_merges = 0;
rev.ignore_merges = 1;
DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
-
rev.subject_prefix = fmt_patch_subject_prefix;
+ memset(&s_r_opt, 0, sizeof(s_r_opt));
+ s_r_opt.def = "HEAD";
if (default_attach) {
rev.mime_boundary = default_attach;
@@ -1056,7 +1083,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
if (keep_subject && subject_prefix)
die ("--subject-prefix and -k are mutually exclusive.");
- argc = setup_revisions(argc, argv, &rev, "HEAD");
+ argc = setup_revisions(argc, argv, &rev, &s_r_opt);
if (argc > 1)
die ("unrecognized argument: %s", argv[1]);
diff --git a/diff-lib.c b/diff-lib.c
index d7e13cb177..64976f921d 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -510,9 +510,12 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
int index_differs_from(const char *def, int diff_flags)
{
struct rev_info rev;
+ struct setup_revision_opt opt;
init_revisions(&rev, NULL);
- setup_revisions(0, NULL, &rev, def);
+ memset(&opt, 0, sizeof(opt));
+ opt.def = def;
+ setup_revisions(0, NULL, &rev, &opt);
DIFF_OPT_SET(&rev.diffopt, QUICK);
DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);
rev.diffopt.flags |= diff_flags;
diff --git a/log-tree.c b/log-tree.c
index 27afcf6972..d3ae969f60 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -514,6 +514,16 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
return 0;
else if (opt->combine_merges)
return do_diff_combined(opt, commit);
+ else if (opt->first_parent_only) {
+ /*
+ * Generate merge log entry only for the first
+ * parent, showing summary diff of the others
+ * we merged _in_.
+ */
+ diff_tree_sha1(parents->item->object.sha1, sha1, "", &opt->diffopt);
+ log_tree_diff_flush(opt);
+ return !opt->loginfo;
+ }
/* If we show individual diffs, show the parent info */
log->parent = parents->item;
diff --git a/revision.c b/revision.c
index 490b484084..0471cd3f7e 100644
--- a/revision.c
+++ b/revision.c
@@ -1332,7 +1332,7 @@ static void append_prune_data(const char ***prune_data, const char **av)
* Returns the number of arguments left that weren't recognized
* (which are also moved to the head of the argument list)
*/
-int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def)
+int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct setup_revision_opt *opt)
{
int i, flags, left, seen_dashdash, read_from_stdin, got_rev_arg = 0;
const char **prune_data = NULL;
@@ -1468,7 +1468,9 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
revs->prune_data = get_pathspec(revs->prefix, prune_data);
if (revs->def == NULL)
- revs->def = def;
+ revs->def = opt ? opt->def : NULL;
+ if (opt && opt->tweak)
+ opt->tweak(revs, opt);
if (revs->show_merge)
prepare_show_merge(revs);
if (revs->def && !revs->pending.nr && !got_rev_arg) {
@@ -1502,11 +1504,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
if (!revs->full_diff)
diff_tree_setup_paths(revs->prune_data, &revs->diffopt);
}
- if (revs->combine_merges) {
+ if (revs->combine_merges)
revs->ignore_merges = 0;
- if (revs->dense_combined_merges && !revs->diffopt.output_format)
- revs->diffopt.output_format = DIFF_FORMAT_PATCH;
- }
revs->diffopt.abbrev = revs->abbrev;
if (diff_setup_done(&revs->diffopt) < 0)
die("diff_setup_done failed");
diff --git a/revision.h b/revision.h
index a14deefc25..ceae4cae74 100644
--- a/revision.h
+++ b/revision.h
@@ -137,8 +137,13 @@ struct rev_info {
typedef void (*show_early_output_fn_t)(struct rev_info *, struct commit_list *);
extern volatile show_early_output_fn_t show_early_output;
+struct setup_revision_opt {
+ const char *def;
+ void (*tweak)(struct rev_info *, struct setup_revision_opt *);
+};
+
extern void init_revisions(struct rev_info *revs, const char *prefix);
-extern int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def);
+extern int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct setup_revision_opt *);
extern void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
const struct option *options,
const char * const usagestr[]);
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index 8e3694ed5b..dae6358516 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -204,6 +204,9 @@ log --root --patch-with-stat --summary master
log --root -c --patch-with-stat --summary master
# improved by Timo's patch
log --root --cc --patch-with-stat --summary master
+log -p --first-parent master
+log -m -p --first-parent master
+log -m -p master
log -SF master
log -SF -p master
log --decorate --all
@@ -235,6 +238,9 @@ show initial
show --root initial
show side
show master
+show -c master
+show -m master
+show --first-parent master
show --stat side
show --stat --summary side
show --patch-with-stat side
diff --git a/t/t4013/diff.log_-m_-p_--first-parent_master b/t/t4013/diff.log_-m_-p_--first-parent_master
new file mode 100644
index 0000000000..7a0073f529
--- /dev/null
+++ b/t/t4013/diff.log_-m_-p_--first-parent_master
@@ -0,0 +1,100 @@
+$ git log -m -p --first-parent master
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:04:00 2006 +0000
+
+ Merge branch 'side'
+
+diff --git a/dir/sub b/dir/sub
+index cead32e..992913c 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -4,3 +4,5 @@ C
+ D
+ E
+ F
++1
++2
+diff --git a/file0 b/file0
+index b414108..10a8a9f 100644
+--- a/file0
++++ b/file0
+@@ -4,3 +4,6 @@
+ 4
+ 5
+ 6
++A
++B
++C
+
+commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:02:00 2006 +0000
+
+ Third
+
+diff --git a/dir/sub b/dir/sub
+index 8422d40..cead32e 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -2,3 +2,5 @@ A
+ B
+ C
+ D
++E
++F
+diff --git a/file1 b/file1
+new file mode 100644
+index 0000000..b1e6722
+--- /dev/null
++++ b/file1
+@@ -0,0 +1,3 @@
++A
++B
++C
+
+commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:01:00 2006 +0000
+
+ Second
+
+ This is the second commit.
+
+diff --git a/dir/sub b/dir/sub
+index 35d242b..8422d40 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -1,2 +1,4 @@
+ A
+ B
++C
++D
+diff --git a/file0 b/file0
+index 01e79c3..b414108 100644
+--- a/file0
++++ b/file0
+@@ -1,3 +1,6 @@
+ 1
+ 2
+ 3
++4
++5
++6
+diff --git a/file2 b/file2
+deleted file mode 100644
+index 01e79c3..0000000
+--- a/file2
++++ /dev/null
+@@ -1,3 +0,0 @@
+-1
+-2
+-3
+
+commit 444ac553ac7612cc88969031b02b3767fb8a353a
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:00:00 2006 +0000
+
+ Initial
+$
diff --git a/t/t4013/diff.log_-m_-p_master b/t/t4013/diff.log_-m_-p_master
new file mode 100644
index 0000000000..9ca62a01ed
--- /dev/null
+++ b/t/t4013/diff.log_-m_-p_master
@@ -0,0 +1,200 @@
+$ git log -m -p master
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (from 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0)
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:04:00 2006 +0000
+
+ Merge branch 'side'
+
+diff --git a/dir/sub b/dir/sub
+index cead32e..992913c 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -4,3 +4,5 @@ C
+ D
+ E
+ F
++1
++2
+diff --git a/file0 b/file0
+index b414108..10a8a9f 100644
+--- a/file0
++++ b/file0
+@@ -4,3 +4,6 @@
+ 4
+ 5
+ 6
++A
++B
++C
+
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (from c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a)
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:04:00 2006 +0000
+
+ Merge branch 'side'
+
+diff --git a/dir/sub b/dir/sub
+index 7289e35..992913c 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -1,4 +1,8 @@
+ A
+ B
++C
++D
++E
++F
+ 1
+ 2
+diff --git a/file0 b/file0
+index f4615da..10a8a9f 100644
+--- a/file0
++++ b/file0
+@@ -1,6 +1,9 @@
+ 1
+ 2
+ 3
++4
++5
++6
+ A
+ B
+ C
+diff --git a/file1 b/file1
+new file mode 100644
+index 0000000..b1e6722
+--- /dev/null
++++ b/file1
+@@ -0,0 +1,3 @@
++A
++B
++C
+diff --git a/file2 b/file2
+deleted file mode 100644
+index 01e79c3..0000000
+--- a/file2
++++ /dev/null
+@@ -1,3 +0,0 @@
+-1
+-2
+-3
+diff --git a/file3 b/file3
+deleted file mode 100644
+index 7289e35..0000000
+--- a/file3
++++ /dev/null
+@@ -1,4 +0,0 @@
+-A
+-B
+-1
+-2
+
+commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:03:00 2006 +0000
+
+ Side
+
+diff --git a/dir/sub b/dir/sub
+index 35d242b..7289e35 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -1,2 +1,4 @@
+ A
+ B
++1
++2
+diff --git a/file0 b/file0
+index 01e79c3..f4615da 100644
+--- a/file0
++++ b/file0
+@@ -1,3 +1,6 @@
+ 1
+ 2
+ 3
++A
++B
++C
+diff --git a/file3 b/file3
+new file mode 100644
+index 0000000..7289e35
+--- /dev/null
++++ b/file3
+@@ -0,0 +1,4 @@
++A
++B
++1
++2
+
+commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:02:00 2006 +0000
+
+ Third
+
+diff --git a/dir/sub b/dir/sub
+index 8422d40..cead32e 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -2,3 +2,5 @@ A
+ B
+ C
+ D
++E
++F
+diff --git a/file1 b/file1
+new file mode 100644
+index 0000000..b1e6722
+--- /dev/null
++++ b/file1
+@@ -0,0 +1,3 @@
++A
++B
++C
+
+commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:01:00 2006 +0000
+
+ Second
+
+ This is the second commit.
+
+diff --git a/dir/sub b/dir/sub
+index 35d242b..8422d40 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -1,2 +1,4 @@
+ A
+ B
++C
++D
+diff --git a/file0 b/file0
+index 01e79c3..b414108 100644
+--- a/file0
++++ b/file0
+@@ -1,3 +1,6 @@
+ 1
+ 2
+ 3
++4
++5
++6
+diff --git a/file2 b/file2
+deleted file mode 100644
+index 01e79c3..0000000
+--- a/file2
++++ /dev/null
+@@ -1,3 +0,0 @@
+-1
+-2
+-3
+
+commit 444ac553ac7612cc88969031b02b3767fb8a353a
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:00:00 2006 +0000
+
+ Initial
+$
diff --git a/t/t4013/diff.log_-p_--first-parent_master b/t/t4013/diff.log_-p_--first-parent_master
new file mode 100644
index 0000000000..3fc896d424
--- /dev/null
+++ b/t/t4013/diff.log_-p_--first-parent_master
@@ -0,0 +1,78 @@
+$ git log -p --first-parent master
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:04:00 2006 +0000
+
+ Merge branch 'side'
+
+commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:02:00 2006 +0000
+
+ Third
+
+diff --git a/dir/sub b/dir/sub
+index 8422d40..cead32e 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -2,3 +2,5 @@ A
+ B
+ C
+ D
++E
++F
+diff --git a/file1 b/file1
+new file mode 100644
+index 0000000..b1e6722
+--- /dev/null
++++ b/file1
+@@ -0,0 +1,3 @@
++A
++B
++C
+
+commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:01:00 2006 +0000
+
+ Second
+
+ This is the second commit.
+
+diff --git a/dir/sub b/dir/sub
+index 35d242b..8422d40 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -1,2 +1,4 @@
+ A
+ B
++C
++D
+diff --git a/file0 b/file0
+index 01e79c3..b414108 100644
+--- a/file0
++++ b/file0
+@@ -1,3 +1,6 @@
+ 1
+ 2
+ 3
++4
++5
++6
+diff --git a/file2 b/file2
+deleted file mode 100644
+index 01e79c3..0000000
+--- a/file2
++++ /dev/null
+@@ -1,3 +0,0 @@
+-1
+-2
+-3
+
+commit 444ac553ac7612cc88969031b02b3767fb8a353a
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:00:00 2006 +0000
+
+ Initial
+$
diff --git a/t/t4013/diff.show_--first-parent_master b/t/t4013/diff.show_--first-parent_master
new file mode 100644
index 0000000000..3dcbe473a0
--- /dev/null
+++ b/t/t4013/diff.show_--first-parent_master
@@ -0,0 +1,30 @@
+$ git show --first-parent master
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:04:00 2006 +0000
+
+ Merge branch 'side'
+
+diff --git a/dir/sub b/dir/sub
+index cead32e..992913c 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -4,3 +4,5 @@ C
+ D
+ E
+ F
++1
++2
+diff --git a/file0 b/file0
+index b414108..10a8a9f 100644
+--- a/file0
++++ b/file0
+@@ -4,3 +4,6 @@
+ 4
+ 5
+ 6
++A
++B
++C
+$
diff --git a/t/t4013/diff.show_-c_master b/t/t4013/diff.show_-c_master
new file mode 100644
index 0000000000..81aba8da96
--- /dev/null
+++ b/t/t4013/diff.show_-c_master
@@ -0,0 +1,36 @@
+$ git show -c master
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:04:00 2006 +0000
+
+ Merge branch 'side'
+
+diff --combined dir/sub
+index cead32e,7289e35..992913c
+--- a/dir/sub
++++ b/dir/sub
+@@@ -1,6 -1,4 +1,8 @@@
+ A
+ B
+ +C
+ +D
+ +E
+ +F
++ 1
++ 2
+diff --combined file0
+index b414108,f4615da..10a8a9f
+--- a/file0
++++ b/file0
+@@@ -1,6 -1,6 +1,9 @@@
+ 1
+ 2
+ 3
+ +4
+ +5
+ +6
++ A
++ B
++ C
+$
diff --git a/t/t4013/diff.show_-m_master b/t/t4013/diff.show_-m_master
new file mode 100644
index 0000000000..4ea2ee453d
--- /dev/null
+++ b/t/t4013/diff.show_-m_master
@@ -0,0 +1,93 @@
+$ git show -m master
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (from 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0)
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:04:00 2006 +0000
+
+ Merge branch 'side'
+
+diff --git a/dir/sub b/dir/sub
+index cead32e..992913c 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -4,3 +4,5 @@ C
+ D
+ E
+ F
++1
++2
+diff --git a/file0 b/file0
+index b414108..10a8a9f 100644
+--- a/file0
++++ b/file0
+@@ -4,3 +4,6 @@
+ 4
+ 5
+ 6
++A
++B
++C
+
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (from c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a)
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:04:00 2006 +0000
+
+ Merge branch 'side'
+
+diff --git a/dir/sub b/dir/sub
+index 7289e35..992913c 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -1,4 +1,8 @@
+ A
+ B
++C
++D
++E
++F
+ 1
+ 2
+diff --git a/file0 b/file0
+index f4615da..10a8a9f 100644
+--- a/file0
++++ b/file0
+@@ -1,6 +1,9 @@
+ 1
+ 2
+ 3
++4
++5
++6
+ A
+ B
+ C
+diff --git a/file1 b/file1
+new file mode 100644
+index 0000000..b1e6722
+--- /dev/null
++++ b/file1
+@@ -0,0 +1,3 @@
++A
++B
++C
+diff --git a/file2 b/file2
+deleted file mode 100644
+index 01e79c3..0000000
+--- a/file2
++++ /dev/null
+@@ -1,3 +0,0 @@
+-1
+-2
+-3
+diff --git a/file3 b/file3
+deleted file mode 100644
+index 7289e35..0000000
+--- a/file3
++++ /dev/null
+@@ -1,4 +0,0 @@
+-A
+-B
+-1
+-2
+$
diff --git a/wt-status.c b/wt-status.c
index 5807fc3211..dcaec7f09e 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -290,10 +290,13 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)
static void wt_status_collect_changes_index(struct wt_status *s)
{
struct rev_info rev;
+ struct setup_revision_opt opt;
init_revisions(&rev, NULL);
- setup_revisions(0, NULL, &rev,
- s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference);
+ memset(&opt, 0, sizeof(opt));
+ opt.def = s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference;
+ setup_revisions(0, NULL, &rev, &opt);
+
rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
rev.diffopt.format_callback = wt_status_collect_updated_cb;
rev.diffopt.format_callback_data = s;
@@ -512,11 +515,15 @@ static void wt_status_print_untracked(struct wt_status *s)
static void wt_status_print_verbose(struct wt_status *s)
{
struct rev_info rev;
+ struct setup_revision_opt opt;
init_revisions(&rev, NULL);
DIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);
- setup_revisions(0, NULL, &rev,
- s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference);
+
+ memset(&opt, 0, sizeof(opt));
+ opt.def = s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference;
+ setup_revisions(0, NULL, &rev, &opt);
+
rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
rev.diffopt.detect_rename = 1;
rev.diffopt.file = s->fp;