From: Christian Couder <chriscool@tuxfamily.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Avery Pennarun <apenwarr@gmail.com>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Jonathan Nieder <jrnieder@gmail.com>, Jeff King <peff@peff.net>,
Max Horn <max@quendi.de>
Subject: [PATCH 06/86] pretty: replace prefixcmd() with has_prefix()
Date: Sat, 09 Nov 2013 08:05:59 +0100 [thread overview]
Message-ID: <20131109070720.18178.27578.chriscool@tuxfamily.org> (raw)
In-Reply-To: <20131109070358.18178.40248.chriscool@tuxfamily.org>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
pretty.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/pretty.c b/pretty.c
index b4e32b7..961241a 100644
--- a/pretty.c
+++ b/pretty.c
@@ -40,7 +40,7 @@ static int git_pretty_formats_config(const char *var, const char *value, void *c
const char *fmt;
int i;
- if (prefixcmp(var, "pretty."))
+ if (!has_prefix(var, "pretty."))
return 0;
name = var + strlen("pretty.");
@@ -67,7 +67,7 @@ static int git_pretty_formats_config(const char *var, const char *value, void *c
commit_format->name = xstrdup(name);
commit_format->format = CMIT_FMT_USERFORMAT;
git_config_string(&fmt, var, value);
- if (!prefixcmp(fmt, "format:") || !prefixcmp(fmt, "tformat:")) {
+ if (has_prefix(fmt, "format:") || has_prefix(fmt, "tformat:")) {
commit_format->is_tformat = fmt[0] == 't';
fmt = strchr(fmt, ':') + 1;
} else if (strchr(fmt, '%'))
@@ -115,7 +115,7 @@ static struct cmt_fmt_map *find_commit_format_recursive(const char *sought,
for (i = 0; i < commit_formats_len; i++) {
size_t match_len;
- if (prefixcmp(commit_formats[i].name, sought))
+ if (!has_prefix(commit_formats[i].name, sought))
continue;
match_len = strlen(commit_formats[i].name);
@@ -151,7 +151,7 @@ void get_commit_format(const char *arg, struct rev_info *rev)
rev->commit_format = CMIT_FMT_DEFAULT;
return;
}
- if (!prefixcmp(arg, "format:") || !prefixcmp(arg, "tformat:")) {
+ if (has_prefix(arg, "format:") || has_prefix(arg, "tformat:")) {
save_user_format(rev, strchr(arg, ':') + 1, arg[0] == 't');
return;
}
@@ -840,10 +840,10 @@ static void parse_commit_header(struct format_commit_context *context)
if (i == eol) {
break;
- } else if (!prefixcmp(msg + i, "author ")) {
+ } else if (has_prefix(msg + i, "author ")) {
context->author.off = i + 7;
context->author.len = eol - i - 7;
- } else if (!prefixcmp(msg + i, "committer ")) {
+ } else if (has_prefix(msg + i, "committer ")) {
context->committer.off = i + 10;
context->committer.len = eol - i - 10;
}
@@ -983,7 +983,7 @@ static size_t parse_color(struct strbuf *sb, /* in UTF-8 */
if (!end)
return 0;
- if (!prefixcmp(begin, "auto,")) {
+ if (has_prefix(begin, "auto,")) {
if (!want_color(c->pretty_ctx->color))
return end - placeholder + 1;
begin += 5;
@@ -994,16 +994,16 @@ static size_t parse_color(struct strbuf *sb, /* in UTF-8 */
strbuf_addstr(sb, color);
return end - placeholder + 1;
}
- if (!prefixcmp(placeholder + 1, "red")) {
+ if (has_prefix(placeholder + 1, "red")) {
strbuf_addstr(sb, GIT_COLOR_RED);
return 4;
- } else if (!prefixcmp(placeholder + 1, "green")) {
+ } else if (has_prefix(placeholder + 1, "green")) {
strbuf_addstr(sb, GIT_COLOR_GREEN);
return 6;
- } else if (!prefixcmp(placeholder + 1, "blue")) {
+ } else if (has_prefix(placeholder + 1, "blue")) {
strbuf_addstr(sb, GIT_COLOR_BLUE);
return 5;
- } else if (!prefixcmp(placeholder + 1, "reset")) {
+ } else if (has_prefix(placeholder + 1, "reset")) {
strbuf_addstr(sb, GIT_COLOR_RESET);
return 6;
} else
@@ -1060,11 +1060,11 @@ static size_t parse_padding_placeholder(struct strbuf *sb,
end = strchr(start, ')');
if (!end || end == start)
return 0;
- if (!prefixcmp(start, "trunc)"))
+ if (has_prefix(start, "trunc)"))
c->truncate = trunc_right;
- else if (!prefixcmp(start, "ltrunc)"))
+ else if (has_prefix(start, "ltrunc)"))
c->truncate = trunc_left;
- else if (!prefixcmp(start, "mtrunc)"))
+ else if (has_prefix(start, "mtrunc)"))
c->truncate = trunc_middle;
else
return 0;
@@ -1089,7 +1089,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
/* these are independent of the commit */
switch (placeholder[0]) {
case 'C':
- if (!prefixcmp(placeholder + 1, "(auto)")) {
+ if (has_prefix(placeholder + 1, "(auto)")) {
c->auto_color = 1;
return 7; /* consumed 7 bytes, "C(auto)" */
} else {
@@ -1556,7 +1556,7 @@ static void pp_header(struct pretty_print_context *pp,
continue;
}
- if (!prefixcmp(line, "parent ")) {
+ if (has_prefix(line, "parent ")) {
if (linelen != 48)
die("bad parent line in commit");
continue;
@@ -1580,11 +1580,11 @@ static void pp_header(struct pretty_print_context *pp,
* FULL shows both authors but not dates.
* FULLER shows both authors and dates.
*/
- if (!prefixcmp(line, "author ")) {
+ if (has_prefix(line, "author ")) {
strbuf_grow(sb, linelen + 80);
pp_user_info(pp, "Author", sb, line + 7, encoding);
}
- if (!prefixcmp(line, "committer ") &&
+ if (has_prefix(line, "committer ") &&
(pp->fmt == CMIT_FMT_FULL || pp->fmt == CMIT_FMT_FULLER)) {
strbuf_grow(sb, linelen + 80);
pp_user_info(pp, "Commit", sb, line + 10, encoding);
--
1.8.4.1.566.geca833c
next prev parent reply other threads:[~2013-11-09 7:11 UTC|newest]
Thread overview: 100+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-09 7:05 [PATCH 00/86] replace prefixcmp() with has_prefix() Christian Couder
2013-11-09 7:05 ` [PATCH 01/86] strbuf: add has_prefix() to be used instead of prefixcmp() Christian Couder
2013-11-09 7:05 ` [PATCH 02/86] diff: replace prefixcmd() with has_prefix() Christian Couder
2013-11-09 7:05 ` [PATCH 03/86] fast-import: " Christian Couder
2013-11-09 7:05 ` [PATCH 04/86] remote*: " Christian Couder
2013-11-09 7:05 ` [PATCH 05/86] daemon: " Christian Couder
2013-11-09 7:05 ` Christian Couder [this message]
2013-11-09 7:06 ` [PATCH 07/86] revision: " Christian Couder
2013-11-09 7:06 ` [PATCH 08/86] transport*: " Christian Couder
2013-11-09 7:06 ` [PATCH 09/86] config: " Christian Couder
2013-11-09 7:06 ` [PATCH 10/86] sha1_name: " Christian Couder
2013-11-09 7:06 ` [PATCH 11/86] wt-status: " Christian Couder
2013-11-09 7:06 ` [PATCH 12/86] upload-pack: " Christian Couder
2013-11-09 7:06 ` [PATCH 13/86] test-line-buffer: " Christian Couder
2013-11-09 7:06 ` [PATCH 14/86] parse-options: " Christian Couder
2013-11-09 7:06 ` [PATCH 15/86] fetch-pack: " Christian Couder
2013-11-09 7:06 ` [PATCH 16/86] git: " Christian Couder
2013-11-09 7:06 ` [PATCH 17/86] tag: " Christian Couder
2013-11-09 7:06 ` [PATCH 18/86] sequencer: " Christian Couder
2013-11-09 7:06 ` [PATCH 19/86] commit: " Christian Couder
2013-11-09 7:06 ` [PATCH 20/86] http: " Christian Couder
2013-11-09 7:06 ` [PATCH 21/86] imap-send: " Christian Couder
2013-11-09 7:06 ` [PATCH 22/86] help: " Christian Couder
2013-11-09 7:06 ` [PATCH 23/86] log-tree: " Christian Couder
2013-11-09 7:06 ` [PATCH 24/86] merge-recursive: " Christian Couder
2013-11-09 7:06 ` [PATCH 25/86] notes: " Christian Couder
2013-11-09 7:06 ` [PATCH 26/86] refs: " Christian Couder
2013-11-09 7:06 ` [PATCH 27/86] setup: " Christian Couder
2013-11-09 7:06 ` [PATCH 28/86] bisect: " Christian Couder
2013-11-09 7:06 ` [PATCH 29/86] branch: " Christian Couder
2013-11-09 7:06 ` [PATCH 30/86] http-push: " Christian Couder
2013-11-09 7:06 ` [PATCH 31/86] send-pack: " Christian Couder
2013-11-09 7:06 ` [PATCH 32/86] http-backend: " Christian Couder
2013-11-09 7:06 ` [PATCH 33/86] notes-utils: " Christian Couder
2013-11-09 7:06 ` [PATCH 34/86] pkt-line: " Christian Couder
2013-11-09 7:06 ` [PATCH 35/86] alias: " Christian Couder
2013-11-09 7:06 ` [PATCH 36/86] attr: " Christian Couder
2013-11-09 7:06 ` [PATCH 37/86] connect: " Christian Couder
2013-11-09 7:06 ` [PATCH 38/86] pager: " Christian Couder
2013-11-09 7:06 ` [PATCH 39/86] convert: " Christian Couder
2013-11-09 7:06 ` [PATCH 40/86] environment: " Christian Couder
2013-11-09 7:06 ` [PATCH 41/86] shell: " Christian Couder
2013-11-09 7:06 ` [PATCH 42/86] pathspec: " Christian Couder
2013-11-09 7:06 ` [PATCH 43/86] submodule: " Christian Couder
2013-11-09 7:06 ` [PATCH 44/86] test-string-list: " Christian Couder
2013-11-09 7:06 ` [PATCH 45/86] builtin/apply: " Christian Couder
2013-11-09 7:06 ` [PATCH 46/86] builtin/archive: " Christian Couder
2013-11-09 7:06 ` [PATCH 47/86] builtin/branch: " Christian Couder
2013-11-09 7:06 ` [PATCH 48/86] builtin/checkout: " Christian Couder
2013-11-09 7:06 ` [PATCH 49/86] builtin/clean: " Christian Couder
2013-11-09 7:06 ` [PATCH 50/86] builtin/clone: " Christian Couder
2013-11-09 7:06 ` [PATCH 51/86] builtin/column: " Christian Couder
2013-11-09 7:06 ` [PATCH 52/86] builtin/commit: " Christian Couder
2013-11-09 7:06 ` [PATCH 53/86] builtin/describe: " Christian Couder
2013-11-09 7:06 ` [PATCH 54/86] builtin/fast-export: " Christian Couder
2013-11-09 7:06 ` [PATCH 55/86] builtin/fetch-pack: " Christian Couder
2013-11-09 7:06 ` [PATCH 56/86] builtin/fetch: " Christian Couder
2013-11-09 7:06 ` [PATCH 57/86] builtin/fmt-merge-msg: " Christian Couder
2013-11-09 7:06 ` [PATCH 58/86] builtin/for-each-ref: " Christian Couder
2013-11-09 7:06 ` [PATCH 59/86] builtin/fsck: " Christian Couder
2013-11-09 7:06 ` [PATCH 60/86] builtin/help: " Christian Couder
2013-11-09 7:06 ` [PATCH 61/86] builtin/index-pack: " Christian Couder
2013-11-09 7:06 ` [PATCH 62/86] builtin/init-db: " Christian Couder
2013-11-09 7:06 ` [PATCH 63/86] builtin/log: " Christian Couder
2013-11-09 7:06 ` [PATCH 64/86] builtin/ls-remote: " Christian Couder
2013-11-09 7:06 ` [PATCH 65/86] builtin/mailinfo: " Christian Couder
2013-11-09 7:06 ` [PATCH 66/86] builtin/merge-recursive: " Christian Couder
2013-11-09 7:07 ` [PATCH 67/86] builtin/merge: " Christian Couder
2013-11-09 7:07 ` [PATCH 68/86] builtin/name-rev: " Christian Couder
2013-11-09 7:07 ` [PATCH 69/86] builtin/notes: " Christian Couder
2013-11-09 7:07 ` [PATCH 70/86] builtin/pack-objects: " Christian Couder
2013-11-09 7:07 ` [PATCH 71/86] builtin/prune: " Christian Couder
2013-11-09 7:07 ` [PATCH 72/86] builtin/receive-pack: " Christian Couder
2013-11-09 7:07 ` [PATCH 73/86] builtin/reflog: " Christian Couder
2013-11-09 7:07 ` [PATCH 74/86] builtin/remote: " Christian Couder
2013-11-09 7:07 ` [PATCH 75/86] builtin/rev-parse: " Christian Couder
2013-11-09 7:07 ` [PATCH 76/86] builtin/send-pack: " Christian Couder
2013-11-09 7:07 ` [PATCH 77/86] builtin/shortlog: " Christian Couder
2013-11-09 7:07 ` [PATCH 78/86] builtin/show-branch: " Christian Couder
2013-11-09 7:07 ` [PATCH 79/86] builtin/show-ref: " Christian Couder
2013-11-09 7:07 ` [PATCH 80/86] builtin/symbolic-ref: " Christian Couder
2013-11-09 7:07 ` [PATCH 81/86] builtin/tag: " Christian Couder
2013-11-09 7:07 ` [PATCH 82/86] builtin/tar-tree: " Christian Couder
2013-11-09 7:07 ` [PATCH 83/86] builtin/unpack-objects: " Christian Couder
2013-11-09 7:07 ` [PATCH 84/86] builtin/update-ref: " Christian Couder
2013-11-09 7:07 ` [PATCH 85/86] builtin/upload-archive: " Christian Couder
2013-11-09 7:07 ` [PATCH 86/86] strbuf: remove prefixcmp() as it has been replaced " Christian Couder
2013-11-09 14:24 ` [PATCH 00/86] replace prefixcmp() " Thomas Rast
2013-11-12 6:16 ` Christian Couder
2013-11-11 16:09 ` Andreas Ericsson
2013-11-12 8:32 ` Jeff King
2013-11-12 16:53 ` Junio C Hamano
2013-11-12 20:14 ` Jeff King
2013-11-12 20:43 ` Christian Couder
2013-11-12 21:26 ` Junio C Hamano
2013-11-13 6:47 ` Christian Couder
2013-11-13 7:17 ` Jeff King
2013-11-17 8:52 ` Christian Couder
2013-11-18 10:42 ` Christian Couder
2013-11-19 21:42 ` Junio C Hamano
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=20131109070720.18178.27578.chriscool@tuxfamily.org \
--to=chriscool@tuxfamily.org \
--cc=Johannes.Schindelin@gmx.de \
--cc=apenwarr@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=max@quendi.de \
--cc=peff@peff.net \
/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).