diff options
author | Junio C Hamano <junkio@cox.net> | 2006-07-30 23:42:10 -0700 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-07-30 23:42:10 -0700 |
commit | c1a788aceecb0a8e95d6442938ade9ca43df033e (patch) | |
tree | 30d99ae60a57281f75586d64f9853429fa3d26e7 /builtin-log.c | |
parent | f59aac47f3839367d0da04019b0fc2bd61345225 (diff) | |
parent | 076b0adcf9dac7bd9d18624087f679cc811aeb77 (diff) | |
download | git-c1a788aceecb0a8e95d6442938ade9ca43df033e.tar.gz |
Merge branch 'js/read-tree' into js/c-merge-recursive
* js/read-tree: (107 commits)
read-tree: move merge functions to the library
read-trees: refactor the unpack_trees() part
tar-tree: illustrate an obscure feature better
git.c: allow alias expansion without a git directory
setup_git_directory_gently: do not barf when GIT_DIR is given.
Build on Debian GNU/kFreeBSD
Call setup_git_directory() much earlier
Call setup_git_directory() early
Display an error from update-ref if target ref name is invalid.
Fix http-fetch
t4103: fix binary patch application test.
git-apply -R: binary patches are irreversible for now.
Teach git-apply about '-R'
Makefile: ssh-pull.o depends on ssh-fetch.c
log and diff family: honor config even from subdirectories
git-reset: detect update-ref error and report it.
lost-found: use fsck-objects --full
Teach git-http-fetch the --stdin switch
Teach git-local-fetch the --stdin switch
Make pull() support fetching multiple targets at once
...
Diffstat (limited to 'builtin-log.c')
-rw-r--r-- | builtin-log.c | 71 |
1 files changed, 56 insertions, 15 deletions
diff --git a/builtin-log.c b/builtin-log.c index 7e5cab15c1..82c69d1d05 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -10,11 +10,13 @@ #include "revision.h" #include "log-tree.h" #include "builtin.h" +#include <time.h> +#include <sys/time.h> /* this is in builtin-diff.c */ void add_head(struct rev_info *revs); -static void cmd_log_init(int argc, const char **argv, char **envp, +static void cmd_log_init(int argc, const char **argv, const char *prefix, struct rev_info *rev) { rev->abbrev = DEFAULT_ABBREV; @@ -43,27 +45,27 @@ static int cmd_log_walk(struct rev_info *rev) return 0; } -int cmd_whatchanged(int argc, const char **argv, char **envp) +int cmd_whatchanged(int argc, const char **argv, const char *prefix) { struct rev_info rev; git_config(git_diff_ui_config); - init_revisions(&rev); + init_revisions(&rev, prefix); rev.diff = 1; rev.diffopt.recursive = 1; rev.simplify_history = 0; - cmd_log_init(argc, argv, envp, &rev); + cmd_log_init(argc, argv, prefix, &rev); if (!rev.diffopt.output_format) rev.diffopt.output_format = DIFF_FORMAT_RAW; return cmd_log_walk(&rev); } -int cmd_show(int argc, const char **argv, char **envp) +int cmd_show(int argc, const char **argv, const char *prefix) { struct rev_info rev; git_config(git_diff_ui_config); - init_revisions(&rev); + init_revisions(&rev, prefix); rev.diff = 1; rev.diffopt.recursive = 1; rev.combine_merges = 1; @@ -71,18 +73,18 @@ int cmd_show(int argc, const char **argv, char **envp) rev.always_show_header = 1; rev.ignore_merges = 0; rev.no_walk = 1; - cmd_log_init(argc, argv, envp, &rev); + cmd_log_init(argc, argv, prefix, &rev); return cmd_log_walk(&rev); } -int cmd_log(int argc, const char **argv, char **envp) +int cmd_log(int argc, const char **argv, const char *prefix) { struct rev_info rev; git_config(git_diff_ui_config); - init_revisions(&rev); + init_revisions(&rev, prefix); rev.always_show_header = 1; - cmd_log_init(argc, argv, envp, &rev); + cmd_log_init(argc, argv, prefix, &rev); return cmd_log_walk(&rev); } @@ -176,7 +178,7 @@ static int get_patch_id(struct commit *commit, struct diff_options *options, return diff_flush_patch_id(options, sha1); } -static void get_patch_ids(struct rev_info *rev, struct diff_options *options) +static void get_patch_ids(struct rev_info *rev, struct diff_options *options, const char *prefix) { struct rev_info check_rev; struct commit *commit; @@ -201,7 +203,7 @@ static void get_patch_ids(struct rev_info *rev, struct diff_options *options) die("diff_setup_done failed"); /* given a range a..b get all patch ids for b..a */ - init_revisions(&check_rev); + init_revisions(&check_rev, prefix); o1->flags ^= UNINTERESTING; o2->flags ^= UNINTERESTING; add_pending_object(&check_rev, o1, "o1"); @@ -226,7 +228,19 @@ static void get_patch_ids(struct rev_info *rev, struct diff_options *options) o2->flags = flags2; } -int cmd_format_patch(int argc, const char **argv, char **envp) +static void gen_message_id(char *dest, unsigned int length, char *base) +{ + const char *committer = git_committer_info(1); + const char *email_start = strrchr(committer, '<'); + const char *email_end = strrchr(committer, '>'); + if(!email_start || !email_end || email_start > email_end - 1) + die("Could not extract email from committer identity."); + snprintf(dest, length, "%s.%lu.git.%.*s", base, + (unsigned long) time(NULL), + (int)(email_end - email_start - 1), email_start + 1); +} + +int cmd_format_patch(int argc, const char **argv, const char *prefix) { struct commit *commit; struct commit **list = NULL; @@ -237,11 +251,15 @@ int cmd_format_patch(int argc, const char **argv, char **envp) int start_number = -1; int keep_subject = 0; int ignore_if_in_upstream = 0; + int thread = 0; + const char *in_reply_to = NULL; struct diff_options patch_id_opts; char *add_signoff = NULL; + char message_id[1024]; + char ref_message_id[1024]; git_config(git_format_config); - init_revisions(&rev); + init_revisions(&rev, prefix); rev.commit_format = CMIT_FMT_EMAIL; rev.verbose_header = 1; rev.diff = 1; @@ -304,6 +322,16 @@ int cmd_format_patch(int argc, const char **argv, char **envp) rev.mime_boundary = argv[i] + 9; else if (!strcmp(argv[i], "--ignore-if-in-upstream")) ignore_if_in_upstream = 1; + else if (!strcmp(argv[i], "--thread")) + thread = 1; + else if (!strncmp(argv[i], "--in-reply-to=", 14)) + in_reply_to = argv[i] + 14; + else if (!strcmp(argv[i], "--in-reply-to")) { + i++; + if (i == argc) + die("Need a Message-Id for --in-reply-to"); + in_reply_to = argv[i]; + } else argv[j++] = argv[i]; } @@ -335,7 +363,7 @@ int cmd_format_patch(int argc, const char **argv, char **envp) } if (ignore_if_in_upstream) - get_patch_ids(&rev, &patch_id_opts); + get_patch_ids(&rev, &patch_id_opts, prefix); if (!use_stdout) realstdout = fdopen(dup(1), "w"); @@ -361,10 +389,23 @@ int cmd_format_patch(int argc, const char **argv, char **envp) if (numbered) rev.total = total + start_number - 1; rev.add_signoff = add_signoff; + rev.ref_message_id = in_reply_to; while (0 <= --nr) { int shown; commit = list[nr]; rev.nr = total - nr + (start_number - 1); + /* Make the second and subsequent mails replies to the first */ + if (thread) { + if (nr == (total - 2)) { + strncpy(ref_message_id, message_id, + sizeof(ref_message_id)); + ref_message_id[sizeof(ref_message_id)-1]='\0'; + rev.ref_message_id = ref_message_id; + } + gen_message_id(message_id, sizeof(message_id), + sha1_to_hex(commit->object.sha1)); + rev.message_id = message_id; + } if (!use_stdout) reopen_stdout(commit, rev.nr, keep_subject); shown = log_tree_commit(&rev, commit); |