aboutsummaryrefslogtreecommitdiff
path: root/builtin-log.c
diff options
context:
space:
mode:
authorThomas Rast <trast@student.ethz.ch>2009-02-19 22:26:33 +0100
committerJunio C Hamano <gitster@pobox.com>2009-02-21 20:26:10 -0800
commit30984ed2e92651962c6b8bdacf1f84da75d1da95 (patch)
treef247b9b2541bbd57d3089a4ae54bffe4aa43b6cf /builtin-log.c
parent2175c10d5ad2769936f5bf5bcca5ea32715a7307 (diff)
downloadgit-30984ed2e92651962c6b8bdacf1f84da75d1da95.tar.gz
git-30984ed2e92651962c6b8bdacf1f84da75d1da95.tar.xz
format-patch: support deep threading
For deep threading mode, i.e., the mode that gives a thread structured like + [PATCH 0/n] Cover letter `-+ [PATCH 1/n] First patch `-+ [PATCH 2/n] Second patch `-+ ... we currently have to use 'git send-email --thread' (the default). On the other hand, format-patch also has a --thread option which gives shallow mode, i.e., + [PATCH 0/n] Cover letter |-+ [PATCH 1/n] First patch |-+ [PATCH 2/n] Second patch ... To reduce the confusion resulting from having two indentically named features in different tools giving different results, let format-patch take an optional argument '--thread=deep' that gives the same output as 'send-mail --thread'. With no argument, or 'shallow', behave as before. Also add a configuration variable format.thread with the same semantics. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-log.c')
-rw-r--r--builtin-log.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/builtin-log.c b/builtin-log.c
index 1df38e17a..6bf04e8af 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -460,6 +460,10 @@ static void add_header(const char *value)
extra_hdr[extra_hdr_nr++] = xstrndup(value, len);
}
+#define THREAD_SHALLOW 1
+#define THREAD_DEEP 2
+static int thread = 0;
+
static int git_format_config(const char *var, const char *value, void *cb)
{
if (!strcmp(var, "format.headers")) {
@@ -489,6 +493,18 @@ static int git_format_config(const char *var, const char *value, void *cb)
auto_number = auto_number && numbered;
return 0;
}
+ if (!strcmp(var, "format.thread")) {
+ if (value && !strcasecmp(value, "deep")) {
+ thread = THREAD_DEEP;
+ return 0;
+ }
+ if (value && !strcasecmp(value, "shallow")) {
+ thread = THREAD_SHALLOW;
+ return 0;
+ }
+ thread = git_config_bool(var, value) && THREAD_SHALLOW;
+ return 0;
+ }
return git_log_config(var, value, cb);
}
@@ -767,7 +783,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
int numbered_files = 0; /* _just_ numbers */
int subject_prefix = 0;
int ignore_if_in_upstream = 0;
- int thread = 0;
int cover_letter = 0;
int boundary_count = 0;
int no_binary_diff = 0;
@@ -860,8 +875,13 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
}
else if (!strcmp(argv[i], "--ignore-if-in-upstream"))
ignore_if_in_upstream = 1;
- else if (!strcmp(argv[i], "--thread"))
- thread = 1;
+ else if (!strcmp(argv[i], "--thread")
+ || !strcmp(argv[i], "--thread=shallow"))
+ thread = THREAD_SHALLOW;
+ else if (!strcmp(argv[i], "--thread=deep"))
+ thread = THREAD_DEEP;
+ else if (!strcmp(argv[i], "--no-thread"))
+ thread = 0;
else if (!prefixcmp(argv[i], "--in-reply-to="))
in_reply_to = argv[i] + 14;
else if (!strcmp(argv[i], "--in-reply-to")) {
@@ -1036,6 +1056,12 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
/* Have we already had a message ID? */
if (rev.message_id) {
/*
+ * For deep threading: make every mail
+ * a reply to the previous one, no
+ * matter what other options are set.
+ *
+ * For shallow threading:
+ *
* Without --cover-letter and
* --in-reply-to, make every mail a
* reply to the one before.
@@ -1050,7 +1076,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
* letter is a reply to the
* --in-reply-to, if specified.
*/
- if (rev.ref_message_ids->nr > 0
+ if (thread == THREAD_SHALLOW
+ && rev.ref_message_ids->nr > 0
&& (!cover_letter || rev.nr > 1))
free(rev.message_id);
else