{"thread":{"id":"25991","subject":"[WIP/RFH] format-patch: Allow diffs for first-parent history","startedAt":"2010-12-08T10:18:35Z","lastAt":"2010-12-08T10:52:09Z","messageCount":2,"participants":["Michael J Gruber","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"157590","messageId":"f60b93ae61c0e3088112cd6e1185d9c66f623813.1291803440.git.git@drmicha.warpmail.net","threadId":"25991","inReplyTo":null,"subject":"[WIP/RFH] format-patch: Allow diffs for first-parent history","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-12-08T10:18:35Z","receivedAt":"2010-12-08T10:18:35Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Introduce a new option \"--first-parent\" to format-patch which allows\nto export the \"main development\" line as a series of patches, where\nmerge commits are represented by their diff against the first parent.\n\nThis is useful for keeping development steps and history in side\nbranches and exporting the cleaned up main line for upstream (\"mergy\nrebase\").\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\nThis does not work yet! Work In Progress/Request For Help\n\n\"git log -p -m --first-parent\" does exactly what I want to achieve,\nsince the parent rewriting done by \"--first-parent\" makes \"-p -m\" output\nthe diff to the first parent only.\n\nThe attached patch teaches format-patch not to ignore merges (on\n\"--first-parent\"), but I failed to track how \"diff-tree\" sets options\nbased on \"-m\" and how to do that for \"format-patch\". I am sure someone\nhere can help me!\n\n builtin/log.c |    6 +++++-\n 1 files changed, 5 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 4191d9c..34d01d3 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -983,6 +983,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \tint cover_letter = 0;\n \tint boundary_count = 0;\n \tint no_binary_diff = 0;\n+\tint first_parent = 0;\n \tstruct commit *origin = NULL, *head = NULL;\n \tconst char *in_reply_to = NULL;\n \tstruct patch_ids ids;\n@@ -1023,6 +1024,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\t{ OPTION_BOOLEAN, 'p', \"no-stat\", &use_patch_format, NULL,\n \t\t  \"show patch format instead of default (patch + stat)\",\n \t\t  PARSE_OPT_NONEG | PARSE_OPT_NOARG },\n+\t\tOPT_BOOLEAN(0, \"first-parent\", &first_parent,\n+\t\t\t    \"follow first parents\"),\n \t\tOPT_GROUP(\"Messaging\"),\n \t\t{ OPTION_CALLBACK, 0, \"add-header\", NULL, \"header\",\n \t\t\t    \"add email header\", 0, header_callback },\n@@ -1055,7 +1058,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \trev.commit_format = CMIT_FMT_EMAIL;\n \trev.verbose_header = 1;\n \trev.diff = 1;\n-\trev.no_merges = 1;\n+\trev.no_merges = !first_parent;\n+\trev.first_parent_only = first_parent;\n \tDIFF_OPT_SET(&rev.diffopt, RECURSIVE);\n \trev.subject_prefix = fmt_patch_subject_prefix;\n \tmemset(&s_r_opt, 0, sizeof(s_r_opt));\n-- \n1.7.3.2.660.g7cc83\n"},{"id":"157594","messageId":"20101208105209.GA4947@burratino","threadId":"25991","inReplyTo":"f60b93ae61c0e3088112cd6e1185d9c66f623813.1291803440.git.git@drmicha.warpmail.net","subject":"Re: [WIP/RFH] format-patch: Allow diffs for first-parent history","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-12-08T10:52:09Z","receivedAt":"2010-12-08T10:52:09Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Michael J Gruber wrote:\n\n> The attached patch teaches format-patch not to ignore merges (on\n> \"--first-parent\"), but I failed to track how \"diff-tree\" sets options\n> based on \"-m\"\n\nWith hindsight, here's a search result:\n\n $ git grep -e argv -- builtin/diff-tree.c\n int cmd_diff_tree(int argc, const char **argv, const char *prefix)\n         argc = setup_revisions(argc, argv, opt, &s_r_opt);\n                 const char *arg = *++argv;\n\nSo it's setup_revisions, in revision.c, which clears revs->ignore_merges\nwhen -m is detected.\n\nMaybe it should clear revs->no_merges while at it?  I can't see any\nother meaningful meaning for\n\n\tgit alias.lg \"log --no-merges\"\n\tgit lg -m HEAD~2..HEAD\n\nor\n\n\tgit format-patch -m --first-parent HEAD~2..HEAD\n\nMeanwhile I would also be happy to see --first-parent imply -m, though\nthat might be more controversial since -p -c --first-parent and\n-p --cc --first-parent are also meaningful.\n"}]}