format-patch: update append_signoff prototype
This is a preparation step for merging with append_signoff from sequencer.c Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Brandon Casey <bcasey@nvidia.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Feb 12, 2013 at 02:17 UTC
5289c56a72efc6e5e4409c7a3802fc54aea09340
3 files changed
+15
-17
builtin/log.c
+1
-12
@@ -1058,7 +1058,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1058
struct commit *origin = NULL, *head = NULL;
1059
const char *in_reply_to = NULL;
1060
struct patch_ids ids;
1061
- char *add_signoff = NULL;
1061
struct strbuf buf = STRBUF_INIT;
1062
int use_patch_format = 0;
1063
int quiet = 0;
@@ -1154,16 +1153,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1153
PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN |
1154
PARSE_OPT_KEEP_DASHDASH);
1155
1157
- if (do_signoff) {
1158
- const char *committer;
1159
- const char *endpos;
1160
- committer = git_committer_info(IDENT_STRICT);
1161
- endpos = strchr(committer, '>');
1162
- if (!endpos)
1163
- die(_("bogus committer info %s"), committer);
1164
- add_signoff = xmemdupz(committer, endpos - committer + 1);
1165
- }
1166
-
1156
for (i = 0; i < extra_hdr.nr; i++) {
1157
strbuf_addstr(&buf, extra_hdr.items[i].string);
1158
strbuf_addch(&buf, '\n');
@@ -1354,7 +1343,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1343
total++;
1344
start_number--;
1345
}
1357
- rev.add_signoff = add_signoff;
1346
+ rev.add_signoff = do_signoff;
1347
while (0 <= --nr) {
1348
int shown;
1349
commit = list[nr];
log-tree.c
+13
-4
@@ -10,6 +10,8 @@
10
#include "color.h"
11
#include "gpg-interface.h"
12
13
+#define APPEND_SIGNOFF_DEDUP (1u <<0)
14
+
15
struct decoration name_decoration = { "object names" };
16
17
enum decoration_type {
@@ -253,9 +255,12 @@ static int detect_any_signoff(char *letter, int size)
255
return seen_head && seen_name;
256
}
257
256
-static void append_signoff(struct strbuf *sb, const char *signoff)
258
+static void append_signoff(struct strbuf *sb, int ignore_footer, unsigned flag)
259
{
260
+ unsigned no_dup_sob = flag & APPEND_SIGNOFF_DEDUP;
261
static const char signed_off_by[] = "Signed-off-by: ";
262
+ char *signoff = xstrdup(fmt_name(getenv("GIT_COMMITTER_NAME"),
263
+ getenv("GIT_COMMITTER_EMAIL")));
264
size_t signoff_len = strlen(signoff);
265
int has_signoff = 0;
266
char *cp;
@@ -275,6 +280,7 @@ static void append_signoff(struct strbuf *sb, const char *signoff)
280
if (!isspace(cp[signoff_len]))
281
continue;
282
/* we already have him */
283
+ free(signoff);
284
return;
285
}
286
@@ -287,6 +293,7 @@ static void append_signoff(struct strbuf *sb, const char *signoff)
293
strbuf_addstr(sb, signed_off_by);
294
strbuf_add(sb, signoff, signoff_len);
295
strbuf_addch(sb, '\n');
296
+ free(signoff);
297
}
298
299
static unsigned int digits_in_number(unsigned int number)
@@ -662,8 +669,10 @@ void show_log(struct rev_info *opt)
669
/*
670
* And then the pretty-printed message itself
671
*/
665
- if (ctx.need_8bit_cte >= 0)
666
- ctx.need_8bit_cte = has_non_ascii(opt->add_signoff);
672
+ if (ctx.need_8bit_cte >= 0 && opt->add_signoff)
673
+ ctx.need_8bit_cte =
674
+ has_non_ascii(fmt_name(getenv("GIT_COMMITTER_NAME"),
675
+ getenv("GIT_COMMITTER_EMAIL")));
676
ctx.date_mode = opt->date_mode;
677
ctx.date_mode_explicit = opt->date_mode_explicit;
678
ctx.abbrev = opt->diffopt.abbrev;
@@ -674,7 +683,7 @@ void show_log(struct rev_info *opt)
683
pretty_print_commit(&ctx, commit, &msgbuf);
684
685
if (opt->add_signoff)
677
- append_signoff(&msgbuf, opt->add_signoff);
686
+ append_signoff(&msgbuf, 0, APPEND_SIGNOFF_DEDUP);
687
688
if ((ctx.fmt != CMIT_FMT_USERFORMAT) &&
689
ctx.notes_message && *ctx.notes_message) {
revision.h
+1
-1
@@ -137,7 +137,7 @@ struct rev_info {
137
int numbered_files;
138
char *message_id;
139
struct string_list *ref_message_ids;
140
- const char *add_signoff;
140
+ int add_signoff;
141
const char *extra_headers;
142
const char *log_reencode;
143
const char *subject_prefix;