From: Junio C Hamano <junkio@cox.net>
To: "Geoff Russell" <geoffrey.russell@gmail.com>,
"Marco Costalba" <mcostalba@gmail.com>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org, Seth Falcon <sethfalcon@gmail.com>
Subject: [PATCH] format-patch --signoff
Date: Wed, 31 May 2006 15:14:07 -0700 [thread overview]
Message-ID: <7v4pz5zvtc.fsf_-_@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <7vejyayq46.fsf@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Wed, 31 May 2006 12:02:33 -0700")
This resurrects --signoff option to format-patch.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
builtin-log.c | 18 ++++++++++++++++--
log-tree.c | 35 +++++++++++++++++++++++++++++++++++
revision.h | 1 +
3 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/builtin-log.c b/builtin-log.c
index db1912a..ac4822d 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -150,6 +150,7 @@ int cmd_format_patch(int argc, const cha
int numbered = 0;
int start_number = -1;
int keep_subject = 0;
+ char *add_signoff = NULL;
init_revisions(&rev);
rev.commit_format = CMIT_FMT_EMAIL;
@@ -179,11 +180,13 @@ int cmd_format_patch(int argc, const cha
if (i == argc)
die("Need a number for --start-number");
start_number = strtol(argv[i], NULL, 10);
- } else if (!strcmp(argv[i], "-k") ||
+ }
+ else if (!strcmp(argv[i], "-k") ||
!strcmp(argv[i], "--keep-subject")) {
keep_subject = 1;
rev.total = -1;
- } else if (!strcmp(argv[i], "-o")) {
+ }
+ else if (!strcmp(argv[i], "-o")) {
if (argc < 3)
die ("Which directory?");
if (mkdir(argv[i + 1], 0777) < 0 && errno != EEXIST)
@@ -192,6 +195,16 @@ int cmd_format_patch(int argc, const cha
output_directory = strdup(argv[i + 1]);
i++;
}
+ else if (!strcmp(argv[i], "--signoff") ||
+ !strcmp(argv[i], "-s")) {
+ const char *committer = git_committer_info(1);
+ const char *endpos = strchr(committer, '>');
+ if (!endpos)
+ die("bogos committer info %s\n", committer);
+ add_signoff = xmalloc(endpos - committer + 2);
+ memcpy(add_signoff, committer, endpos - committer + 1);
+ add_signoff[endpos - committer + 1] = 0;
+ }
else if (!strcmp(argv[i], "--attach"))
rev.mime_boundary = git_version_string;
else if (!strncmp(argv[i], "--attach=", 9))
@@ -230,6 +243,7 @@ int cmd_format_patch(int argc, const cha
total = nr;
if (numbered)
rev.total = total + start_number - 1;
+ rev.add_signoff = add_signoff;
while (0 <= --nr) {
int shown;
commit = list[nr];
diff --git a/log-tree.c b/log-tree.c
index 58b0163..e86e16b 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -12,6 +12,37 @@ static void show_parents(struct commit *
}
}
+static int append_signoff(char *buf, int buf_sz, int at, const char *signoff)
+{
+ int signoff_len = strlen(signoff);
+ static const char signed_off_by[] = "Signed-off-by: ";
+ char *cp = buf;
+
+ /* Do we have enough space to add it? */
+ if (buf_sz - at <= strlen(signed_off_by) + signoff_len + 2)
+ return at;
+
+ /* First see if we already have the sign-off by the signer */
+ while (1) {
+ cp = strstr(cp, signed_off_by);
+ if (!cp)
+ break;
+ cp += strlen(signed_off_by);
+ if ((cp + signoff_len < buf + at) &&
+ !strncmp(cp, signoff, signoff_len) &&
+ isspace(cp[signoff_len]))
+ return at; /* we already have him */
+ }
+
+ strcpy(buf + at, signed_off_by);
+ at += strlen(signed_off_by);
+ strcpy(buf + at, signoff);
+ at += signoff_len;
+ buf[at++] = '\n';
+ buf[at] = 0;
+ return at;
+}
+
void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
{
static char this_header[16384];
@@ -111,6 +142,10 @@ void show_log(struct rev_info *opt, stru
* And then the pretty-printed message itself
*/
len = pretty_print_commit(opt->commit_format, commit, ~0u, this_header, sizeof(this_header), abbrev, subject, after_subject);
+
+ if (opt->add_signoff)
+ len = append_signoff(this_header, sizeof(this_header), len,
+ opt->add_signoff);
printf("%s%s%s", this_header, extra, sep);
}
diff --git a/revision.h b/revision.h
index bdbdd23..75796bc 100644
--- a/revision.h
+++ b/revision.h
@@ -60,6 +60,7 @@ struct rev_info {
struct log_info *loginfo;
int nr, total;
const char *mime_boundary;
+ const char *add_signoff;
/* special limits */
int max_count;
--
1.3.3.g1361-dirty
next prev parent reply other threads:[~2006-05-31 22:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <93c3eada0605310332p19241861g466e1516a2aaf0df@mail.gmail.com>
2006-05-31 11:11 ` format-patch signoff argument no longer works Geoff Russell
2006-05-31 11:28 ` Matthias Kestenholz
2006-05-31 13:58 ` Seth Falcon
2006-05-31 14:09 ` Johannes Schindelin
2006-05-31 19:02 ` Junio C Hamano
2006-05-31 19:19 ` J. Bruce Fields
2006-05-31 19:43 ` Seth Falcon
2006-05-31 22:14 ` Junio C Hamano [this message]
2006-05-31 22:42 ` [PATCH] format-patch --signoff Johannes Schindelin
2006-05-31 23:16 ` Junio C Hamano
2006-05-31 23:31 ` Johannes Schindelin
2006-05-31 14:14 ` [PATCH] Update documentation for git-format-patch Dennis Stosberg
2006-05-31 15:00 ` Johannes Schindelin
2006-05-31 15:24 ` Jakub Narebski
2006-05-31 17:24 ` Dennis Stosberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7v4pz5zvtc.fsf_-_@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=Johannes.Schindelin@gmx.de \
--cc=geoffrey.russell@gmail.com \
--cc=git@vger.kernel.org \
--cc=mcostalba@gmail.com \
--cc=sethfalcon@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).