Merge branch 'tr/format-patch-thread'
* tr/format-patch-thread: format-patch: support deep threading format-patch: thread as reply to cover letter even with in-reply-to format-patch: track several references format-patch: threading test reactivation Conflicts: builtin-log.c
This commit is contained in:
@ -17,6 +17,7 @@
|
||||
#include "run-command.h"
|
||||
#include "shortlog.h"
|
||||
#include "remote.h"
|
||||
#include "string-list.h"
|
||||
|
||||
/* Set a default date-time format for git log ("log.date" config variable) */
|
||||
static const char *default_date_mode = NULL;
|
||||
@ -461,6 +462,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")) {
|
||||
@ -497,7 +502,18 @@ static int git_format_config(const char *var, const char *value, void *cb)
|
||||
default_attach = xstrdup(git_version_string);
|
||||
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);
|
||||
}
|
||||
@ -776,7 +792,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;
|
||||
@ -878,8 +893,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")) {
|
||||
@ -1030,8 +1050,12 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||
numbered = 1;
|
||||
if (numbered)
|
||||
rev.total = total + start_number - 1;
|
||||
if (in_reply_to)
|
||||
rev.ref_message_id = clean_message_id(in_reply_to);
|
||||
if (in_reply_to || thread || cover_letter)
|
||||
rev.ref_message_ids = xcalloc(1, sizeof(struct string_list));
|
||||
if (in_reply_to) {
|
||||
const char *msgid = clean_message_id(in_reply_to);
|
||||
string_list_append(msgid, rev.ref_message_ids);
|
||||
}
|
||||
if (cover_letter) {
|
||||
if (thread)
|
||||
gen_message_id(&rev, "cover");
|
||||
@ -1050,15 +1074,33 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||
/* Have we already had a message ID? */
|
||||
if (rev.message_id) {
|
||||
/*
|
||||
* If we've got the ID to be a reply
|
||||
* to, discard the current ID;
|
||||
* otherwise, make everything a reply
|
||||
* to that.
|
||||
* 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.
|
||||
*
|
||||
* With --in-reply-to but no
|
||||
* --cover-letter, make every mail a
|
||||
* reply to the <reply-to>.
|
||||
*
|
||||
* With --cover-letter, make every
|
||||
* mail but the cover letter a reply
|
||||
* to the cover letter. The cover
|
||||
* letter is a reply to the
|
||||
* --in-reply-to, if specified.
|
||||
*/
|
||||
if (rev.ref_message_id)
|
||||
if (thread == THREAD_SHALLOW
|
||||
&& rev.ref_message_ids->nr > 0
|
||||
&& (!cover_letter || rev.nr > 1))
|
||||
free(rev.message_id);
|
||||
else
|
||||
rev.ref_message_id = rev.message_id;
|
||||
string_list_append(rev.message_id,
|
||||
rev.ref_message_ids);
|
||||
}
|
||||
gen_message_id(&rev, sha1_to_hex(commit->object.sha1));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user