summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: af3feef)
raw | patch | inline | side by side (parent: af3feef)
author | Junio C Hamano <junkio@cox.net> | |
Tue, 24 Jan 2006 09:22:04 +0000 (01:22 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 28 Jan 2006 08:08:28 +0000 (00:08 -0800) |
Building on the previous '-c' (combined) option, '--cc' option
squelches the output further by omitting hunks that consist of
difference with solely one parent.
Signed-off-by: Junio C Hamano <junkio@cox.net>
squelches the output further by omitting hunks that consist of
difference with solely one parent.
Signed-off-by: Junio C Hamano <junkio@cox.net>
combine-diff.c | patch | blob | history | |
diff-tree.c | patch | blob | history | |
diff.h | patch | blob | history |
diff --git a/combine-diff.c b/combine-diff.c
index 669002349a2ae0f54e19329e25406ceaf4ee358c..062ed8a7bfda9e84a91597232e61f7c62d877459 100644 (file)
--- a/combine-diff.c
+++ b/combine-diff.c
return ((sline->flag & all_mask) != all_mask || sline->lost_head);
}
-static void make_hunks(struct sline *sline, unsigned long cnt, int num_parent)
+static unsigned long line_diff_parents(struct sline *sline, unsigned long all_mask)
+{
+ /*
+ * Look at the line and see from which parents we have difference.
+ * Lower bits of sline->flag records if the parent had this line,
+ * so XOR with all_mask gives us on-bits for parents we have
+ * differences with.
+ */
+ unsigned long parents = (sline->flag ^ all_mask);
+ if (sline->lost_head) {
+ struct lline *ll;
+ for (ll = sline->lost_head; ll; ll = ll->next)
+ parents |= ll->parent_map;
+ }
+ return parents & all_mask;
+}
+
+static void make_hunks(struct sline *sline, unsigned long cnt,
+ int num_parent, int dense)
{
unsigned long all_mask = (1UL<<num_parent) - 1;
unsigned long mark = (1UL<<num_parent);
}
i++;
}
+ if (!dense)
+ return;
+
+ /* Look at each hunk, and if it contains changes from only
+ * one parent, mark that uninteresting.
+ */
+ i = 0;
+ while (i < cnt) {
+ int j, hunk_end, diffs;
+ unsigned long parents;
+ while (i < cnt && !(sline[i].flag & mark))
+ i++;
+ if (cnt <= i)
+ break; /* No more interesting hunks */
+ for (hunk_end = i + 1; hunk_end < cnt; hunk_end++)
+ if (!(sline[hunk_end].flag & mark))
+ break;
+ /* [i..hunk_end) are interesting. Now is it from
+ * only one parent?
+ * If lost lines are only from one parent and
+ * remaining lines existed in parents other than
+ * that parent, then the hunk is not that interesting.
+ */
+ parents = 0;
+ diffs = 0;
+ for (j = i; j < hunk_end; j++)
+ parents |= line_diff_parents(sline + j, all_mask);
+ /* Now, how many bits from [0..num_parent) are on? */
+ for (j = 0; j < num_parent; j++) {
+ if (parents & (1UL<<j))
+ diffs++;
+ }
+ if (diffs < 2) {
+ /* This hunk is not that interesting after all */
+ for (j = i; j < hunk_end; j++)
+ sline[j].flag &= ~mark;
+ }
+ i = hunk_end;
+ }
}
static void dump_sline(struct sline *sline, int cnt, int num_parent)
}
}
-static void show_combined_diff(struct path_list *elem, int num_parent)
+static void show_combined_diff(struct path_list *elem, int num_parent,
+ int dense)
{
unsigned long size, cnt, lno;
char *result, *cp, *ep;
for (i = 0; i < num_parent; i++)
combine_diff(elem->parent_sha1[i], ourtmp, sline, cnt, i);
- make_hunks(sline, cnt, num_parent);
+ make_hunks(sline, cnt, num_parent, dense);
dump_sline(sline, cnt, num_parent);
unlink(ourtmp);
}
int diff_tree_combined_merge(const unsigned char *sha1,
- const char *header, int show_empty_merge)
+ const char *header,
+ int show_empty_merge, int dense)
{
struct commit *commit = lookup_commit(sha1);
struct diff_options diffopts;
else
printf("%s", p->path);
putchar('\n');
- show_combined_diff(p, num_parent);
+ show_combined_diff(p, num_parent, dense);
}
}
diff --git a/diff-tree.c b/diff-tree.c
index 0c689360ee5bf40eda7d1241ebcffcfce0b8e0db..99c580cf75ee15d6bbd65c588360309cc94e9dc4 100644 (file)
--- a/diff-tree.c
+++ b/diff-tree.c
static int ignore_merges = 1;
static int show_empty_combined = 0;
static int combine_merges = 0;
+static int dense_combined_merges = 0;
static int read_stdin = 0;
static const char *header = NULL;
header = generate_header(sha1, sha1,
commit->buffer);
return diff_tree_combined_merge(sha1, header,
- show_empty_combined);
+ show_empty_combined,
+ dense_combined_merges);
}
}
}
static const char diff_tree_usage[] =
-"git-diff-tree [--stdin] [-m] [-c] [-s] [-v] [--pretty] [-t] [-r] [--root] "
+"git-diff-tree [--stdin] [-m] [-c] [--cc] [-s] [-v] [--pretty] [-t] [-r] [--root] "
"[<common diff options>] <tree-ish> [<tree-ish>] [<path>...]\n"
" -r diff recursively\n"
" --root include the initial commit as diff against /dev/null\n"
combine_merges = 1;
continue;
}
+ if (!strcmp(arg, "--cc")) {
+ dense_combined_merges = combine_merges = 1;
+ continue;
+ }
if (!strcmp(arg, "-v")) {
verbose_header = 1;
header_prefix = "diff-tree ";
index 081234cb97ce1a06c7acda97510dc8440d440a86..ab0d47b982ac462843f6fbde555ea902f332b97d 100644 (file)
--- a/diff.h
+++ b/diff.h
extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,
const char *base, struct diff_options *opt);
-extern int diff_tree_combined_merge(const unsigned char *sha1, const char *, int);
+extern int diff_tree_combined_merge(const unsigned char *sha1, const char *, int, int);
extern void diff_addremove(struct diff_options *,
int addremove,