From: "Pat Notz" <patnotz@gmail.com>
To: git@vger.kernel.org
Subject: [PATCHv5 1/8] commit.c: prefer get_header() to manual searching
Date: Thu, 7 Oct 2010 13:10:50 -0600 [thread overview]
Message-ID: <1286478657-61581-2-git-send-email-patnotz@gmail.com> (raw)
In-Reply-To: <1286478657-61581-1-git-send-email-patnotz@gmail.com>
Signed-off-by: Pat Notz <patnotz@gmail.com>
---
builtin/commit.c | 11 +++--------
commit.h | 1 +
pretty.c | 2 +-
3 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index 66fdd22..bf9fcc1 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -899,7 +899,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
unsigned char sha1[20];
static char utf8[] = "UTF-8";
const char *out_enc;
- char *enc, *end;
+ char *enc;
struct commit *commit;
if (get_sha1(use_message, sha1))
@@ -908,13 +908,8 @@ static int parse_and_validate_options(int argc, const char *argv[],
if (!commit || parse_commit(commit))
die("could not parse commit %s", use_message);
- enc = strstr(commit->buffer, "\nencoding");
- if (enc) {
- end = strchr(enc + 10, '\n');
- enc = xstrndup(enc + 10, end - (enc + 10));
- } else {
- enc = utf8;
- }
+ enc = get_header(commit, "encoding");
+ enc = enc ? enc : utf8;
out_enc = git_commit_encoding ? git_commit_encoding : utf8;
if (strcmp(out_enc, enc))
diff --git a/commit.h b/commit.h
index 9113bbe..c246c94 100644
--- a/commit.h
+++ b/commit.h
@@ -87,6 +87,7 @@ struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
extern char *reencode_commit_message(const struct commit *commit,
const char **encoding_p);
extern void get_commit_format(const char *arg, struct rev_info *);
+extern char *get_header(const struct commit *commit, const char *key);
extern void userformat_find_requirements(const char *fmt, struct userformat_want *w);
extern void format_commit_message(const struct commit *commit,
const char *format, struct strbuf *sb,
diff --git a/pretty.c b/pretty.c
index f85444b..839944c 100644
--- a/pretty.c
+++ b/pretty.c
@@ -348,7 +348,7 @@ static void add_merge_info(enum cmit_fmt fmt, struct strbuf *sb,
strbuf_addch(sb, '\n');
}
-static char *get_header(const struct commit *commit, const char *key)
+char *get_header(const struct commit *commit, const char *key)
{
int key_len = strlen(key);
const char *line = commit->buffer;
--
1.7.3.1
next prev parent reply other threads:[~2010-10-07 19:11 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-07 19:10 [PATCHv5 0/8] Add commit message options for rebase --autosquash Pat Notz
2010-10-07 19:10 ` Pat Notz [this message]
2010-10-07 21:11 ` [PATCHv5 1/8] commit.c: prefer get_header() to manual searching Sverre Rabbelier
2010-10-07 21:12 ` Sverre Rabbelier
2010-10-13 21:59 ` Junio C Hamano
2010-10-07 19:10 ` [PATCHv5 2/8] commit.c: new function for looking up a comit by name Pat Notz
2010-10-13 21:59 ` Junio C Hamano
2010-10-07 19:10 ` [PATCHv5 3/8] pretty.c: helper methods for getting output encodings Pat Notz
2010-10-07 19:10 ` [PATCHv5 4/8] pretty.c: teach format_commit_message() to reencode the output Pat Notz
2010-10-13 21:59 ` Junio C Hamano
2010-10-13 22:44 ` Pat Notz
2010-10-07 19:10 ` [PATCHv5 5/8] commit: --fixup option for use with rebase --autosquash Pat Notz
2010-10-07 19:10 ` [PATCHv5 6/8] add tests of commit --fixup Pat Notz
2010-10-07 19:10 ` [PATCHv5 7/8] commit: --squash option for use with rebase --autosquash Pat Notz
2010-10-07 19:10 ` [PATCHv5 8/8] add tests of commit --squash Pat Notz
2010-10-11 21:06 ` [PATCHv5 0/8] Add commit message options for rebase --autosquash Pat Notz
2010-10-12 9:36 ` Sverre Rabbelier
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=1286478657-61581-2-git-send-email-patnotz@gmail.com \
--to=patnotz@gmail.com \
--cc=git@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.