[WIP/RFH] format-patch: Allow diffs for first-parent history

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Introduce a new option "--first-parent" to format-patch which allows
to export the "main development" line as a series of patches, where
merge commits are represented by their diff against the first parent.

This is useful for keeping development steps and history in side
branches and exporting the cleaned up main line for upstream ("mergy
rebase").

Signed-off-by: Michael J Gruber <git@xxxxxxxxxxxxxxxxxxxx>
---
This does not work yet! Work In Progress/Request For Help

"git log -p -m --first-parent" does exactly what I want to achieve,
since the parent rewriting done by "--first-parent" makes "-p -m" output
the diff to the first parent only.

The attached patch teaches format-patch not to ignore merges (on
"--first-parent"), but I failed to track how "diff-tree" sets options
based on "-m" and how to do that for "format-patch". I am sure someone
here can help me!

 builtin/log.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/builtin/log.c b/builtin/log.c
index 4191d9c..34d01d3 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -983,6 +983,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 	int cover_letter = 0;
 	int boundary_count = 0;
 	int no_binary_diff = 0;
+	int first_parent = 0;
 	struct commit *origin = NULL, *head = NULL;
 	const char *in_reply_to = NULL;
 	struct patch_ids ids;
@@ -1023,6 +1024,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		{ OPTION_BOOLEAN, 'p', "no-stat", &use_patch_format, NULL,
 		  "show patch format instead of default (patch + stat)",
 		  PARSE_OPT_NONEG | PARSE_OPT_NOARG },
+		OPT_BOOLEAN(0, "first-parent", &first_parent,
+			    "follow first parents"),
 		OPT_GROUP("Messaging"),
 		{ OPTION_CALLBACK, 0, "add-header", NULL, "header",
 			    "add email header", 0, header_callback },
@@ -1055,7 +1058,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 	rev.commit_format = CMIT_FMT_EMAIL;
 	rev.verbose_header = 1;
 	rev.diff = 1;
-	rev.no_merges = 1;
+	rev.no_merges = !first_parent;
+	rev.first_parent_only = first_parent;
 	DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
 	rev.subject_prefix = fmt_patch_subject_prefix;
 	memset(&s_r_opt, 0, sizeof(s_r_opt));
-- 
1.7.3.2.660.g7cc83

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]