{"thread":{"id":"3144","subject":"[PATCH 2/2] diff-tree --cc: denser combined diff output for a merge commit.","startedAt":"2006-01-25T02:08:56Z","lastAt":"2006-01-25T20:03:41Z","messageCount":2,"participants":["Junio C Hamano","Eric W. Biederman"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"15100","messageId":"7voe212h53.fsf@assigned-by-dhcp.cox.net","threadId":"3144","inReplyTo":null,"subject":"[PATCH 2/2] diff-tree --cc: denser combined diff output for a merge commit.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-25T02:08:56Z","receivedAt":"2006-01-25T02:08:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Building on the previous '-c' (combined) option, '--cc' option\nsquelches the output further by omitting hunks that consist of\ndifference with solely one parent.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n * I am not particularly happy about the option name, but I\n   wanted to avoid --dense, because it would make it hard to use\n   in the context of 'whatchanged' (rev-list wants that flag).\n\n   Even without '-m' flag, the command outputs the commit log if\n   the removal of not so interesting hunks results in an empty\n   patch, along with 'diff --combined' header.  This might be\n   considered a feature to remind the user that there were some\n   file-level merges, just like diff-files shows empty diffs on\n   cache-dirty paths.\n\n combine-diff.c |   69 ++++++++++++++++++++++++++++++++++++++++++++++++++++----\n diff-tree.c    |   10 ++++++--\n diff.h         |    2 +-\n 3 files changed, 73 insertions(+), 8 deletions(-)\n\nceba1d2a70929c0c89c4dcddb1e1b4dd38d8494c\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 6690023..062ed8a 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -278,7 +278,25 @@ static int interesting(struct sline *sli\n \treturn ((sline->flag & all_mask) != all_mask || sline->lost_head);\n }\n \n-static void make_hunks(struct sline *sline, unsigned long cnt, int num_parent)\n+static unsigned long line_diff_parents(struct sline *sline, unsigned long all_mask)\n+{\n+\t/*\n+\t * Look at the line and see from which parents we have difference.\n+\t * Lower bits of sline->flag records if the parent had this line,\n+\t * so XOR with all_mask gives us on-bits for parents we have\n+\t * differences with.\n+\t */\n+\tunsigned long parents = (sline->flag ^ all_mask);\n+\tif (sline->lost_head) {\n+\t\tstruct lline *ll;\n+\t\tfor (ll = sline->lost_head; ll; ll = ll->next)\n+\t\t\tparents |= ll->parent_map;\n+\t}\n+\treturn parents & all_mask;\n+}\n+\n+static void make_hunks(struct sline *sline, unsigned long cnt,\n+\t\t       int num_parent, int dense)\n {\n \tunsigned long all_mask = (1UL<<num_parent) - 1;\n \tunsigned long mark = (1UL<<num_parent);\n@@ -302,6 +320,45 @@ static void make_hunks(struct sline *sli\n \t\t}\n \t\ti++;\n \t}\n+\tif (!dense)\n+\t\treturn;\n+\n+\t/* Look at each hunk, and if it contains changes from only\n+\t * one parent, mark that uninteresting.\n+\t */\n+\ti = 0;\n+\twhile (i < cnt) {\n+\t\tint j, hunk_end, diffs;\n+\t\tunsigned long parents;\n+\t\twhile (i < cnt && !(sline[i].flag & mark))\n+\t\t\ti++;\n+\t\tif (cnt <= i)\n+\t\t\tbreak; /* No more interesting hunks */\n+\t\tfor (hunk_end = i + 1; hunk_end < cnt; hunk_end++)\n+\t\t\tif (!(sline[hunk_end].flag & mark))\n+\t\t\t\tbreak;\n+\t\t/* [i..hunk_end) are interesting.  Now is it from\n+\t\t * only one parent?\n+\t\t * If lost lines are only from one parent and\n+\t\t * remaining lines existed in parents other than\n+\t\t * that parent, then the hunk is not that interesting.\n+\t\t */\n+\t\tparents = 0;\n+\t\tdiffs = 0;\n+\t\tfor (j = i; j < hunk_end; j++)\n+\t\t\tparents |= line_diff_parents(sline + j, all_mask);\n+\t\t/* Now, how many bits from [0..num_parent) are on? */\n+\t\tfor (j = 0; j < num_parent; j++) {\n+\t\t\tif (parents & (1UL<<j))\n+\t\t\t\tdiffs++;\n+\t\t}\n+\t\tif (diffs < 2) {\n+\t\t\t/* This hunk is not that interesting after all */\n+\t\t\tfor (j = i; j < hunk_end; j++)\n+\t\t\t\tsline[j].flag &= ~mark;\n+\t\t}\n+\t\ti = hunk_end;\n+\t}\n }\n \n static void dump_sline(struct sline *sline, int cnt, int num_parent)\n@@ -351,7 +408,8 @@ static void dump_sline(struct sline *sli\n \t}\n }\n \n-static void show_combined_diff(struct path_list *elem, int num_parent)\n+static void show_combined_diff(struct path_list *elem, int num_parent,\n+\t\t\t       int dense)\n {\n \tunsigned long size, cnt, lno;\n \tchar *result, *cp, *ep;\n@@ -390,7 +448,7 @@ static void show_combined_diff(struct pa\n \tfor (i = 0; i < num_parent; i++)\n \t\tcombine_diff(elem->parent_sha1[i], ourtmp, sline, cnt, i);\n \n-\tmake_hunks(sline, cnt, num_parent);\n+\tmake_hunks(sline, cnt, num_parent, dense);\n \n \tdump_sline(sline, cnt, num_parent);\n \tunlink(ourtmp);\n@@ -410,7 +468,8 @@ static void show_combined_diff(struct pa\n }\n \n int diff_tree_combined_merge(const unsigned char *sha1,\n-\t\t\t     const char *header, int show_empty_merge)\n+\t\t\t     const char *header,\n+\t\t\t     int show_empty_merge, int dense)\n {\n \tstruct commit *commit = lookup_commit(sha1);\n \tstruct diff_options diffopts;\n@@ -455,7 +514,7 @@ int diff_tree_combined_merge(const unsig\n \t\t\telse\n \t\t\t\tprintf(\"%s\", p->path);\n \t\t\tputchar('\\n');\n-\t\t\tshow_combined_diff(p, num_parent);\n+\t\t\tshow_combined_diff(p, num_parent, dense);\n \t\t}\n \t}\n \ndiff --git a/diff-tree.c b/diff-tree.c\nindex 0c68936..99c580c 100644\n--- a/diff-tree.c\n+++ b/diff-tree.c\n@@ -8,6 +8,7 @@ static int verbose_header = 0;\n static int ignore_merges = 1;\n static int show_empty_combined = 0;\n static int combine_merges = 0;\n+static int dense_combined_merges = 0;\n static int read_stdin = 0;\n \n static const char *header = NULL;\n@@ -121,7 +122,8 @@ static int diff_tree_commit(const unsign\n \t\t\theader = generate_header(sha1, sha1,\n \t\t\t\t\t\t commit->buffer);\n \t\t\treturn diff_tree_combined_merge(sha1, header,\n-\t\t\t\t\t\t\tshow_empty_combined);\n+\t\t\t\t\t\t\tshow_empty_combined,\n+\t\t\t\t\t\t\tdense_combined_merges);\n \t\t}\n \t}\n \n@@ -168,7 +170,7 @@ static int diff_tree_stdin(char *line)\n }\n \n static const char diff_tree_usage[] =\n-\"git-diff-tree [--stdin] [-m] [-c] [-s] [-v] [--pretty] [-t] [-r] [--root] \"\n+\"git-diff-tree [--stdin] [-m] [-c] [--cc] [-s] [-v] [--pretty] [-t] [-r] [--root] \"\n \"[<common diff options>] <tree-ish> [<tree-ish>] [<path>...]\\n\"\n \"  -r            diff recursively\\n\"\n \"  --root        include the initial commit as diff against /dev/null\\n\"\n@@ -235,6 +237,10 @@ int main(int argc, const char **argv)\n \t\t\tcombine_merges = 1;\n \t\t\tcontinue;\n \t\t}\n+\t\tif (!strcmp(arg, \"--cc\")) {\n+\t\t\tdense_combined_merges = combine_merges = 1;\n+\t\t\tcontinue;\n+\t\t}\n \t\tif (!strcmp(arg, \"-v\")) {\n \t\t\tverbose_header = 1;\n \t\t\theader_prefix = \"diff-tree \";\ndiff --git a/diff.h b/diff.h\nindex 081234c..ab0d47b 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -56,7 +56,7 @@ extern int diff_tree(struct tree_desc *t\n extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,\n \t\t\t  const char *base, struct diff_options *opt);\n \n-extern int diff_tree_combined_merge(const unsigned char *sha1, const char *, int);\n+extern int diff_tree_combined_merge(const unsigned char *sha1, const char *, int, int);\n \n extern void diff_addremove(struct diff_options *,\n \t\t\t   int addremove,\n-- \n1.1.4.g869a\n"},{"id":"15119","messageId":"m1r76why76.fsf@ebiederm.dsl.xmission.com","threadId":"3144","inReplyTo":"7voe212h53.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] Fix git-format-patch -s to include a Signed-off-by: line...","fromName":"Eric W. Biederman","fromEmail":"ebiederm@xmission.com","sentAt":"2006-01-25T20:03:41Z","receivedAt":"2006-01-25T20:03:41Z","isPatch":true,"sender":{"key":"ebiederm@xmission.com","avatar":"https://avatars.githubusercontent.com/u/7477136?v=4"},"body":"\nIn the last round of bug fixes the signed-off-by line was still be\ngenerated but it was not including a signed-off-by line :(\n\nSigned-off-by: Eric W. Biederman <ebiederm@xmission.com>\n\n\n---\n\n git-format-patch.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\n78308e7078be1beb979def50579722910f2ff54f\ndiff --git a/git-format-patch.sh b/git-format-patch.sh\nindex 7e67c4e..5fb8ce1 100755\n--- a/git-format-patch.sh\n+++ b/git-format-patch.sh\n@@ -178,7 +178,7 @@ my ($signoff_pattern, $done_header, $don\n     $last_was_signoff);\n \n if ($signoff) {\n-\t$signoff = `git-var GIT_COMMITTER_IDENT`;\n+\t$signoff = \"Signed-off-by: \" . `git-var GIT_COMMITTER_IDENT`;\n \t$signoff =~ s/>.*/>/;\n \t$signoff_pattern = quotemeta($signoff);\n }\n-- \n1.1.4.g7830\n"}]}