{"thread":{"id":"35313","subject":"[PATCH 01/86] strbuf: add has_prefix() to be used instead of prefixcmp()","startedAt":"2013-11-09T07:05:53Z","lastAt":"2013-11-19T21:42:29Z","messageCount":100,"participants":["Christian Couder","Thomas Rast","Andreas Ericsson","Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":86},"messages":[{"id":"230314","messageId":"20131109070358.18178.40248.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":null,"subject":"[PATCH 00/86] replace prefixcmp() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:05:53Z","receivedAt":"2013-11-09T07:05:53Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Here is a big patch series to replace prefixcmp() with a new\nhas_prefix() function.\n\nSo the first patch of this series introduces has_prefix()\nand the last patch removes prefixcmp().\n\nExcept in a few cases, I used a script that does basically\nthe following to generate the commits in between:\n\n===\n#!/bin/bash\n\nperl -pi -e 's/!prefixcmp\\(/has_prefix\\(/g' \"$1\"\nperl -pi -e 's/prefixcmp\\(/!has_prefix\\(/g' \"$1\"\n\ngit commit -m \"$1: replace prefixcmd() with has_prefix()\" \"$1\"\n===\n\nThe few special cases are the following ones:\n\n        - remote*: replace prefixcmd() with has_prefix()\n        - transport*: replace prefixcmd() with has_prefix()\n        - environment: replace prefixcmd() with has_prefix()\n\nIn first 2 cases above, I processed a few files at the same\ntime instead of just one.\n\nIn the case of \"environment\", I removed \" != 0\" after\n\"!has_prefix(...)\" as it is not necessary and makes it\nmore difficult to understand the logic.\n\nOf course it's possible to squash many of the commits\ntogether if it is prefered.\n\nChristian Couder (86):\n  strbuf: add has_prefix() to be used instead of prefixcmp()\n  diff: replace prefixcmd() with has_prefix()\n  fast-import: replace prefixcmd() with has_prefix()\n  remote*: replace prefixcmd() with has_prefix()\n  daemon: replace prefixcmd() with has_prefix()\n  pretty: replace prefixcmd() with has_prefix()\n  revision: replace prefixcmd() with has_prefix()\n  transport*: replace prefixcmd() with has_prefix()\n  config: replace prefixcmd() with has_prefix()\n  sha1_name: replace prefixcmd() with has_prefix()\n  wt-status: replace prefixcmd() with has_prefix()\n  upload-pack: replace prefixcmd() with has_prefix()\n  test-line-buffer: replace prefixcmd() with has_prefix()\n  parse-options: replace prefixcmd() with has_prefix()\n  fetch-pack: replace prefixcmd() with has_prefix()\n  git: replace prefixcmd() with has_prefix()\n  tag: replace prefixcmd() with has_prefix()\n  sequencer: replace prefixcmd() with has_prefix()\n  commit: replace prefixcmd() with has_prefix()\n  http: replace prefixcmd() with has_prefix()\n  imap-send: replace prefixcmd() with has_prefix()\n  help: replace prefixcmd() with has_prefix()\n  log-tree: replace prefixcmd() with has_prefix()\n  merge-recursive: replace prefixcmd() with has_prefix()\n  notes: replace prefixcmd() with has_prefix()\n  refs: replace prefixcmd() with has_prefix()\n  setup: replace prefixcmd() with has_prefix()\n  bisect: replace prefixcmd() with has_prefix()\n  branch: replace prefixcmd() with has_prefix()\n  http-push: replace prefixcmd() with has_prefix()\n  send-pack: replace prefixcmd() with has_prefix()\n  http-backend: replace prefixcmd() with has_prefix()\n  notes-utils: replace prefixcmd() with has_prefix()\n  pkt-line: replace prefixcmd() with has_prefix()\n  alias: replace prefixcmd() with has_prefix()\n  attr: replace prefixcmd() with has_prefix()\n  connect: replace prefixcmd() with has_prefix()\n  pager: replace prefixcmd() with has_prefix()\n  convert: replace prefixcmd() with has_prefix()\n  environment: replace prefixcmd() with has_prefix()\n  shell: replace prefixcmd() with has_prefix()\n  pathspec: replace prefixcmd() with has_prefix()\n  submodule: replace prefixcmd() with has_prefix()\n  test-string-list: replace prefixcmd() with has_prefix()\n  builtin/apply: replace prefixcmd() with has_prefix()\n  builtin/archive: replace prefixcmd() with has_prefix()\n  builtin/branch: replace prefixcmd() with has_prefix()\n  builtin/checkout: replace prefixcmd() with has_prefix()\n  builtin/clean: replace prefixcmd() with has_prefix()\n  builtin/clone: replace prefixcmd() with has_prefix()\n  builtin/column: replace prefixcmd() with has_prefix()\n  builtin/commit: replace prefixcmd() with has_prefix()\n  builtin/describe: replace prefixcmd() with has_prefix()\n  builtin/fast-export: replace prefixcmd() with has_prefix()\n  builtin/fetch-pack: replace prefixcmd() with has_prefix()\n  builtin/fetch: replace prefixcmd() with has_prefix()\n  builtin/fmt-merge-msg: replace prefixcmd() with has_prefix()\n  builtin/for-each-ref: replace prefixcmd() with has_prefix()\n  builtin/fsck: replace prefixcmd() with has_prefix()\n  builtin/help: replace prefixcmd() with has_prefix()\n  builtin/index-pack: replace prefixcmd() with has_prefix()\n  builtin/init-db: replace prefixcmd() with has_prefix()\n  builtin/log: replace prefixcmd() with has_prefix()\n  builtin/ls-remote: replace prefixcmd() with has_prefix()\n  builtin/mailinfo: replace prefixcmd() with has_prefix()\n  builtin/merge-recursive: replace prefixcmd() with has_prefix()\n  builtin/merge: replace prefixcmd() with has_prefix()\n  builtin/name-rev: replace prefixcmd() with has_prefix()\n  builtin/notes: replace prefixcmd() with has_prefix()\n  builtin/pack-objects: replace prefixcmd() with has_prefix()\n  builtin/prune: replace prefixcmd() with has_prefix()\n  builtin/receive-pack: replace prefixcmd() with has_prefix()\n  builtin/reflog: replace prefixcmd() with has_prefix()\n  builtin/remote: replace prefixcmd() with has_prefix()\n  builtin/rev-parse: replace prefixcmd() with has_prefix()\n  builtin/send-pack: replace prefixcmd() with has_prefix()\n  builtin/shortlog: replace prefixcmd() with has_prefix()\n  builtin/show-branch: replace prefixcmd() with has_prefix()\n  builtin/show-ref: replace prefixcmd() with has_prefix()\n  builtin/symbolic-ref: replace prefixcmd() with has_prefix()\n  builtin/tag: replace prefixcmd() with has_prefix()\n  builtin/tar-tree: replace prefixcmd() with has_prefix()\n  builtin/unpack-objects: replace prefixcmd() with has_prefix()\n  builtin/update-ref: replace prefixcmd() with has_prefix()\n  builtin/upload-archive: replace prefixcmd() with has_prefix()\n  strbuf: remove prefixcmp() as it has been replaced with has_prefix()\n\n alias.c                   |  2 +-\n attr.c                    |  2 +-\n bisect.c                  |  4 +--\n branch.c                  |  4 +--\n builtin/apply.c           | 12 +++----\n builtin/archive.c         |  4 +--\n builtin/branch.c          |  6 ++--\n builtin/checkout.c        |  8 ++---\n builtin/clean.c           |  4 +--\n builtin/clone.c           |  6 ++--\n builtin/column.c          |  2 +-\n builtin/commit.c          | 10 +++---\n builtin/describe.c        |  2 +-\n builtin/fast-export.c     |  2 +-\n builtin/fetch-pack.c      |  6 ++--\n builtin/fetch.c           | 16 +++++-----\n builtin/fmt-merge-msg.c   | 10 +++---\n builtin/for-each-ref.c    | 14 ++++-----\n builtin/fsck.c            |  6 ++--\n builtin/help.c            |  8 ++---\n builtin/index-pack.c      |  8 ++---\n builtin/init-db.c         |  2 +-\n builtin/log.c             |  8 ++---\n builtin/ls-remote.c       |  4 +--\n builtin/mailinfo.c        | 16 +++++-----\n builtin/merge-recursive.c |  2 +-\n builtin/merge.c           | 12 +++----\n builtin/name-rev.c        |  6 ++--\n builtin/notes.c           |  2 +-\n builtin/pack-objects.c    |  2 +-\n builtin/prune.c           |  4 +--\n builtin/receive-pack.c    |  6 ++--\n builtin/reflog.c          |  4 +--\n builtin/remote.c          |  8 ++---\n builtin/rev-parse.c       | 24 +++++++-------\n builtin/send-pack.c       |  8 ++---\n builtin/shortlog.c        |  6 ++--\n builtin/show-branch.c     | 20 ++++++------\n builtin/show-ref.c        |  6 ++--\n builtin/symbolic-ref.c    |  2 +-\n builtin/tag.c             |  2 +-\n builtin/tar-tree.c        |  2 +-\n builtin/unpack-objects.c  |  2 +-\n builtin/update-ref.c      | 10 +++---\n builtin/upload-archive.c  |  2 +-\n commit.c                  |  6 ++--\n config.c                  | 16 +++++-----\n connect.c                 |  2 +-\n convert.c                 |  2 +-\n daemon.c                  | 40 ++++++++++++------------\n diff.c                    | 56 ++++++++++++++++-----------------\n environment.c             |  2 +-\n fast-import.c             | 80 +++++++++++++++++++++++------------------------\n fetch-pack.c              | 12 +++----\n git-compat-util.h         |  2 +-\n git.c                     | 12 +++----\n help.c                    |  8 ++---\n http-backend.c            |  4 +--\n http-push.c               |  4 +--\n http.c                    |  8 ++---\n imap-send.c               | 10 +++---\n log-tree.c                |  8 ++---\n merge-recursive.c         |  6 ++--\n notes-utils.c             |  4 +--\n notes.c                   |  8 ++---\n pager.c                   |  2 +-\n parse-options.c           | 12 +++----\n pathspec.c                |  2 +-\n pkt-line.c                |  4 +--\n pretty.c                  | 36 ++++++++++-----------\n refs.c                    | 30 +++++++++---------\n remote-curl.c             | 14 ++++-----\n remote-testsvn.c          | 10 +++---\n remote.c                  | 46 +++++++++++++--------------\n revision.c                | 38 +++++++++++-----------\n send-pack.c               |  4 +--\n sequencer.c               |  8 ++---\n setup.c                   |  4 +--\n sha1_name.c               | 16 +++++-----\n shell.c                   |  2 +-\n strbuf.c                  |  6 ++--\n submodule.c               |  2 +-\n tag.c                     | 10 +++---\n test-line-buffer.c        |  6 ++--\n test-string-list.c        |  2 +-\n transport-helper.c        | 16 +++++-----\n transport.c               | 28 ++++++++---------\n upload-pack.c             | 10 +++---\n wt-status.c               | 16 +++++-----\n 89 files changed, 455 insertions(+), 455 deletions(-)\n\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230265","messageId":"20131109070720.18178.71603.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 01/86] strbuf: add has_prefix() to be used instead of prefixcmp()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:05:54Z","receivedAt":"2013-11-09T07:05:54Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"prefixcmp() cannot be really used as a comparison function as\nit is not antisymmetric:\n\n\tprefixcmp(\"foo\", \"foobar\") < 0\n\tprefixcmp(\"foobar\", \"foo\") == 0\n\nSo it is not suitable as a function for passing to qsort.\nAnd in fact it is used nowhere as a comparison function.\n\nSo we should replace it with a function that just checks for\nequality.\n\nAs a first step toward this goal, this patch introduces\nhas_prefix().\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n git-compat-util.h | 1 +\n strbuf.c          | 9 +++++++++\n 2 files changed, 10 insertions(+)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 0f6a31e..7930f49 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -351,6 +351,7 @@ extern void set_error_routine(void (*routine)(const char *err, va_list params));\n extern void set_die_is_recursing_routine(int (*routine)(void));\n \n extern int prefixcmp(const char *str, const char *prefix);\n+extern int has_prefix(const char *str, const char *prefix);\n extern int has_suffix(const char *str, const char *suffix);\n \n static inline const char *skip_prefix(const char *str, const char *prefix)\ndiff --git a/strbuf.c b/strbuf.c\nindex 0d784b5..748be6d 100644\n--- a/strbuf.c\n+++ b/strbuf.c\n@@ -10,6 +10,15 @@ int prefixcmp(const char *str, const char *prefix)\n \t\t\treturn (unsigned char)*prefix - (unsigned char)*str;\n }\n \n+int has_prefix(const char *str, const char *prefix)\n+{\n+\tfor (; ; str++, prefix++)\n+\t\tif (!*prefix)\n+\t\t\treturn 1;\n+\t\telse if (*str != *prefix)\n+\t\t\treturn 0;\n+}\n+\n int has_suffix(const char *str, const char *suffix)\n {\n \tint len = strlen(str), suflen = strlen(suffix);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230322","messageId":"20131109070720.18178.51034.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 02/86] diff: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:05:55Z","receivedAt":"2013-11-09T07:05:55Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n diff.c | 56 ++++++++++++++++++++++++++++----------------------------\n 1 file changed, 28 insertions(+), 28 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex a04a34d..b42523a 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -235,7 +235,7 @@ int git_diff_basic_config(const char *var, const char *value, void *cb)\n \tif (userdiff_config(var, value) < 0)\n \t\treturn -1;\n \n-\tif (!prefixcmp(var, \"diff.color.\") || !prefixcmp(var, \"color.diff.\")) {\n+\tif (has_prefix(var, \"diff.color.\") || has_prefix(var, \"color.diff.\")) {\n \t\tint slot = parse_diff_color_slot(var, 11);\n \t\tif (slot < 0)\n \t\t\treturn 0;\n@@ -264,7 +264,7 @@ int git_diff_basic_config(const char *var, const char *value, void *cb)\n \t\treturn 0;\n \t}\n \n-\tif (!prefixcmp(var, \"submodule.\"))\n+\tif (has_prefix(var, \"submodule.\"))\n \t\treturn parse_submodule_config_option(var, value);\n \n \treturn git_default_config(var, value, cb);\n@@ -1215,7 +1215,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n \t\t\tdiff_words_append(line, len,\n \t\t\t\t\t  &ecbdata->diff_words->plus);\n \t\t\treturn;\n-\t\t} else if (!prefixcmp(line, \"\\\\ \")) {\n+\t\t} else if (has_prefix(line, \"\\\\ \")) {\n \t\t\t/*\n \t\t\t * Eat the \"no newline at eof\" marker as if we\n \t\t\t * saw a \"+\" or \"-\" line with nothing on it,\n@@ -2387,9 +2387,9 @@ static void builtin_diff(const char *name_a,\n \t\t\txdiff_set_find_func(&xecfg, pe->pattern, pe->cflags);\n \t\tif (!diffopts)\n \t\t\t;\n-\t\telse if (!prefixcmp(diffopts, \"--unified=\"))\n+\t\telse if (has_prefix(diffopts, \"--unified=\"))\n \t\t\txecfg.ctxlen = strtoul(diffopts + 10, NULL, 10);\n-\t\telse if (!prefixcmp(diffopts, \"-u\"))\n+\t\telse if (has_prefix(diffopts, \"-u\"))\n \t\t\txecfg.ctxlen = strtoul(diffopts + 2, NULL, 10);\n \t\tif (o->word_diff)\n \t\t\tinit_diff_words_data(&ecbdata, o, one, two);\n@@ -3388,7 +3388,7 @@ int parse_long_opt(const char *opt, const char **argv,\n \tif (arg[0] != '-' || arg[1] != '-')\n \t\treturn 0;\n \targ += strlen(\"--\");\n-\tif (prefixcmp(arg, opt))\n+\tif (!has_prefix(arg, opt))\n \t\treturn 0;\n \targ += strlen(opt);\n \tif (*arg == '=') { /* sticked form: --option=value */\n@@ -3419,7 +3419,7 @@ static int stat_opt(struct diff_options *options, const char **av)\n \n \tswitch (*arg) {\n \tcase '-':\n-\t\tif (!prefixcmp(arg, \"-width\")) {\n+\t\tif (has_prefix(arg, \"-width\")) {\n \t\t\targ += strlen(\"-width\");\n \t\t\tif (*arg == '=')\n \t\t\t\twidth = strtoul(arg + 1, &end, 10);\n@@ -3429,7 +3429,7 @@ static int stat_opt(struct diff_options *options, const char **av)\n \t\t\t\twidth = strtoul(av[1], &end, 10);\n \t\t\t\targcount = 2;\n \t\t\t}\n-\t\t} else if (!prefixcmp(arg, \"-name-width\")) {\n+\t\t} else if (has_prefix(arg, \"-name-width\")) {\n \t\t\targ += strlen(\"-name-width\");\n \t\t\tif (*arg == '=')\n \t\t\t\tname_width = strtoul(arg + 1, &end, 10);\n@@ -3439,7 +3439,7 @@ static int stat_opt(struct diff_options *options, const char **av)\n \t\t\t\tname_width = strtoul(av[1], &end, 10);\n \t\t\t\targcount = 2;\n \t\t\t}\n-\t\t} else if (!prefixcmp(arg, \"-graph-width\")) {\n+\t\t} else if (has_prefix(arg, \"-graph-width\")) {\n \t\t\targ += strlen(\"-graph-width\");\n \t\t\tif (*arg == '=')\n \t\t\t\tgraph_width = strtoul(arg + 1, &end, 10);\n@@ -3449,7 +3449,7 @@ static int stat_opt(struct diff_options *options, const char **av)\n \t\t\t\tgraph_width = strtoul(av[1], &end, 10);\n \t\t\t\targcount = 2;\n \t\t\t}\n-\t\t} else if (!prefixcmp(arg, \"-count\")) {\n+\t\t} else if (has_prefix(arg, \"-count\")) {\n \t\t\targ += strlen(\"-count\");\n \t\t\tif (*arg == '=')\n \t\t\t\tcount = strtoul(arg + 1, &end, 10);\n@@ -3611,15 +3611,15 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\toptions->output_format |= DIFF_FORMAT_SHORTSTAT;\n \telse if (!strcmp(arg, \"-X\") || !strcmp(arg, \"--dirstat\"))\n \t\treturn parse_dirstat_opt(options, \"\");\n-\telse if (!prefixcmp(arg, \"-X\"))\n+\telse if (has_prefix(arg, \"-X\"))\n \t\treturn parse_dirstat_opt(options, arg + 2);\n-\telse if (!prefixcmp(arg, \"--dirstat=\"))\n+\telse if (has_prefix(arg, \"--dirstat=\"))\n \t\treturn parse_dirstat_opt(options, arg + 10);\n \telse if (!strcmp(arg, \"--cumulative\"))\n \t\treturn parse_dirstat_opt(options, \"cumulative\");\n \telse if (!strcmp(arg, \"--dirstat-by-file\"))\n \t\treturn parse_dirstat_opt(options, \"files\");\n-\telse if (!prefixcmp(arg, \"--dirstat-by-file=\")) {\n+\telse if (has_prefix(arg, \"--dirstat-by-file=\")) {\n \t\tparse_dirstat_opt(options, \"files\");\n \t\treturn parse_dirstat_opt(options, arg + 18);\n \t}\n@@ -3636,17 +3636,17 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\toptions->output_format |= DIFF_FORMAT_NAME_STATUS;\n \telse if (!strcmp(arg, \"-s\") || !strcmp(arg, \"--no-patch\"))\n \t\toptions->output_format |= DIFF_FORMAT_NO_OUTPUT;\n-\telse if (!prefixcmp(arg, \"--stat\"))\n+\telse if (has_prefix(arg, \"--stat\"))\n \t\t/* --stat, --stat-width, --stat-name-width, or --stat-count */\n \t\treturn stat_opt(options, av);\n \n \t/* renames options */\n-\telse if (!prefixcmp(arg, \"-B\") || !prefixcmp(arg, \"--break-rewrites=\") ||\n+\telse if (has_prefix(arg, \"-B\") || has_prefix(arg, \"--break-rewrites=\") ||\n \t\t !strcmp(arg, \"--break-rewrites\")) {\n \t\tif ((options->break_opt = diff_scoreopt_parse(arg)) == -1)\n \t\t\treturn error(\"invalid argument to -B: %s\", arg+2);\n \t}\n-\telse if (!prefixcmp(arg, \"-M\") || !prefixcmp(arg, \"--find-renames=\") ||\n+\telse if (has_prefix(arg, \"-M\") || has_prefix(arg, \"--find-renames=\") ||\n \t\t !strcmp(arg, \"--find-renames\")) {\n \t\tif ((options->rename_score = diff_scoreopt_parse(arg)) == -1)\n \t\t\treturn error(\"invalid argument to -M: %s\", arg+2);\n@@ -3655,7 +3655,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \telse if (!strcmp(arg, \"-D\") || !strcmp(arg, \"--irreversible-delete\")) {\n \t\toptions->irreversible_delete = 1;\n \t}\n-\telse if (!prefixcmp(arg, \"-C\") || !prefixcmp(arg, \"--find-copies=\") ||\n+\telse if (has_prefix(arg, \"-C\") || has_prefix(arg, \"--find-copies=\") ||\n \t\t !strcmp(arg, \"--find-copies\")) {\n \t\tif (options->detect_rename == DIFF_DETECT_COPY)\n \t\t\tDIFF_OPT_SET(options, FIND_COPIES_HARDER);\n@@ -3671,7 +3671,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\tDIFF_OPT_CLR(options, RENAME_EMPTY);\n \telse if (!strcmp(arg, \"--relative\"))\n \t\tDIFF_OPT_SET(options, RELATIVE_NAME);\n-\telse if (!prefixcmp(arg, \"--relative=\")) {\n+\telse if (has_prefix(arg, \"--relative=\")) {\n \t\tDIFF_OPT_SET(options, RELATIVE_NAME);\n \t\toptions->prefix = arg + 11;\n \t}\n@@ -3724,7 +3724,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\tDIFF_OPT_CLR(options, FOLLOW_RENAMES);\n \telse if (!strcmp(arg, \"--color\"))\n \t\toptions->use_color = 1;\n-\telse if (!prefixcmp(arg, \"--color=\")) {\n+\telse if (has_prefix(arg, \"--color=\")) {\n \t\tint value = git_config_colorbool(NULL, arg+8);\n \t\tif (value < 0)\n \t\t\treturn error(\"option `color' expects \\\"always\\\", \\\"auto\\\", or \\\"never\\\"\");\n@@ -3736,7 +3736,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\toptions->use_color = 1;\n \t\toptions->word_diff = DIFF_WORDS_COLOR;\n \t}\n-\telse if (!prefixcmp(arg, \"--color-words=\")) {\n+\telse if (has_prefix(arg, \"--color-words=\")) {\n \t\toptions->use_color = 1;\n \t\toptions->word_diff = DIFF_WORDS_COLOR;\n \t\toptions->word_regex = arg + 14;\n@@ -3745,7 +3745,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\tif (options->word_diff == DIFF_WORDS_NONE)\n \t\t\toptions->word_diff = DIFF_WORDS_PLAIN;\n \t}\n-\telse if (!prefixcmp(arg, \"--word-diff=\")) {\n+\telse if (has_prefix(arg, \"--word-diff=\")) {\n \t\tconst char *type = arg + 12;\n \t\tif (!strcmp(type, \"plain\"))\n \t\t\toptions->word_diff = DIFF_WORDS_PLAIN;\n@@ -3781,12 +3781,12 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \telse if (!strcmp(arg, \"--ignore-submodules\")) {\n \t\tDIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG);\n \t\thandle_ignore_submodules_arg(options, \"all\");\n-\t} else if (!prefixcmp(arg, \"--ignore-submodules=\")) {\n+\t} else if (has_prefix(arg, \"--ignore-submodules=\")) {\n \t\tDIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG);\n \t\thandle_ignore_submodules_arg(options, arg + 20);\n \t} else if (!strcmp(arg, \"--submodule\"))\n \t\tDIFF_OPT_SET(options, SUBMODULE_LOG);\n-\telse if (!prefixcmp(arg, \"--submodule=\"))\n+\telse if (has_prefix(arg, \"--submodule=\"))\n \t\treturn parse_submodule_opt(options, arg + 12);\n \n \t/* misc options */\n@@ -3822,7 +3822,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t}\n \telse if (!strcmp(arg, \"--abbrev\"))\n \t\toptions->abbrev = DEFAULT_ABBREV;\n-\telse if (!prefixcmp(arg, \"--abbrev=\")) {\n+\telse if (has_prefix(arg, \"--abbrev=\")) {\n \t\toptions->abbrev = strtoul(arg + 9, NULL, 10);\n \t\tif (options->abbrev < MINIMUM_ABBREV)\n \t\t\toptions->abbrev = MINIMUM_ABBREV;\n@@ -3904,15 +3904,15 @@ static int diff_scoreopt_parse(const char *opt)\n \tcmd = *opt++;\n \tif (cmd == '-') {\n \t\t/* convert the long-form arguments into short-form versions */\n-\t\tif (!prefixcmp(opt, \"break-rewrites\")) {\n+\t\tif (has_prefix(opt, \"break-rewrites\")) {\n \t\t\topt += strlen(\"break-rewrites\");\n \t\t\tif (*opt == 0 || *opt++ == '=')\n \t\t\t\tcmd = 'B';\n-\t\t} else if (!prefixcmp(opt, \"find-copies\")) {\n+\t\t} else if (has_prefix(opt, \"find-copies\")) {\n \t\t\topt += strlen(\"find-copies\");\n \t\t\tif (*opt == 0 || *opt++ == '=')\n \t\t\t\tcmd = 'C';\n-\t\t} else if (!prefixcmp(opt, \"find-renames\")) {\n+\t\t} else if (has_prefix(opt, \"find-renames\")) {\n \t\t\topt += strlen(\"find-renames\");\n \t\t\tif (*opt == 0 || *opt++ == '=')\n \t\t\t\tcmd = 'M';\n@@ -4322,7 +4322,7 @@ static void patch_id_consume(void *priv, char *line, unsigned long len)\n \tint new_len;\n \n \t/* Ignore line numbers when computing the SHA1 of the patch */\n-\tif (!prefixcmp(line, \"@@ -\"))\n+\tif (has_prefix(line, \"@@ -\"))\n \t\treturn;\n \n \tnew_len = remove_space(line, len);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230320","messageId":"20131109070720.18178.66984.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 03/86] fast-import: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:05:56Z","receivedAt":"2013-11-09T07:05:56Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n fast-import.c | 80 +++++++++++++++++++++++++++++------------------------------\n 1 file changed, 40 insertions(+), 40 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex f4d9969..14f69a1 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -1877,8 +1877,8 @@ static int read_next_command(void)\n \t\t\t\treturn EOF;\n \n \t\t\tif (!seen_data_command\n-\t\t\t\t&& prefixcmp(command_buf.buf, \"feature \")\n-\t\t\t\t&& prefixcmp(command_buf.buf, \"option \")) {\n+\t\t\t\t&& !has_prefix(command_buf.buf, \"feature \")\n+\t\t\t\t&& !has_prefix(command_buf.buf, \"option \")) {\n \t\t\t\tparse_argv();\n \t\t\t}\n \n@@ -1898,7 +1898,7 @@ static int read_next_command(void)\n \t\t\trc->prev->next = rc;\n \t\t\tcmd_tail = rc;\n \t\t}\n-\t\tif (!prefixcmp(command_buf.buf, \"cat-blob \")) {\n+\t\tif (has_prefix(command_buf.buf, \"cat-blob \")) {\n \t\t\tparse_cat_blob();\n \t\t\tcontinue;\n \t\t}\n@@ -1917,7 +1917,7 @@ static void skip_optional_lf(void)\n \n static void parse_mark(void)\n {\n-\tif (!prefixcmp(command_buf.buf, \"mark :\")) {\n+\tif (has_prefix(command_buf.buf, \"mark :\")) {\n \t\tnext_mark = strtoumax(command_buf.buf + 6, NULL, 10);\n \t\tread_next_command();\n \t}\n@@ -1929,10 +1929,10 @@ static int parse_data(struct strbuf *sb, uintmax_t limit, uintmax_t *len_res)\n {\n \tstrbuf_reset(sb);\n \n-\tif (prefixcmp(command_buf.buf, \"data \"))\n+\tif (!has_prefix(command_buf.buf, \"data \"))\n \t\tdie(\"Expected 'data n' command, found: %s\", command_buf.buf);\n \n-\tif (!prefixcmp(command_buf.buf + 5, \"<<\")) {\n+\tif (has_prefix(command_buf.buf + 5, \"<<\")) {\n \t\tchar *term = xstrdup(command_buf.buf + 5 + 2);\n \t\tsize_t term_len = command_buf.len - 5 - 2;\n \n@@ -2306,7 +2306,7 @@ static void file_change_m(struct branch *b)\n \tif (*p == ':') {\n \t\toe = find_mark(parse_mark_ref_space(&p));\n \t\thashcpy(sha1, oe->idx.sha1);\n-\t} else if (!prefixcmp(p, \"inline \")) {\n+\t} else if (has_prefix(p, \"inline \")) {\n \t\tinline_data = 1;\n \t\toe = NULL; /* not used with inline_data, but makes gcc happy */\n \t\tp += strlen(\"inline\");  /* advance to space */\n@@ -2479,7 +2479,7 @@ static void note_change_n(struct branch *b, unsigned char *old_fanout)\n \tif (*p == ':') {\n \t\toe = find_mark(parse_mark_ref_space(&p));\n \t\thashcpy(sha1, oe->idx.sha1);\n-\t} else if (!prefixcmp(p, \"inline \")) {\n+\t} else if (has_prefix(p, \"inline \")) {\n \t\tinline_data = 1;\n \t\toe = NULL; /* not used with inline_data, but makes gcc happy */\n \t\tp += strlen(\"inline\");  /* advance to space */\n@@ -2590,7 +2590,7 @@ static int parse_from(struct branch *b)\n \tconst char *from;\n \tstruct branch *s;\n \n-\tif (prefixcmp(command_buf.buf, \"from \"))\n+\tif (!has_prefix(command_buf.buf, \"from \"))\n \t\treturn 0;\n \n \tif (b->branch_tree.tree) {\n@@ -2636,7 +2636,7 @@ static struct hash_list *parse_merge(unsigned int *count)\n \tstruct branch *s;\n \n \t*count = 0;\n-\twhile (!prefixcmp(command_buf.buf, \"merge \")) {\n+\twhile (has_prefix(command_buf.buf, \"merge \")) {\n \t\tfrom = strchr(command_buf.buf, ' ') + 1;\n \t\tn = xmalloc(sizeof(*n));\n \t\ts = lookup_branch(from);\n@@ -2687,11 +2687,11 @@ static void parse_new_commit(void)\n \n \tread_next_command();\n \tparse_mark();\n-\tif (!prefixcmp(command_buf.buf, \"author \")) {\n+\tif (has_prefix(command_buf.buf, \"author \")) {\n \t\tauthor = parse_ident(command_buf.buf + 7);\n \t\tread_next_command();\n \t}\n-\tif (!prefixcmp(command_buf.buf, \"committer \")) {\n+\tif (has_prefix(command_buf.buf, \"committer \")) {\n \t\tcommitter = parse_ident(command_buf.buf + 10);\n \t\tread_next_command();\n \t}\n@@ -2712,19 +2712,19 @@ static void parse_new_commit(void)\n \n \t/* file_change* */\n \twhile (command_buf.len > 0) {\n-\t\tif (!prefixcmp(command_buf.buf, \"M \"))\n+\t\tif (has_prefix(command_buf.buf, \"M \"))\n \t\t\tfile_change_m(b);\n-\t\telse if (!prefixcmp(command_buf.buf, \"D \"))\n+\t\telse if (has_prefix(command_buf.buf, \"D \"))\n \t\t\tfile_change_d(b);\n-\t\telse if (!prefixcmp(command_buf.buf, \"R \"))\n+\t\telse if (has_prefix(command_buf.buf, \"R \"))\n \t\t\tfile_change_cr(b, 1);\n-\t\telse if (!prefixcmp(command_buf.buf, \"C \"))\n+\t\telse if (has_prefix(command_buf.buf, \"C \"))\n \t\t\tfile_change_cr(b, 0);\n-\t\telse if (!prefixcmp(command_buf.buf, \"N \"))\n+\t\telse if (has_prefix(command_buf.buf, \"N \"))\n \t\t\tnote_change_n(b, &prev_fanout);\n \t\telse if (!strcmp(\"deleteall\", command_buf.buf))\n \t\t\tfile_change_deleteall(b);\n-\t\telse if (!prefixcmp(command_buf.buf, \"ls \"))\n+\t\telse if (has_prefix(command_buf.buf, \"ls \"))\n \t\t\tparse_ls(b);\n \t\telse {\n \t\t\tunread_command_buf = 1;\n@@ -2793,7 +2793,7 @@ static void parse_new_tag(void)\n \tread_next_command();\n \n \t/* from ... */\n-\tif (prefixcmp(command_buf.buf, \"from \"))\n+\tif (!has_prefix(command_buf.buf, \"from \"))\n \t\tdie(\"Expected from command, got %s\", command_buf.buf);\n \tfrom = strchr(command_buf.buf, ' ') + 1;\n \ts = lookup_branch(from);\n@@ -2821,7 +2821,7 @@ static void parse_new_tag(void)\n \tread_next_command();\n \n \t/* tagger ... */\n-\tif (!prefixcmp(command_buf.buf, \"tagger \")) {\n+\tif (has_prefix(command_buf.buf, \"tagger \")) {\n \t\ttagger = parse_ident(command_buf.buf + 7);\n \t\tread_next_command();\n \t} else\n@@ -3209,7 +3209,7 @@ static void option_export_pack_edges(const char *edges)\n \n static int parse_one_option(const char *option)\n {\n-\tif (!prefixcmp(option, \"max-pack-size=\")) {\n+\tif (has_prefix(option, \"max-pack-size=\")) {\n \t\tunsigned long v;\n \t\tif (!git_parse_ulong(option + 14, &v))\n \t\t\treturn 0;\n@@ -3221,20 +3221,20 @@ static int parse_one_option(const char *option)\n \t\t\tv = 1024 * 1024;\n \t\t}\n \t\tmax_packsize = v;\n-\t} else if (!prefixcmp(option, \"big-file-threshold=\")) {\n+\t} else if (has_prefix(option, \"big-file-threshold=\")) {\n \t\tunsigned long v;\n \t\tif (!git_parse_ulong(option + 19, &v))\n \t\t\treturn 0;\n \t\tbig_file_threshold = v;\n-\t} else if (!prefixcmp(option, \"depth=\")) {\n+\t} else if (has_prefix(option, \"depth=\")) {\n \t\toption_depth(option + 6);\n-\t} else if (!prefixcmp(option, \"active-branches=\")) {\n+\t} else if (has_prefix(option, \"active-branches=\")) {\n \t\toption_active_branches(option + 16);\n-\t} else if (!prefixcmp(option, \"export-pack-edges=\")) {\n+\t} else if (has_prefix(option, \"export-pack-edges=\")) {\n \t\toption_export_pack_edges(option + 18);\n-\t} else if (!prefixcmp(option, \"quiet\")) {\n+\t} else if (has_prefix(option, \"quiet\")) {\n \t\tshow_stats = 0;\n-\t} else if (!prefixcmp(option, \"stats\")) {\n+\t} else if (has_prefix(option, \"stats\")) {\n \t\tshow_stats = 1;\n \t} else {\n \t\treturn 0;\n@@ -3245,14 +3245,14 @@ static int parse_one_option(const char *option)\n \n static int parse_one_feature(const char *feature, int from_stream)\n {\n-\tif (!prefixcmp(feature, \"date-format=\")) {\n+\tif (has_prefix(feature, \"date-format=\")) {\n \t\toption_date_format(feature + 12);\n-\t} else if (!prefixcmp(feature, \"import-marks=\")) {\n+\t} else if (has_prefix(feature, \"import-marks=\")) {\n \t\toption_import_marks(feature + 13, from_stream, 0);\n-\t} else if (!prefixcmp(feature, \"import-marks-if-exists=\")) {\n+\t} else if (has_prefix(feature, \"import-marks-if-exists=\")) {\n \t\toption_import_marks(feature + strlen(\"import-marks-if-exists=\"),\n \t\t\t\t\tfrom_stream, 1);\n-\t} else if (!prefixcmp(feature, \"export-marks=\")) {\n+\t} else if (has_prefix(feature, \"export-marks=\")) {\n \t\toption_export_marks(feature + 13);\n \t} else if (!strcmp(feature, \"cat-blob\")) {\n \t\t; /* Don't die - this feature is supported */\n@@ -3350,7 +3350,7 @@ static void parse_argv(void)\n \t\tif (parse_one_feature(a + 2, 0))\n \t\t\tcontinue;\n \n-\t\tif (!prefixcmp(a + 2, \"cat-blob-fd=\")) {\n+\t\tif (has_prefix(a + 2, \"cat-blob-fd=\")) {\n \t\t\toption_cat_blob_fd(a + 2 + strlen(\"cat-blob-fd=\"));\n \t\t\tcontinue;\n \t\t}\n@@ -3404,25 +3404,25 @@ int main(int argc, char **argv)\n \twhile (read_next_command() != EOF) {\n \t\tif (!strcmp(\"blob\", command_buf.buf))\n \t\t\tparse_new_blob();\n-\t\telse if (!prefixcmp(command_buf.buf, \"ls \"))\n+\t\telse if (has_prefix(command_buf.buf, \"ls \"))\n \t\t\tparse_ls(NULL);\n-\t\telse if (!prefixcmp(command_buf.buf, \"commit \"))\n+\t\telse if (has_prefix(command_buf.buf, \"commit \"))\n \t\t\tparse_new_commit();\n-\t\telse if (!prefixcmp(command_buf.buf, \"tag \"))\n+\t\telse if (has_prefix(command_buf.buf, \"tag \"))\n \t\t\tparse_new_tag();\n-\t\telse if (!prefixcmp(command_buf.buf, \"reset \"))\n+\t\telse if (has_prefix(command_buf.buf, \"reset \"))\n \t\t\tparse_reset_branch();\n \t\telse if (!strcmp(\"checkpoint\", command_buf.buf))\n \t\t\tparse_checkpoint();\n \t\telse if (!strcmp(\"done\", command_buf.buf))\n \t\t\tbreak;\n-\t\telse if (!prefixcmp(command_buf.buf, \"progress \"))\n+\t\telse if (has_prefix(command_buf.buf, \"progress \"))\n \t\t\tparse_progress();\n-\t\telse if (!prefixcmp(command_buf.buf, \"feature \"))\n+\t\telse if (has_prefix(command_buf.buf, \"feature \"))\n \t\t\tparse_feature();\n-\t\telse if (!prefixcmp(command_buf.buf, \"option git \"))\n+\t\telse if (has_prefix(command_buf.buf, \"option git \"))\n \t\t\tparse_option();\n-\t\telse if (!prefixcmp(command_buf.buf, \"option \"))\n+\t\telse if (has_prefix(command_buf.buf, \"option \"))\n \t\t\t/* ignore non-git options*/;\n \t\telse\n \t\t\tdie(\"Unsupported command: %s\", command_buf.buf);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230321","messageId":"20131109070720.18178.98413.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 04/86] remote*: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:05:57Z","receivedAt":"2013-11-09T07:05:57Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n remote-curl.c    | 14 +++++++-------\n remote-testsvn.c | 10 +++++-----\n remote.c         | 46 +++++++++++++++++++++++-----------------------\n 3 files changed, 35 insertions(+), 35 deletions(-)\n\ndiff --git a/remote-curl.c b/remote-curl.c\nindex b5ebe01..437b863 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -212,7 +212,7 @@ static struct discovery* discover_refs(const char *service, int for_push)\n \tfree_discovery(last);\n \n \tstrbuf_addf(&buffer, \"%sinfo/refs\", url);\n-\tif ((!prefixcmp(url, \"http://\") || !prefixcmp(url, \"https://\")) &&\n+\tif ((has_prefix(url, \"http://\") || has_prefix(url, \"https://\")) &&\n \t     git_env_bool(\"GIT_SMART_HTTP\", 1)) {\n \t\tmaybe_smart = 1;\n \t\tif (!strchr(url, '?'))\n@@ -740,7 +740,7 @@ static void parse_fetch(struct strbuf *buf)\n \tint alloc_heads = 0, nr_heads = 0;\n \n \tdo {\n-\t\tif (!prefixcmp(buf->buf, \"fetch \")) {\n+\t\tif (has_prefix(buf->buf, \"fetch \")) {\n \t\t\tchar *p = buf->buf + strlen(\"fetch \");\n \t\t\tchar *name;\n \t\t\tstruct ref *ref;\n@@ -863,7 +863,7 @@ static void parse_push(struct strbuf *buf)\n \tint alloc_spec = 0, nr_spec = 0, i, ret;\n \n \tdo {\n-\t\tif (!prefixcmp(buf->buf, \"push \")) {\n+\t\tif (has_prefix(buf->buf, \"push \")) {\n \t\t\tALLOC_GROW(specs, nr_spec + 1, alloc_spec);\n \t\t\tspecs[nr_spec++] = xstrdup(buf->buf + 5);\n \t\t}\n@@ -928,19 +928,19 @@ int main(int argc, const char **argv)\n \t\t}\n \t\tif (buf.len == 0)\n \t\t\tbreak;\n-\t\tif (!prefixcmp(buf.buf, \"fetch \")) {\n+\t\tif (has_prefix(buf.buf, \"fetch \")) {\n \t\t\tif (nongit)\n \t\t\t\tdie(\"Fetch attempted without a local repo\");\n \t\t\tparse_fetch(&buf);\n \n-\t\t} else if (!strcmp(buf.buf, \"list\") || !prefixcmp(buf.buf, \"list \")) {\n+\t\t} else if (!strcmp(buf.buf, \"list\") || has_prefix(buf.buf, \"list \")) {\n \t\t\tint for_push = !!strstr(buf.buf + 4, \"for-push\");\n \t\t\toutput_refs(get_refs(for_push));\n \n-\t\t} else if (!prefixcmp(buf.buf, \"push \")) {\n+\t\t} else if (has_prefix(buf.buf, \"push \")) {\n \t\t\tparse_push(&buf);\n \n-\t\t} else if (!prefixcmp(buf.buf, \"option \")) {\n+\t\t} else if (has_prefix(buf.buf, \"option \")) {\n \t\t\tchar *name = buf.buf + strlen(\"option \");\n \t\t\tchar *value = strchr(name, ' ');\n \t\t\tint result;\ndiff --git a/remote-testsvn.c b/remote-testsvn.c\nindex d7cd5d2..7a5d4c8 100644\n--- a/remote-testsvn.c\n+++ b/remote-testsvn.c\n@@ -82,7 +82,7 @@ static int parse_rev_note(const char *msg, struct rev_note *res)\n \t\tlen = end ? end - msg : strlen(msg);\n \n \t\tkey = \"Revision-number: \";\n-\t\tif (!prefixcmp(msg, key)) {\n+\t\tif (has_prefix(msg, key)) {\n \t\t\tlong i;\n \t\t\tchar *end;\n \t\t\tvalue = msg + strlen(key);\n@@ -154,7 +154,7 @@ static void check_or_regenerate_marks(int latestrev)\n \t} else {\n \t\tstrbuf_addf(&sb, \":%d \", latestrev);\n \t\twhile (strbuf_getline(&line, marksfile, '\\n') != EOF) {\n-\t\t\tif (!prefixcmp(line.buf, sb.buf)) {\n+\t\t\tif (has_prefix(line.buf, sb.buf)) {\n \t\t\t\tfound++;\n \t\t\t\tbreak;\n \t\t\t}\n@@ -264,7 +264,7 @@ static int do_command(struct strbuf *line)\n \t\treturn 1;\t/* end of command stream, quit */\n \t}\n \tif (batch_cmd) {\n-\t\tif (prefixcmp(batch_cmd->name, line->buf))\n+\t\tif (!has_prefix(batch_cmd->name, line->buf))\n \t\t\tdie(\"Active %s batch interrupted by %s\", batch_cmd->name, line->buf);\n \t\t/* buffer batch lines */\n \t\tstring_list_append(&batchlines, line->buf);\n@@ -272,7 +272,7 @@ static int do_command(struct strbuf *line)\n \t}\n \n \tfor (p = input_command_list; p->name; p++) {\n-\t\tif (!prefixcmp(line->buf, p->name) && (strlen(p->name) == line->len ||\n+\t\tif (has_prefix(line->buf, p->name) && (strlen(p->name) == line->len ||\n \t\t\t\tline->buf[strlen(p->name)] == ' ')) {\n \t\t\tif (p->batchable) {\n \t\t\t\tbatch_cmd = p;\n@@ -304,7 +304,7 @@ int main(int argc, char **argv)\n \tremote = remote_get(argv[1]);\n \turl_in = (argc == 3) ? argv[2] : remote->url[0];\n \n-\tif (!prefixcmp(url_in, \"file://\")) {\n+\tif (has_prefix(url_in, \"file://\")) {\n \t\tdump_from_file = 1;\n \t\turl = url_decode(url_in + sizeof(\"file://\")-1);\n \t} else {\ndiff --git a/remote.c b/remote.c\nindex e9fedfa..84c0d9f 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -76,7 +76,7 @@ static const char *alias_url(const char *url, struct rewrites *r)\n \t\tif (!r->rewrite[i])\n \t\t\tcontinue;\n \t\tfor (j = 0; j < r->rewrite[i]->instead_of_nr; j++) {\n-\t\t\tif (!prefixcmp(url, r->rewrite[i]->instead_of[j].s) &&\n+\t\t\tif (has_prefix(url, r->rewrite[i]->instead_of[j].s) &&\n \t\t\t    (!longest ||\n \t\t\t     longest->len < r->rewrite[i]->instead_of[j].len)) {\n \t\t\t\tlongest = &(r->rewrite[i]->instead_of[j]);\n@@ -239,13 +239,13 @@ static void read_remotes_file(struct remote *remote)\n \t\tint value_list;\n \t\tchar *s, *p;\n \n-\t\tif (!prefixcmp(buffer, \"URL:\")) {\n+\t\tif (has_prefix(buffer, \"URL:\")) {\n \t\t\tvalue_list = 0;\n \t\t\ts = buffer + 4;\n-\t\t} else if (!prefixcmp(buffer, \"Push:\")) {\n+\t\t} else if (has_prefix(buffer, \"Push:\")) {\n \t\t\tvalue_list = 1;\n \t\t\ts = buffer + 5;\n-\t\t} else if (!prefixcmp(buffer, \"Pull:\")) {\n+\t\t} else if (has_prefix(buffer, \"Pull:\")) {\n \t\t\tvalue_list = 2;\n \t\t\ts = buffer + 5;\n \t\t} else\n@@ -337,7 +337,7 @@ static int handle_config(const char *key, const char *value, void *cb)\n \tconst char *subkey;\n \tstruct remote *remote;\n \tstruct branch *branch;\n-\tif (!prefixcmp(key, \"branch.\")) {\n+\tif (has_prefix(key, \"branch.\")) {\n \t\tname = key + 7;\n \t\tsubkey = strrchr(name, '.');\n \t\tif (!subkey)\n@@ -361,7 +361,7 @@ static int handle_config(const char *key, const char *value, void *cb)\n \t\t}\n \t\treturn 0;\n \t}\n-\tif (!prefixcmp(key, \"url.\")) {\n+\tif (has_prefix(key, \"url.\")) {\n \t\tstruct rewrite *rewrite;\n \t\tname = key + 4;\n \t\tsubkey = strrchr(name, '.');\n@@ -380,7 +380,7 @@ static int handle_config(const char *key, const char *value, void *cb)\n \t\t}\n \t}\n \n-\tif (prefixcmp(key,  \"remote.\"))\n+\tif (!has_prefix(key,  \"remote.\"))\n \t\treturn 0;\n \tname = key + 7;\n \n@@ -487,7 +487,7 @@ static void read_config(void)\n \tcurrent_branch = NULL;\n \thead_ref = resolve_ref_unsafe(\"HEAD\", sha1, 0, &flag);\n \tif (head_ref && (flag & REF_ISSYMREF) &&\n-\t    !prefixcmp(head_ref, \"refs/heads/\")) {\n+\t    has_prefix(head_ref, \"refs/heads/\")) {\n \t\tcurrent_branch =\n \t\t\tmake_branch(head_ref + strlen(\"refs/heads/\"), 0);\n \t}\n@@ -982,8 +982,8 @@ static int count_refspec_match(const char *pattern,\n \t\t */\n \t\tif (namelen != patlen &&\n \t\t    patlen != namelen - 5 &&\n-\t\t    prefixcmp(name, \"refs/heads/\") &&\n-\t\t    prefixcmp(name, \"refs/tags/\")) {\n+\t\t    !has_prefix(name, \"refs/heads/\") &&\n+\t\t    !has_prefix(name, \"refs/tags/\")) {\n \t\t\t/* We want to catch the case where only weak\n \t\t\t * matches are found and there are multiple\n \t\t\t * matches, and where more than one strong\n@@ -1054,9 +1054,9 @@ static char *guess_ref(const char *name, struct ref *peer)\n \tif (!r)\n \t\treturn NULL;\n \n-\tif (!prefixcmp(r, \"refs/heads/\"))\n+\tif (has_prefix(r, \"refs/heads/\"))\n \t\tstrbuf_addstr(&buf, \"refs/heads/\");\n-\telse if (!prefixcmp(r, \"refs/tags/\"))\n+\telse if (has_prefix(r, \"refs/tags/\"))\n \t\tstrbuf_addstr(&buf, \"refs/tags/\");\n \telse\n \t\treturn NULL;\n@@ -1104,7 +1104,7 @@ static int match_explicit(struct ref *src, struct ref *dst,\n \t\tdst_value = resolve_ref_unsafe(matched_src->name, sha1, 1, &flag);\n \t\tif (!dst_value ||\n \t\t    ((flag & REF_ISSYMREF) &&\n-\t\t     prefixcmp(dst_value, \"refs/heads/\")))\n+\t\t     !has_prefix(dst_value, \"refs/heads/\")))\n \t\t\tdie(\"%s cannot be resolved to branch.\",\n \t\t\t    matched_src->name);\n \t}\n@@ -1193,7 +1193,7 @@ static char *get_ref_match(const struct refspec *rs, int rs_nr, const struct ref\n \t\t * including refs outside refs/heads/ hierarchy, but\n \t\t * that does not make much sense these days.\n \t\t */\n-\t\tif (!send_mirror && prefixcmp(ref->name, \"refs/heads/\"))\n+\t\tif (!send_mirror && !has_prefix(ref->name, \"refs/heads/\"))\n \t\t\treturn NULL;\n \t\tname = xstrdup(ref->name);\n \t}\n@@ -1248,7 +1248,7 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds\n \t\t\tadd_to_tips(&sent_tips, ref->peer_ref->new_sha1);\n \t\telse\n \t\t\tadd_to_tips(&sent_tips, ref->old_sha1);\n-\t\tif (!prefixcmp(ref->name, \"refs/tags/\"))\n+\t\tif (has_prefix(ref->name, \"refs/tags/\"))\n \t\t\tstring_list_append(&dst_tag, ref->name);\n \t}\n \tclear_commit_marks_many(sent_tips.nr, sent_tips.tip, TMP_MARK);\n@@ -1257,7 +1257,7 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds\n \n \t/* Collect tags they do not have. */\n \tfor (ref = src; ref; ref = ref->next) {\n-\t\tif (prefixcmp(ref->name, \"refs/tags/\"))\n+\t\tif (!has_prefix(ref->name, \"refs/tags/\"))\n \t\t\tcontinue; /* not a tag */\n \t\tif (string_list_has_string(&dst_tag, ref->name))\n \t\t\tcontinue; /* they already have it */\n@@ -1481,7 +1481,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,\n \t\t */\n \n \t\telse if (!ref->deletion && !is_null_sha1(ref->old_sha1)) {\n-\t\t\tif (!prefixcmp(ref->name, \"refs/tags/\"))\n+\t\t\tif (has_prefix(ref->name, \"refs/tags/\"))\n \t\t\t\treject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;\n \t\t\telse if (!has_sha1_file(ref->old_sha1))\n \t\t\t\treject_reason = REF_STATUS_REJECT_FETCH_FIRST;\n@@ -1607,12 +1607,12 @@ static struct ref *get_local_ref(const char *name)\n \tif (!name || name[0] == '\\0')\n \t\treturn NULL;\n \n-\tif (!prefixcmp(name, \"refs/\"))\n+\tif (has_prefix(name, \"refs/\"))\n \t\treturn alloc_ref(name);\n \n-\tif (!prefixcmp(name, \"heads/\") ||\n-\t    !prefixcmp(name, \"tags/\") ||\n-\t    !prefixcmp(name, \"remotes/\"))\n+\tif (has_prefix(name, \"heads/\") ||\n+\t    has_prefix(name, \"tags/\") ||\n+\t    has_prefix(name, \"remotes/\"))\n \t\treturn alloc_ref_with_prefix(\"refs/\", 5, name);\n \n \treturn alloc_ref_with_prefix(\"refs/heads/\", 11, name);\n@@ -1647,7 +1647,7 @@ int get_fetch_map(const struct ref *remote_refs,\n \n \tfor (rmp = &ref_map; *rmp; ) {\n \t\tif ((*rmp)->peer_ref) {\n-\t\t\tif (prefixcmp((*rmp)->peer_ref->name, \"refs/\") ||\n+\t\t\tif (!has_prefix((*rmp)->peer_ref->name, \"refs/\") ||\n \t\t\t    check_refname_format((*rmp)->peer_ref->name, 0)) {\n \t\t\t\tstruct ref *ignore = *rmp;\n \t\t\t\terror(\"* Ignoring funny ref '%s' locally\",\n@@ -1931,7 +1931,7 @@ struct ref *guess_remote_head(const struct ref *head,\n \t/* Look for another ref that points there */\n \tfor (r = refs; r; r = r->next) {\n \t\tif (r != head &&\n-\t\t    !prefixcmp(r->name, \"refs/heads/\") &&\n+\t\t    has_prefix(r->name, \"refs/heads/\") &&\n \t\t    !hashcmp(r->old_sha1, head->old_sha1)) {\n \t\t\t*tail = copy_ref(r);\n \t\t\ttail = &((*tail)->next);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230323","messageId":"20131109070720.18178.19274.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 05/86] daemon: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:05:58Z","receivedAt":"2013-11-09T07:05:58Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n daemon.c | 40 ++++++++++++++++++++--------------------\n 1 file changed, 20 insertions(+), 20 deletions(-)\n\ndiff --git a/daemon.c b/daemon.c\nindex 34916c5..4b23800 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -235,7 +235,7 @@ static int service_enabled;\n \n static int git_daemon_config(const char *var, const char *value, void *cb)\n {\n-\tif (!prefixcmp(var, \"daemon.\") &&\n+\tif (has_prefix(var, \"daemon.\") &&\n \t    !strcmp(var + 7, service_looking_at->config_name)) {\n \t\tservice_enabled = git_config_bool(var, value);\n \t\treturn 0;\n@@ -633,7 +633,7 @@ static int execute(void)\n \tfor (i = 0; i < ARRAY_SIZE(daemon_service); i++) {\n \t\tstruct daemon_service *s = &(daemon_service[i]);\n \t\tint namelen = strlen(s->name);\n-\t\tif (!prefixcmp(line, \"git-\") &&\n+\t\tif (has_prefix(line, \"git-\") &&\n \t\t    !strncmp(s->name, line + 4, namelen) &&\n \t\t    line[namelen + 4] == ' ') {\n \t\t\t/*\n@@ -1165,11 +1165,11 @@ int main(int argc, char **argv)\n \tfor (i = 1; i < argc; i++) {\n \t\tchar *arg = argv[i];\n \n-\t\tif (!prefixcmp(arg, \"--listen=\")) {\n+\t\tif (has_prefix(arg, \"--listen=\")) {\n \t\t\tstring_list_append(&listen_addr, xstrdup_tolower(arg + 9));\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--port=\")) {\n+\t\tif (has_prefix(arg, \"--port=\")) {\n \t\t\tchar *end;\n \t\t\tunsigned long n;\n \t\t\tn = strtoul(arg+7, &end, 0);\n@@ -1199,19 +1199,19 @@ int main(int argc, char **argv)\n \t\t\texport_all_trees = 1;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--access-hook=\")) {\n+\t\tif (has_prefix(arg, \"--access-hook=\")) {\n \t\t\taccess_hook = arg + 14;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--timeout=\")) {\n+\t\tif (has_prefix(arg, \"--timeout=\")) {\n \t\t\ttimeout = atoi(arg+10);\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--init-timeout=\")) {\n+\t\tif (has_prefix(arg, \"--init-timeout=\")) {\n \t\t\tinit_timeout = atoi(arg+15);\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--max-connections=\")) {\n+\t\tif (has_prefix(arg, \"--max-connections=\")) {\n \t\t\tmax_connections = atoi(arg+18);\n \t\t\tif (max_connections < 0)\n \t\t\t\tmax_connections = 0;\t        /* unlimited */\n@@ -1221,7 +1221,7 @@ int main(int argc, char **argv)\n \t\t\tstrict_paths = 1;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--base-path=\")) {\n+\t\tif (has_prefix(arg, \"--base-path=\")) {\n \t\t\tbase_path = arg+12;\n \t\t\tcontinue;\n \t\t}\n@@ -1229,7 +1229,7 @@ int main(int argc, char **argv)\n \t\t\tbase_path_relaxed = 1;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--interpolated-path=\")) {\n+\t\tif (has_prefix(arg, \"--interpolated-path=\")) {\n \t\t\tinterpolated_path = arg+20;\n \t\t\tcontinue;\n \t\t}\n@@ -1241,11 +1241,11 @@ int main(int argc, char **argv)\n \t\t\tuser_path = \"\";\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--user-path=\")) {\n+\t\tif (has_prefix(arg, \"--user-path=\")) {\n \t\t\tuser_path = arg + 12;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--pid-file=\")) {\n+\t\tif (has_prefix(arg, \"--pid-file=\")) {\n \t\t\tpid_file = arg + 11;\n \t\t\tcontinue;\n \t\t}\n@@ -1254,35 +1254,35 @@ int main(int argc, char **argv)\n \t\t\tlog_syslog = 1;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--user=\")) {\n+\t\tif (has_prefix(arg, \"--user=\")) {\n \t\t\tuser_name = arg + 7;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--group=\")) {\n+\t\tif (has_prefix(arg, \"--group=\")) {\n \t\t\tgroup_name = arg + 8;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--enable=\")) {\n+\t\tif (has_prefix(arg, \"--enable=\")) {\n \t\t\tenable_service(arg + 9, 1);\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--disable=\")) {\n+\t\tif (has_prefix(arg, \"--disable=\")) {\n \t\t\tenable_service(arg + 10, 0);\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--allow-override=\")) {\n+\t\tif (has_prefix(arg, \"--allow-override=\")) {\n \t\t\tmake_service_overridable(arg + 17, 1);\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--forbid-override=\")) {\n+\t\tif (has_prefix(arg, \"--forbid-override=\")) {\n \t\t\tmake_service_overridable(arg + 18, 0);\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--informative-errors\")) {\n+\t\tif (has_prefix(arg, \"--informative-errors\")) {\n \t\t\tinformative_errors = 1;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--no-informative-errors\")) {\n+\t\tif (has_prefix(arg, \"--no-informative-errors\")) {\n \t\t\tinformative_errors = 0;\n \t\t\tcontinue;\n \t\t}\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230319","messageId":"20131109070720.18178.27578.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 06/86] pretty: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:05:59Z","receivedAt":"2013-11-09T07:05:59Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n pretty.c | 36 ++++++++++++++++++------------------\n 1 file changed, 18 insertions(+), 18 deletions(-)\n\ndiff --git a/pretty.c b/pretty.c\nindex b4e32b7..961241a 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -40,7 +40,7 @@ static int git_pretty_formats_config(const char *var, const char *value, void *c\n \tconst char *fmt;\n \tint i;\n \n-\tif (prefixcmp(var, \"pretty.\"))\n+\tif (!has_prefix(var, \"pretty.\"))\n \t\treturn 0;\n \n \tname = var + strlen(\"pretty.\");\n@@ -67,7 +67,7 @@ static int git_pretty_formats_config(const char *var, const char *value, void *c\n \tcommit_format->name = xstrdup(name);\n \tcommit_format->format = CMIT_FMT_USERFORMAT;\n \tgit_config_string(&fmt, var, value);\n-\tif (!prefixcmp(fmt, \"format:\") || !prefixcmp(fmt, \"tformat:\")) {\n+\tif (has_prefix(fmt, \"format:\") || has_prefix(fmt, \"tformat:\")) {\n \t\tcommit_format->is_tformat = fmt[0] == 't';\n \t\tfmt = strchr(fmt, ':') + 1;\n \t} else if (strchr(fmt, '%'))\n@@ -115,7 +115,7 @@ static struct cmt_fmt_map *find_commit_format_recursive(const char *sought,\n \tfor (i = 0; i < commit_formats_len; i++) {\n \t\tsize_t match_len;\n \n-\t\tif (prefixcmp(commit_formats[i].name, sought))\n+\t\tif (!has_prefix(commit_formats[i].name, sought))\n \t\t\tcontinue;\n \n \t\tmatch_len = strlen(commit_formats[i].name);\n@@ -151,7 +151,7 @@ void get_commit_format(const char *arg, struct rev_info *rev)\n \t\trev->commit_format = CMIT_FMT_DEFAULT;\n \t\treturn;\n \t}\n-\tif (!prefixcmp(arg, \"format:\") || !prefixcmp(arg, \"tformat:\")) {\n+\tif (has_prefix(arg, \"format:\") || has_prefix(arg, \"tformat:\")) {\n \t\tsave_user_format(rev, strchr(arg, ':') + 1, arg[0] == 't');\n \t\treturn;\n \t}\n@@ -840,10 +840,10 @@ static void parse_commit_header(struct format_commit_context *context)\n \n \t\tif (i == eol) {\n \t\t\tbreak;\n-\t\t} else if (!prefixcmp(msg + i, \"author \")) {\n+\t\t} else if (has_prefix(msg + i, \"author \")) {\n \t\t\tcontext->author.off = i + 7;\n \t\t\tcontext->author.len = eol - i - 7;\n-\t\t} else if (!prefixcmp(msg + i, \"committer \")) {\n+\t\t} else if (has_prefix(msg + i, \"committer \")) {\n \t\t\tcontext->committer.off = i + 10;\n \t\t\tcontext->committer.len = eol - i - 10;\n \t\t}\n@@ -983,7 +983,7 @@ static size_t parse_color(struct strbuf *sb, /* in UTF-8 */\n \n \t\tif (!end)\n \t\t\treturn 0;\n-\t\tif (!prefixcmp(begin, \"auto,\")) {\n+\t\tif (has_prefix(begin, \"auto,\")) {\n \t\t\tif (!want_color(c->pretty_ctx->color))\n \t\t\t\treturn end - placeholder + 1;\n \t\t\tbegin += 5;\n@@ -994,16 +994,16 @@ static size_t parse_color(struct strbuf *sb, /* in UTF-8 */\n \t\tstrbuf_addstr(sb, color);\n \t\treturn end - placeholder + 1;\n \t}\n-\tif (!prefixcmp(placeholder + 1, \"red\")) {\n+\tif (has_prefix(placeholder + 1, \"red\")) {\n \t\tstrbuf_addstr(sb, GIT_COLOR_RED);\n \t\treturn 4;\n-\t} else if (!prefixcmp(placeholder + 1, \"green\")) {\n+\t} else if (has_prefix(placeholder + 1, \"green\")) {\n \t\tstrbuf_addstr(sb, GIT_COLOR_GREEN);\n \t\treturn 6;\n-\t} else if (!prefixcmp(placeholder + 1, \"blue\")) {\n+\t} else if (has_prefix(placeholder + 1, \"blue\")) {\n \t\tstrbuf_addstr(sb, GIT_COLOR_BLUE);\n \t\treturn 5;\n-\t} else if (!prefixcmp(placeholder + 1, \"reset\")) {\n+\t} else if (has_prefix(placeholder + 1, \"reset\")) {\n \t\tstrbuf_addstr(sb, GIT_COLOR_RESET);\n \t\treturn 6;\n \t} else\n@@ -1060,11 +1060,11 @@ static size_t parse_padding_placeholder(struct strbuf *sb,\n \t\t\tend = strchr(start, ')');\n \t\t\tif (!end || end == start)\n \t\t\t\treturn 0;\n-\t\t\tif (!prefixcmp(start, \"trunc)\"))\n+\t\t\tif (has_prefix(start, \"trunc)\"))\n \t\t\t\tc->truncate = trunc_right;\n-\t\t\telse if (!prefixcmp(start, \"ltrunc)\"))\n+\t\t\telse if (has_prefix(start, \"ltrunc)\"))\n \t\t\t\tc->truncate = trunc_left;\n-\t\t\telse if (!prefixcmp(start, \"mtrunc)\"))\n+\t\t\telse if (has_prefix(start, \"mtrunc)\"))\n \t\t\t\tc->truncate = trunc_middle;\n \t\t\telse\n \t\t\t\treturn 0;\n@@ -1089,7 +1089,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */\n \t/* these are independent of the commit */\n \tswitch (placeholder[0]) {\n \tcase 'C':\n-\t\tif (!prefixcmp(placeholder + 1, \"(auto)\")) {\n+\t\tif (has_prefix(placeholder + 1, \"(auto)\")) {\n \t\t\tc->auto_color = 1;\n \t\t\treturn 7; /* consumed 7 bytes, \"C(auto)\" */\n \t\t} else {\n@@ -1556,7 +1556,7 @@ static void pp_header(struct pretty_print_context *pp,\n \t\t\tcontinue;\n \t\t}\n \n-\t\tif (!prefixcmp(line, \"parent \")) {\n+\t\tif (has_prefix(line, \"parent \")) {\n \t\t\tif (linelen != 48)\n \t\t\t\tdie(\"bad parent line in commit\");\n \t\t\tcontinue;\n@@ -1580,11 +1580,11 @@ static void pp_header(struct pretty_print_context *pp,\n \t\t * FULL shows both authors but not dates.\n \t\t * FULLER shows both authors and dates.\n \t\t */\n-\t\tif (!prefixcmp(line, \"author \")) {\n+\t\tif (has_prefix(line, \"author \")) {\n \t\t\tstrbuf_grow(sb, linelen + 80);\n \t\t\tpp_user_info(pp, \"Author\", sb, line + 7, encoding);\n \t\t}\n-\t\tif (!prefixcmp(line, \"committer \") &&\n+\t\tif (has_prefix(line, \"committer \") &&\n \t\t    (pp->fmt == CMIT_FMT_FULL || pp->fmt == CMIT_FMT_FULLER)) {\n \t\t\tstrbuf_grow(sb, linelen + 80);\n \t\t\tpp_user_info(pp, \"Commit\", sb, line + 10, encoding);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230324","messageId":"20131109070720.18178.44053.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 07/86] revision: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:00Z","receivedAt":"2013-11-09T07:06:00Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n revision.c | 38 +++++++++++++++++++-------------------\n 1 file changed, 19 insertions(+), 19 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex 0173e01..968320a 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1576,9 +1576,9 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t    !strcmp(arg, \"--tags\") || !strcmp(arg, \"--remotes\") ||\n \t    !strcmp(arg, \"--reflog\") || !strcmp(arg, \"--not\") ||\n \t    !strcmp(arg, \"--no-walk\") || !strcmp(arg, \"--do-walk\") ||\n-\t    !strcmp(arg, \"--bisect\") || !prefixcmp(arg, \"--glob=\") ||\n-\t    !prefixcmp(arg, \"--branches=\") || !prefixcmp(arg, \"--tags=\") ||\n-\t    !prefixcmp(arg, \"--remotes=\") || !prefixcmp(arg, \"--no-walk=\"))\n+\t    !strcmp(arg, \"--bisect\") || has_prefix(arg, \"--glob=\") ||\n+\t    has_prefix(arg, \"--branches=\") || has_prefix(arg, \"--tags=\") ||\n+\t    has_prefix(arg, \"--remotes=\") || has_prefix(arg, \"--no-walk=\"))\n \t{\n \t\tunkv[(*unkc)++] = arg;\n \t\treturn 1;\n@@ -1601,7 +1601,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\trevs->max_count = atoi(argv[1]);\n \t\trevs->no_walk = 0;\n \t\treturn 2;\n-\t} else if (!prefixcmp(arg, \"-n\")) {\n+\t} else if (has_prefix(arg, \"-n\")) {\n \t\trevs->max_count = atoi(arg + 2);\n \t\trevs->no_walk = 0;\n \t} else if ((argcount = parse_long_opt(\"max-age\", argv, &optarg))) {\n@@ -1661,7 +1661,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t} else if (!strcmp(arg, \"--author-date-order\")) {\n \t\trevs->sort_order = REV_SORT_BY_AUTHOR_DATE;\n \t\trevs->topo_order = 1;\n-\t} else if (!prefixcmp(arg, \"--early-output\")) {\n+\t} else if (has_prefix(arg, \"--early-output\")) {\n \t\tint count = 100;\n \t\tswitch (arg[14]) {\n \t\tcase '=':\n@@ -1686,13 +1686,13 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\trevs->min_parents = 2;\n \t} else if (!strcmp(arg, \"--no-merges\")) {\n \t\trevs->max_parents = 1;\n-\t} else if (!prefixcmp(arg, \"--min-parents=\")) {\n+\t} else if (has_prefix(arg, \"--min-parents=\")) {\n \t\trevs->min_parents = atoi(arg+14);\n-\t} else if (!prefixcmp(arg, \"--no-min-parents\")) {\n+\t} else if (has_prefix(arg, \"--no-min-parents\")) {\n \t\trevs->min_parents = 0;\n-\t} else if (!prefixcmp(arg, \"--max-parents=\")) {\n+\t} else if (has_prefix(arg, \"--max-parents=\")) {\n \t\trevs->max_parents = atoi(arg+14);\n-\t} else if (!prefixcmp(arg, \"--no-max-parents\")) {\n+\t} else if (has_prefix(arg, \"--no-max-parents\")) {\n \t\trevs->max_parents = -1;\n \t} else if (!strcmp(arg, \"--boundary\")) {\n \t\trevs->boundary = 1;\n@@ -1742,7 +1742,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\trevs->verify_objects = 1;\n \t} else if (!strcmp(arg, \"--unpacked\")) {\n \t\trevs->unpacked = 1;\n-\t} else if (!prefixcmp(arg, \"--unpacked=\")) {\n+\t} else if (has_prefix(arg, \"--unpacked=\")) {\n \t\tdie(\"--unpacked=<packfile> no longer supported.\");\n \t} else if (!strcmp(arg, \"-r\")) {\n \t\trevs->diff = 1;\n@@ -1767,7 +1767,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\trevs->verbose_header = 1;\n \t\trevs->pretty_given = 1;\n \t\tget_commit_format(arg+8, revs);\n-\t} else if (!prefixcmp(arg, \"--pretty=\") || !prefixcmp(arg, \"--format=\")) {\n+\t} else if (has_prefix(arg, \"--pretty=\") || has_prefix(arg, \"--format=\")) {\n \t\t/*\n \t\t * Detached form (\"--pretty X\" as opposed to \"--pretty=X\")\n \t\t * not allowed, since the argument is optional.\n@@ -1781,12 +1781,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\trevs->notes_opt.use_default_notes = 1;\n \t} else if (!strcmp(arg, \"--show-signature\")) {\n \t\trevs->show_signature = 1;\n-\t} else if (!prefixcmp(arg, \"--show-notes=\") ||\n-\t\t   !prefixcmp(arg, \"--notes=\")) {\n+\t} else if (has_prefix(arg, \"--show-notes=\") ||\n+\t\t   has_prefix(arg, \"--notes=\")) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n \t\trevs->show_notes = 1;\n \t\trevs->show_notes_given = 1;\n-\t\tif (!prefixcmp(arg, \"--show-notes\")) {\n+\t\tif (has_prefix(arg, \"--show-notes\")) {\n \t\t\tif (revs->notes_opt.use_default_notes < 0)\n \t\t\t\trevs->notes_opt.use_default_notes = 1;\n \t\t\tstrbuf_addstr(&buf, arg+13);\n@@ -1829,7 +1829,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\trevs->abbrev = 0;\n \t} else if (!strcmp(arg, \"--abbrev\")) {\n \t\trevs->abbrev = DEFAULT_ABBREV;\n-\t} else if (!prefixcmp(arg, \"--abbrev=\")) {\n+\t} else if (has_prefix(arg, \"--abbrev=\")) {\n \t\trevs->abbrev = strtoul(arg + 9, NULL, 10);\n \t\tif (revs->abbrev < MINIMUM_ABBREV)\n \t\t\trevs->abbrev = MINIMUM_ABBREV;\n@@ -1968,15 +1968,15 @@ static int handle_revision_pseudo_opt(const char *submodule,\n \t\tinit_all_refs_cb(&cb, revs, *flags);\n \t\tfor_each_glob_ref(handle_one_ref, optarg, &cb);\n \t\treturn argcount;\n-\t} else if (!prefixcmp(arg, \"--branches=\")) {\n+\t} else if (has_prefix(arg, \"--branches=\")) {\n \t\tstruct all_refs_cb cb;\n \t\tinit_all_refs_cb(&cb, revs, *flags);\n \t\tfor_each_glob_ref_in(handle_one_ref, arg + 11, \"refs/heads/\", &cb);\n-\t} else if (!prefixcmp(arg, \"--tags=\")) {\n+\t} else if (has_prefix(arg, \"--tags=\")) {\n \t\tstruct all_refs_cb cb;\n \t\tinit_all_refs_cb(&cb, revs, *flags);\n \t\tfor_each_glob_ref_in(handle_one_ref, arg + 7, \"refs/tags/\", &cb);\n-\t} else if (!prefixcmp(arg, \"--remotes=\")) {\n+\t} else if (has_prefix(arg, \"--remotes=\")) {\n \t\tstruct all_refs_cb cb;\n \t\tinit_all_refs_cb(&cb, revs, *flags);\n \t\tfor_each_glob_ref_in(handle_one_ref, arg + 10, \"refs/remotes/\", &cb);\n@@ -1986,7 +1986,7 @@ static int handle_revision_pseudo_opt(const char *submodule,\n \t\t*flags ^= UNINTERESTING | BOTTOM;\n \t} else if (!strcmp(arg, \"--no-walk\")) {\n \t\trevs->no_walk = REVISION_WALK_NO_WALK_SORTED;\n-\t} else if (!prefixcmp(arg, \"--no-walk=\")) {\n+\t} else if (has_prefix(arg, \"--no-walk=\")) {\n \t\t/*\n \t\t * Detached form (\"--no-walk X\" as opposed to \"--no-walk=X\")\n \t\t * not allowed, since the argument is optional.\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230318","messageId":"20131109070720.18178.55096.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 08/86] transport*: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:01Z","receivedAt":"2013-11-09T07:06:01Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n transport-helper.c | 16 ++++++++--------\n transport.c        | 28 ++++++++++++++--------------\n 2 files changed, 22 insertions(+), 22 deletions(-)\n\ndiff --git a/transport-helper.c b/transport-helper.c\nindex b32e2d6..bf8d7a0 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -190,7 +190,7 @@ static struct child_process *get_helper(struct transport *transport)\n \t\t\tdata->export = 1;\n \t\telse if (!strcmp(capname, \"check-connectivity\"))\n \t\t\tdata->check_connectivity = 1;\n-\t\telse if (!data->refspecs && !prefixcmp(capname, \"refspec \")) {\n+\t\telse if (!data->refspecs && has_prefix(capname, \"refspec \")) {\n \t\t\tALLOC_GROW(refspecs,\n \t\t\t\t   refspec_nr + 1,\n \t\t\t\t   refspec_alloc);\n@@ -199,17 +199,17 @@ static struct child_process *get_helper(struct transport *transport)\n \t\t\tdata->connect = 1;\n \t\t} else if (!strcmp(capname, \"signed-tags\")) {\n \t\t\tdata->signed_tags = 1;\n-\t\t} else if (!prefixcmp(capname, \"export-marks \")) {\n+\t\t} else if (has_prefix(capname, \"export-marks \")) {\n \t\t\tstruct strbuf arg = STRBUF_INIT;\n \t\t\tstrbuf_addstr(&arg, \"--export-marks=\");\n \t\t\tstrbuf_addstr(&arg, capname + strlen(\"export-marks \"));\n \t\t\tdata->export_marks = strbuf_detach(&arg, NULL);\n-\t\t} else if (!prefixcmp(capname, \"import-marks\")) {\n+\t\t} else if (has_prefix(capname, \"import-marks\")) {\n \t\t\tstruct strbuf arg = STRBUF_INIT;\n \t\t\tstrbuf_addstr(&arg, \"--import-marks=\");\n \t\t\tstrbuf_addstr(&arg, capname + strlen(\"import-marks \"));\n \t\t\tdata->import_marks = strbuf_detach(&arg, NULL);\n-\t\t} else if (!prefixcmp(capname, \"no-private-update\")) {\n+\t\t} else if (has_prefix(capname, \"no-private-update\")) {\n \t\t\tdata->no_private_update = 1;\n \t\t} else if (mandatory) {\n \t\t\tdie(\"Unknown mandatory capability %s. This remote \"\n@@ -310,7 +310,7 @@ static int set_helper_option(struct transport *transport,\n \n \tif (!strcmp(buf.buf, \"ok\"))\n \t\tret = 0;\n-\telse if (!prefixcmp(buf.buf, \"error\")) {\n+\telse if (has_prefix(buf.buf, \"error\")) {\n \t\tret = -1;\n \t} else if (!strcmp(buf.buf, \"unsupported\"))\n \t\tret = 1;\n@@ -374,7 +374,7 @@ static int fetch_with_fetch(struct transport *transport,\n \twhile (1) {\n \t\trecvline(data, &buf);\n \n-\t\tif (!prefixcmp(buf.buf, \"lock \")) {\n+\t\tif (has_prefix(buf.buf, \"lock \")) {\n \t\t\tconst char *name = buf.buf + 5;\n \t\t\tif (transport->pack_lockfile)\n \t\t\t\twarning(\"%s also locked %s\", data->name, name);\n@@ -645,10 +645,10 @@ static int push_update_ref_status(struct strbuf *buf,\n \tchar *refname, *msg;\n \tint status;\n \n-\tif (!prefixcmp(buf->buf, \"ok \")) {\n+\tif (has_prefix(buf->buf, \"ok \")) {\n \t\tstatus = REF_STATUS_OK;\n \t\trefname = buf->buf + 3;\n-\t} else if (!prefixcmp(buf->buf, \"error \")) {\n+\t} else if (has_prefix(buf->buf, \"error \")) {\n \t\tstatus = REF_STATUS_REMOTE_REJECT;\n \t\trefname = buf->buf + 6;\n \t} else\ndiff --git a/transport.c b/transport.c\nindex 7202b77..24b781c 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -169,13 +169,13 @@ static void set_upstreams(struct transport *transport, struct ref *refs,\n \t\tremotename = ref->name;\n \t\ttmp = resolve_ref_unsafe(localname, sha, 1, &flag);\n \t\tif (tmp && flag & REF_ISSYMREF &&\n-\t\t\t!prefixcmp(tmp, \"refs/heads/\"))\n+\t\t\thas_prefix(tmp, \"refs/heads/\"))\n \t\t\tlocalname = tmp;\n \n \t\t/* Both source and destination must be local branches. */\n-\t\tif (!localname || prefixcmp(localname, \"refs/heads/\"))\n+\t\tif (!localname || !has_prefix(localname, \"refs/heads/\"))\n \t\t\tcontinue;\n-\t\tif (!remotename || prefixcmp(remotename, \"refs/heads/\"))\n+\t\tif (!remotename || !has_prefix(remotename, \"refs/heads/\"))\n \t\t\tcontinue;\n \n \t\tif (!pretend)\n@@ -191,7 +191,7 @@ static void set_upstreams(struct transport *transport, struct ref *refs,\n \n static const char *rsync_url(const char *url)\n {\n-\treturn prefixcmp(url, \"rsync://\") ? skip_prefix(url, \"rsync:\") : url;\n+\treturn !has_prefix(url, \"rsync://\") ? skip_prefix(url, \"rsync:\") : url;\n }\n \n static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)\n@@ -296,8 +296,8 @@ static int write_one_ref(const char *name, const unsigned char *sha1,\n \tFILE *f;\n \n \t/* when called via for_each_ref(), flags is non-zero */\n-\tif (flags && prefixcmp(name, \"refs/heads/\") &&\n-\t\t\tprefixcmp(name, \"refs/tags/\"))\n+\tif (flags && !has_prefix(name, \"refs/heads/\") &&\n+\t\t\t!has_prefix(name, \"refs/tags/\"))\n \t\treturn 0;\n \n \tstrbuf_addstr(buf, name);\n@@ -652,7 +652,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)\n \t\tprint_ref_status('-', \"[deleted]\", ref, NULL, NULL, porcelain);\n \telse if (is_null_sha1(ref->old_sha1))\n \t\tprint_ref_status('*',\n-\t\t\t(!prefixcmp(ref->name, \"refs/tags/\") ? \"[new tag]\" :\n+\t\t\t(has_prefix(ref->name, \"refs/tags/\") ? \"[new tag]\" :\n \t\t\t\"[new branch]\"),\n \t\t\tref, ref->peer_ref, NULL, porcelain);\n \telse {\n@@ -930,13 +930,13 @@ struct transport *transport_get(struct remote *remote, const char *url)\n \n \t\twhile (is_urlschemechar(p == url, *p))\n \t\t\tp++;\n-\t\tif (!prefixcmp(p, \"::\"))\n+\t\tif (has_prefix(p, \"::\"))\n \t\t\thelper = xstrndup(url, p - url);\n \t}\n \n \tif (helper) {\n \t\ttransport_helper_init(ret, helper);\n-\t} else if (!prefixcmp(url, \"rsync:\")) {\n+\t} else if (has_prefix(url, \"rsync:\")) {\n \t\tret->get_refs_list = get_refs_via_rsync;\n \t\tret->fetch = fetch_objs_via_rsync;\n \t\tret->push = rsync_transport_push;\n@@ -949,11 +949,11 @@ struct transport *transport_get(struct remote *remote, const char *url)\n \t\tret->disconnect = close_bundle;\n \t\tret->smart_options = NULL;\n \t} else if (!is_url(url)\n-\t\t|| !prefixcmp(url, \"file://\")\n-\t\t|| !prefixcmp(url, \"git://\")\n-\t\t|| !prefixcmp(url, \"ssh://\")\n-\t\t|| !prefixcmp(url, \"git+ssh://\")\n-\t\t|| !prefixcmp(url, \"ssh+git://\")) {\n+\t\t|| has_prefix(url, \"file://\")\n+\t\t|| has_prefix(url, \"git://\")\n+\t\t|| has_prefix(url, \"ssh://\")\n+\t\t|| has_prefix(url, \"git+ssh://\")\n+\t\t|| has_prefix(url, \"ssh+git://\")) {\n \t\t/* These are builtin smart transports. */\n \t\tstruct git_transport_data *data = xcalloc(1, sizeof(*data));\n \t\tret->data = data;\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230317","messageId":"20131109070720.18178.11881.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 09/86] config: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:02Z","receivedAt":"2013-11-09T07:06:02Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n config.c | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/config.c b/config.c\nindex e1d66a1..8d5d70c 100644\n--- a/config.c\n+++ b/config.c\n@@ -969,25 +969,25 @@ static int git_default_mailmap_config(const char *var, const char *value)\n \n int git_default_config(const char *var, const char *value, void *dummy)\n {\n-\tif (!prefixcmp(var, \"core.\"))\n+\tif (has_prefix(var, \"core.\"))\n \t\treturn git_default_core_config(var, value);\n \n-\tif (!prefixcmp(var, \"user.\"))\n+\tif (has_prefix(var, \"user.\"))\n \t\treturn git_ident_config(var, value, dummy);\n \n-\tif (!prefixcmp(var, \"i18n.\"))\n+\tif (has_prefix(var, \"i18n.\"))\n \t\treturn git_default_i18n_config(var, value);\n \n-\tif (!prefixcmp(var, \"branch.\"))\n+\tif (has_prefix(var, \"branch.\"))\n \t\treturn git_default_branch_config(var, value);\n \n-\tif (!prefixcmp(var, \"push.\"))\n+\tif (has_prefix(var, \"push.\"))\n \t\treturn git_default_push_config(var, value);\n \n-\tif (!prefixcmp(var, \"mailmap.\"))\n+\tif (has_prefix(var, \"mailmap.\"))\n \t\treturn git_default_mailmap_config(var, value);\n \n-\tif (!prefixcmp(var, \"advice.\"))\n+\tif (has_prefix(var, \"advice.\"))\n \t\treturn git_default_advice_config(var, value);\n \n \tif (!strcmp(var, \"pager.color\") || !strcmp(var, \"color.pager\")) {\n@@ -1872,7 +1872,7 @@ int parse_config_key(const char *var,\n \tconst char *dot;\n \n \t/* Does it start with \"section.\" ? */\n-\tif (prefixcmp(var, section) || var[section_len] != '.')\n+\tif (!has_prefix(var, section) || var[section_len] != '.')\n \t\treturn -1;\n \n \t/*\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230316","messageId":"20131109070720.18178.85797.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 10/86] sha1_name: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:03Z","receivedAt":"2013-11-09T07:06:03Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n sha1_name.c | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 0e5fe7f..3224a39 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -547,7 +547,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)\n \t\tif (read_ref_at(real_ref, at_time, nth, sha1, NULL,\n \t\t\t\t&co_time, &co_tz, &co_cnt)) {\n \t\t\tif (!len) {\n-\t\t\t\tif (!prefixcmp(real_ref, \"refs/heads/\")) {\n+\t\t\t\tif (has_prefix(real_ref, \"refs/heads/\")) {\n \t\t\t\t\tstr = real_ref + 11;\n \t\t\t\t\tlen = strlen(real_ref + 11);\n \t\t\t\t} else {\n@@ -677,15 +677,15 @@ static int peel_onion(const char *name, int len, unsigned char *sha1)\n \t\treturn -1;\n \n \tsp++; /* beginning of type name, or closing brace for empty */\n-\tif (!prefixcmp(sp, \"commit}\"))\n+\tif (has_prefix(sp, \"commit}\"))\n \t\texpected_type = OBJ_COMMIT;\n-\telse if (!prefixcmp(sp, \"tag}\"))\n+\telse if (has_prefix(sp, \"tag}\"))\n \t\texpected_type = OBJ_TAG;\n-\telse if (!prefixcmp(sp, \"tree}\"))\n+\telse if (has_prefix(sp, \"tree}\"))\n \t\texpected_type = OBJ_TREE;\n-\telse if (!prefixcmp(sp, \"blob}\"))\n+\telse if (has_prefix(sp, \"blob}\"))\n \t\texpected_type = OBJ_BLOB;\n-\telse if (!prefixcmp(sp, \"object}\"))\n+\telse if (has_prefix(sp, \"object}\"))\n \t\texpected_type = OBJ_ANY;\n \telse if (sp[0] == '}')\n \t\texpected_type = OBJ_NONE;\n@@ -912,7 +912,7 @@ static int grab_nth_branch_switch(unsigned char *osha1, unsigned char *nsha1,\n \tconst char *match = NULL, *target = NULL;\n \tsize_t len;\n \n-\tif (!prefixcmp(message, \"checkout: moving from \")) {\n+\tif (has_prefix(message, \"checkout: moving from \")) {\n \t\tmatch = message + strlen(\"checkout: moving from \");\n \t\ttarget = strstr(match, \" to \");\n \t}\n@@ -1305,7 +1305,7 @@ static void diagnose_invalid_index_path(int stage,\n \n static char *resolve_relative_path(const char *rel)\n {\n-\tif (prefixcmp(rel, \"./\") && prefixcmp(rel, \"../\"))\n+\tif (!has_prefix(rel, \"./\") && !has_prefix(rel, \"../\"))\n \t\treturn NULL;\n \n \tif (!startup_info)\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230315","messageId":"20131109070720.18178.3070.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 11/86] wt-status: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:04Z","receivedAt":"2013-11-09T07:06:04Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n wt-status.c | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex b4e44ba..47806d1 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -803,7 +803,7 @@ static void wt_status_print_tracking(struct wt_status *s)\n \tint i;\n \n \tassert(s->branch && !s->is_initial);\n-\tif (prefixcmp(s->branch, \"refs/heads/\"))\n+\tif (!has_prefix(s->branch, \"refs/heads/\"))\n \t\treturn;\n \tbranch = branch_get(s->branch + 11);\n \tif (!format_tracking_info(branch, &sb))\n@@ -1062,9 +1062,9 @@ static char *read_and_strip_branch(const char *path)\n \t\tstrbuf_setlen(&sb, sb.len - 1);\n \tif (!sb.len)\n \t\tgoto got_nothing;\n-\tif (!prefixcmp(sb.buf, \"refs/heads/\"))\n+\tif (has_prefix(sb.buf, \"refs/heads/\"))\n \t\tstrbuf_remove(&sb,0, strlen(\"refs/heads/\"));\n-\telse if (!prefixcmp(sb.buf, \"refs/\"))\n+\telse if (has_prefix(sb.buf, \"refs/\"))\n \t\t;\n \telse if (!get_sha1_hex(sb.buf, sha1)) {\n \t\tconst char *abbrev;\n@@ -1094,7 +1094,7 @@ static int grab_1st_switch(unsigned char *osha1, unsigned char *nsha1,\n \tstruct grab_1st_switch_cbdata *cb = cb_data;\n \tconst char *target = NULL, *end;\n \n-\tif (prefixcmp(message, \"checkout: moving from \"))\n+\tif (!has_prefix(message, \"checkout: moving from \"))\n \t\treturn 0;\n \tmessage += strlen(\"checkout: moving from \");\n \ttarget = strstr(message, \" to \");\n@@ -1129,9 +1129,9 @@ static void wt_status_get_detached_from(struct wt_status_state *state)\n \t     ((commit = lookup_commit_reference_gently(sha1, 1)) != NULL &&\n \t      !hashcmp(cb.nsha1, commit->object.sha1)))) {\n \t\tint ofs;\n-\t\tif (!prefixcmp(ref, \"refs/tags/\"))\n+\t\tif (has_prefix(ref, \"refs/tags/\"))\n \t\t\tofs = strlen(\"refs/tags/\");\n-\t\telse if (!prefixcmp(ref, \"refs/remotes/\"))\n+\t\telse if (has_prefix(ref, \"refs/remotes/\"))\n \t\t\tofs = strlen(\"refs/remotes/\");\n \t\telse\n \t\t\tofs = 0;\n@@ -1220,7 +1220,7 @@ void wt_status_print(struct wt_status *s)\n \tif (s->branch) {\n \t\tconst char *on_what = _(\"On branch \");\n \t\tconst char *branch_name = s->branch;\n-\t\tif (!prefixcmp(branch_name, \"refs/heads/\"))\n+\t\tif (has_prefix(branch_name, \"refs/heads/\"))\n \t\t\tbranch_name += 11;\n \t\telse if (!strcmp(branch_name, \"HEAD\")) {\n \t\t\tbranch_status_color = color(WT_STATUS_NOBRANCH, s);\n@@ -1421,7 +1421,7 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)\n \t\treturn;\n \tbranch_name = s->branch;\n \n-\tif (!prefixcmp(branch_name, \"refs/heads/\"))\n+\tif (has_prefix(branch_name, \"refs/heads/\"))\n \t\tbranch_name += 11;\n \telse if (!strcmp(branch_name, \"HEAD\")) {\n \t\tbranch_name = _(\"HEAD (no branch)\");\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230312","messageId":"20131109070720.18178.39708.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 12/86] upload-pack: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:05Z","receivedAt":"2013-11-09T07:06:05Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n upload-pack.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/upload-pack.c b/upload-pack.c\nindex a6c54e0..ce4ae75 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -394,7 +394,7 @@ static int get_common_commits(void)\n \t\t\tgot_other = 0;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(line, \"have \")) {\n+\t\tif (has_prefix(line, \"have \")) {\n \t\t\tswitch (got_sha1(line+5, sha1)) {\n \t\t\tcase -1: /* they have what we do not */\n \t\t\t\tgot_other = 1;\n@@ -540,7 +540,7 @@ static void receive_needs(void)\n \t\tif (!line)\n \t\t\tbreak;\n \n-\t\tif (!prefixcmp(line, \"shallow \")) {\n+\t\tif (has_prefix(line, \"shallow \")) {\n \t\t\tunsigned char sha1[20];\n \t\t\tstruct object *object;\n \t\t\tif (get_sha1_hex(line + 8, sha1))\n@@ -556,14 +556,14 @@ static void receive_needs(void)\n \t\t\t}\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(line, \"deepen \")) {\n+\t\tif (has_prefix(line, \"deepen \")) {\n \t\t\tchar *end;\n \t\t\tdepth = strtol(line + 7, &end, 0);\n \t\t\tif (end == line + 7 || depth <= 0)\n \t\t\t\tdie(\"Invalid deepen: %s\", line);\n \t\t\tcontinue;\n \t\t}\n-\t\tif (prefixcmp(line, \"want \") ||\n+\t\tif (!has_prefix(line, \"want \") ||\n \t\t    get_sha1_hex(line+5, sha1_buf))\n \t\t\tdie(\"git upload-pack: protocol error, \"\n \t\t\t    \"expected to get sha, not '%s'\", line);\n@@ -777,7 +777,7 @@ int main(int argc, char **argv)\n \t\t\tstrict = 1;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--timeout=\")) {\n+\t\tif (has_prefix(arg, \"--timeout=\")) {\n \t\t\ttimeout = atoi(arg+10);\n \t\t\tdaemon_mode = 1;\n \t\t\tcontinue;\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230313","messageId":"20131109070720.18178.58215.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 13/86] test-line-buffer: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:06Z","receivedAt":"2013-11-09T07:06:06Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n test-line-buffer.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/test-line-buffer.c b/test-line-buffer.c\nindex ef1d7ba..ed0d681 100644\n--- a/test-line-buffer.c\n+++ b/test-line-buffer.c\n@@ -19,7 +19,7 @@ static void handle_command(const char *command, const char *arg, struct line_buf\n {\n \tswitch (*command) {\n \tcase 'b':\n-\t\tif (!prefixcmp(command, \"binary \")) {\n+\t\tif (has_prefix(command, \"binary \")) {\n \t\t\tstruct strbuf sb = STRBUF_INIT;\n \t\t\tstrbuf_addch(&sb, '>');\n \t\t\tbuffer_read_binary(buf, &sb, strtouint32(arg));\n@@ -28,12 +28,12 @@ static void handle_command(const char *command, const char *arg, struct line_buf\n \t\t\treturn;\n \t\t}\n \tcase 'c':\n-\t\tif (!prefixcmp(command, \"copy \")) {\n+\t\tif (has_prefix(command, \"copy \")) {\n \t\t\tbuffer_copy_bytes(buf, strtouint32(arg));\n \t\t\treturn;\n \t\t}\n \tcase 's':\n-\t\tif (!prefixcmp(command, \"skip \")) {\n+\t\tif (has_prefix(command, \"skip \")) {\n \t\t\tbuffer_skip_bytes(buf, strtouint32(arg));\n \t\t\treturn;\n \t\t}\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230266","messageId":"20131109070720.18178.30853.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 14/86] parse-options: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:07Z","receivedAt":"2013-11-09T07:06:07Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n parse-options.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/parse-options.c b/parse-options.c\nindex 62e9b1c..4f7fddc 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -273,13 +273,13 @@ is_abbreviated:\n \t\t\tif (options->flags & PARSE_OPT_NONEG)\n \t\t\t\tcontinue;\n \t\t\t/* negated and abbreviated very much? */\n-\t\t\tif (!prefixcmp(\"no-\", arg)) {\n+\t\t\tif (has_prefix(\"no-\", arg)) {\n \t\t\t\tflags |= OPT_UNSET;\n \t\t\t\tgoto is_abbreviated;\n \t\t\t}\n \t\t\t/* negated? */\n-\t\t\tif (prefixcmp(arg, \"no-\")) {\n-\t\t\t\tif (!prefixcmp(long_name, \"no-\")) {\n+\t\t\tif (!has_prefix(arg, \"no-\")) {\n+\t\t\t\tif (has_prefix(long_name, \"no-\")) {\n \t\t\t\t\tlong_name += 3;\n \t\t\t\t\topt_flags |= OPT_UNSET;\n \t\t\t\t\tgoto again;\n@@ -289,7 +289,7 @@ is_abbreviated:\n \t\t\tflags |= OPT_UNSET;\n \t\t\trest = skip_prefix(arg + 3, long_name);\n \t\t\t/* abbreviated and negated? */\n-\t\t\tif (!rest && !prefixcmp(long_name, arg + 3))\n+\t\t\tif (!rest && has_prefix(long_name, arg + 3))\n \t\t\t\tgoto is_abbreviated;\n \t\t\tif (!rest)\n \t\t\t\tcontinue;\n@@ -334,7 +334,7 @@ static void check_typos(const char *arg, const struct option *options)\n \tif (strlen(arg) < 3)\n \t\treturn;\n \n-\tif (!prefixcmp(arg, \"no-\")) {\n+\tif (has_prefix(arg, \"no-\")) {\n \t\terror (\"did you mean `--%s` (with two dashes ?)\", arg);\n \t\texit(129);\n \t}\n@@ -342,7 +342,7 @@ static void check_typos(const char *arg, const struct option *options)\n \tfor (; options->type != OPTION_END; options++) {\n \t\tif (!options->long_name)\n \t\t\tcontinue;\n-\t\tif (!prefixcmp(options->long_name, arg)) {\n+\t\tif (has_prefix(options->long_name, arg)) {\n \t\t\terror (\"did you mean `--%s` (with two dashes ?)\", arg);\n \t\t\texit(129);\n \t\t}\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230269","messageId":"20131109070720.18178.86102.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 15/86] fetch-pack: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:08Z","receivedAt":"2013-11-09T07:06:08Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n fetch-pack.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex a0e0350..1526ed1 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -176,9 +176,9 @@ static void consume_shallow_list(struct fetch_pack_args *args, int fd)\n \t\t */\n \t\tchar *line;\n \t\twhile ((line = packet_read_line(fd, NULL))) {\n-\t\t\tif (!prefixcmp(line, \"shallow \"))\n+\t\t\tif (has_prefix(line, \"shallow \"))\n \t\t\t\tcontinue;\n-\t\t\tif (!prefixcmp(line, \"unshallow \"))\n+\t\t\tif (has_prefix(line, \"unshallow \"))\n \t\t\t\tcontinue;\n \t\t\tdie(\"git fetch-pack: expected shallow list\");\n \t\t}\n@@ -194,7 +194,7 @@ static enum ack_type get_ack(int fd, unsigned char *result_sha1)\n \t\tdie(\"git fetch-pack: expected ACK/NAK, got EOF\");\n \tif (!strcmp(line, \"NAK\"))\n \t\treturn NAK;\n-\tif (!prefixcmp(line, \"ACK \")) {\n+\tif (has_prefix(line, \"ACK \")) {\n \t\tif (!get_sha1_hex(line+4, result_sha1)) {\n \t\t\tif (len < 45)\n \t\t\t\treturn ACK;\n@@ -323,13 +323,13 @@ static int find_common(struct fetch_pack_args *args,\n \n \t\tsend_request(args, fd[1], &req_buf);\n \t\twhile ((line = packet_read_line(fd[0], NULL))) {\n-\t\t\tif (!prefixcmp(line, \"shallow \")) {\n+\t\t\tif (has_prefix(line, \"shallow \")) {\n \t\t\t\tif (get_sha1_hex(line + 8, sha1))\n \t\t\t\t\tdie(\"invalid shallow line: %s\", line);\n \t\t\t\tregister_shallow(sha1);\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tif (!prefixcmp(line, \"unshallow \")) {\n+\t\t\tif (has_prefix(line, \"unshallow \")) {\n \t\t\t\tif (get_sha1_hex(line + 10, sha1))\n \t\t\t\t\tdie(\"invalid unshallow line: %s\", line);\n \t\t\t\tif (!lookup_object(sha1))\n@@ -523,7 +523,7 @@ static void filter_refs(struct fetch_pack_args *args,\n \t\t}\n \n \t\tif (!keep && args->fetch_all &&\n-\t\t    (!args->depth || prefixcmp(ref->name, \"refs/tags/\")))\n+\t\t    (!args->depth || !has_prefix(ref->name, \"refs/tags/\")))\n \t\t\tkeep = 1;\n \n \t\tif (keep) {\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230267","messageId":"20131109070720.18178.44846.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 16/86] git: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:09Z","receivedAt":"2013-11-09T07:06:09Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n git.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex cb5208d..f077f49 100644\n--- a/git.c\n+++ b/git.c\n@@ -54,7 +54,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)\n \t\t/*\n \t\t * Check remaining flags.\n \t\t */\n-\t\tif (!prefixcmp(cmd, \"--exec-path\")) {\n+\t\tif (has_prefix(cmd, \"--exec-path\")) {\n \t\t\tcmd += 11;\n \t\t\tif (*cmd == '=')\n \t\t\t\tgit_set_argv_exec_path(cmd + 1);\n@@ -92,7 +92,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)\n \t\t\t\t*envchanged = 1;\n \t\t\t(*argv)++;\n \t\t\t(*argc)--;\n-\t\t} else if (!prefixcmp(cmd, \"--git-dir=\")) {\n+\t\t} else if (has_prefix(cmd, \"--git-dir=\")) {\n \t\t\tsetenv(GIT_DIR_ENVIRONMENT, cmd + 10, 1);\n \t\t\tif (envchanged)\n \t\t\t\t*envchanged = 1;\n@@ -106,7 +106,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)\n \t\t\t\t*envchanged = 1;\n \t\t\t(*argv)++;\n \t\t\t(*argc)--;\n-\t\t} else if (!prefixcmp(cmd, \"--namespace=\")) {\n+\t\t} else if (has_prefix(cmd, \"--namespace=\")) {\n \t\t\tsetenv(GIT_NAMESPACE_ENVIRONMENT, cmd + 12, 1);\n \t\t\tif (envchanged)\n \t\t\t\t*envchanged = 1;\n@@ -120,7 +120,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)\n \t\t\t\t*envchanged = 1;\n \t\t\t(*argv)++;\n \t\t\t(*argc)--;\n-\t\t} else if (!prefixcmp(cmd, \"--work-tree=\")) {\n+\t\t} else if (has_prefix(cmd, \"--work-tree=\")) {\n \t\t\tsetenv(GIT_WORK_TREE_ENVIRONMENT, cmd + 12, 1);\n \t\t\tif (envchanged)\n \t\t\t\t*envchanged = 1;\n@@ -569,7 +569,7 @@ int main(int argc, char **av)\n \t * So we just directly call the internal command handler, and\n \t * die if that one cannot handle it.\n \t */\n-\tif (!prefixcmp(cmd, \"git-\")) {\n+\tif (has_prefix(cmd, \"git-\")) {\n \t\tcmd += 4;\n \t\targv[0] = cmd;\n \t\thandle_internal_command(argc, argv);\n@@ -581,7 +581,7 @@ int main(int argc, char **av)\n \targc--;\n \thandle_options(&argv, &argc, NULL);\n \tif (argc > 0) {\n-\t\tif (!prefixcmp(argv[0], \"--\"))\n+\t\tif (has_prefix(argv[0], \"--\"))\n \t\t\targv[0] += 2;\n \t} else {\n \t\t/* The user didn't specify a command; give them help */\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230270","messageId":"20131109070720.18178.87446.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 17/86] tag: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:10Z","receivedAt":"2013-11-09T07:06:10Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n tag.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/tag.c b/tag.c\nindex 78d272b..0b00c76 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -86,7 +86,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)\n \t\treturn -1;\n \tbufptr += 48; /* \"object \" + sha1 + \"\\n\" */\n \n-\tif (prefixcmp(bufptr, \"type \"))\n+\tif (!has_prefix(bufptr, \"type \"))\n \t\treturn -1;\n \tbufptr += 5;\n \tnl = memchr(bufptr, '\\n', tail - bufptr);\n@@ -109,7 +109,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)\n \t\titem->tagged = NULL;\n \t}\n \n-\tif (bufptr + 4 < tail && !prefixcmp(bufptr, \"tag \"))\n+\tif (bufptr + 4 < tail && has_prefix(bufptr, \"tag \"))\n \t\t; \t\t/* good */\n \telse\n \t\treturn -1;\n@@ -120,7 +120,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)\n \titem->tag = xmemdupz(bufptr, nl - bufptr);\n \tbufptr = nl + 1;\n \n-\tif (bufptr + 7 < tail && !prefixcmp(bufptr, \"tagger \"))\n+\tif (bufptr + 7 < tail && has_prefix(bufptr, \"tagger \"))\n \t\titem->date = parse_tag_date(bufptr, tail);\n \telse\n \t\titem->date = 0;\n@@ -160,8 +160,8 @@ size_t parse_signature(const char *buf, unsigned long size)\n {\n \tchar *eol;\n \tsize_t len = 0;\n-\twhile (len < size && prefixcmp(buf + len, PGP_SIGNATURE) &&\n-\t\t\tprefixcmp(buf + len, PGP_MESSAGE)) {\n+\twhile (len < size && !has_prefix(buf + len, PGP_SIGNATURE) &&\n+\t\t\t!has_prefix(buf + len, PGP_MESSAGE)) {\n \t\teol = memchr(buf + len, '\\n', size - len);\n \t\tlen += eol ? eol - (buf + len) + 1 : size - len;\n \t}\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230268","messageId":"20131109070720.18178.17858.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 18/86] sequencer: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:11Z","receivedAt":"2013-11-09T07:06:11Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n sequencer.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex 06e52b4..64cc6f0 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -41,7 +41,7 @@ static int is_cherry_picked_from_line(const char *buf, int len)\n \t * We only care that it looks roughly like (cherry picked from ...)\n \t */\n \treturn len > strlen(cherry_picked_prefix) + 1 &&\n-\t\t!prefixcmp(buf, cherry_picked_prefix) && buf[len - 1] == ')';\n+\t\thas_prefix(buf, cherry_picked_prefix) && buf[len - 1] == ')';\n }\n \n /*\n@@ -180,7 +180,7 @@ static char *get_encoding(const char *message)\n \twhile (*p && *p != '\\n') {\n \t\tfor (eol = p + 1; *eol && *eol != '\\n'; eol++)\n \t\t\t; /* do nothing */\n-\t\tif (!prefixcmp(p, \"encoding \")) {\n+\t\tif (has_prefix(p, \"encoding \")) {\n \t\t\tchar *result = xmalloc(eol - 8 - p);\n \t\t\tstrlcpy(result, p + 9, eol - 8 - p);\n \t\t\treturn result;\n@@ -705,10 +705,10 @@ static struct commit *parse_insn_line(char *bol, char *eol, struct replay_opts *\n \tchar *end_of_object_name;\n \tint saved, status, padding;\n \n-\tif (!prefixcmp(bol, \"pick\")) {\n+\tif (has_prefix(bol, \"pick\")) {\n \t\taction = REPLAY_PICK;\n \t\tbol += strlen(\"pick\");\n-\t} else if (!prefixcmp(bol, \"revert\")) {\n+\t} else if (has_prefix(bol, \"revert\")) {\n \t\taction = REPLAY_REVERT;\n \t\tbol += strlen(\"revert\");\n \t} else\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230309","messageId":"20131109070720.18178.67112.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 19/86] commit: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:12Z","receivedAt":"2013-11-09T07:06:12Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n commit.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex de16a3c..35b276d 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -559,7 +559,7 @@ static void record_author_date(struct author_date_slab *author_date,\n \t     buf;\n \t     buf = line_end + 1) {\n \t\tline_end = strchrnul(buf, '\\n');\n-\t\tif (prefixcmp(buf, \"author \")) {\n+\t\tif (!has_prefix(buf, \"author \")) {\n \t\t\tif (!line_end[0] || line_end[1] == '\\n')\n \t\t\t\treturn; /* end of header */\n \t\t\tcontinue;\n@@ -1106,7 +1106,7 @@ int parse_signed_commit(const unsigned char *sha1,\n \t\tnext = next ? next + 1 : tail;\n \t\tif (in_signature && line[0] == ' ')\n \t\t\tsig = line + 1;\n-\t\telse if (!prefixcmp(line, gpg_sig_header) &&\n+\t\telse if (has_prefix(line, gpg_sig_header) &&\n \t\t\t line[gpg_sig_header_len] == ' ')\n \t\t\tsig = line + gpg_sig_header_len + 1;\n \t\tif (sig) {\n@@ -1186,7 +1186,7 @@ static void parse_gpg_output(struct signature_check *sigc)\n \tfor (i = 0; i < ARRAY_SIZE(sigcheck_gpg_status); i++) {\n \t\tconst char *found, *next;\n \n-\t\tif (!prefixcmp(buf, sigcheck_gpg_status[i].check + 1)) {\n+\t\tif (has_prefix(buf, sigcheck_gpg_status[i].check + 1)) {\n \t\t\t/* At the very beginning of the buffer */\n \t\t\tfound = buf + strlen(sigcheck_gpg_status[i].check + 1);\n \t\t} else {\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230275","messageId":"20131109070720.18178.55408.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 20/86] http: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:13Z","receivedAt":"2013-11-09T07:06:13Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n http.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex f3e1439..f2621cd 100644\n--- a/http.c\n+++ b/http.c\n@@ -422,7 +422,7 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)\n \t\tcredential_from_url(&http_auth, url);\n \t\tif (!ssl_cert_password_required &&\n \t\t    getenv(\"GIT_SSL_CERT_PASSWORD_PROTECTED\") &&\n-\t\t    !prefixcmp(url, \"https://\"))\n+\t\t    has_prefix(url, \"https://\"))\n \t\t\tssl_cert_password_required = 1;\n \t}\n \n@@ -985,7 +985,7 @@ int http_fetch_ref(const char *base, struct ref *ref)\n \t\tstrbuf_rtrim(&buffer);\n \t\tif (buffer.len == 40)\n \t\t\tret = get_sha1_hex(buffer.buf, ref->old_sha1);\n-\t\telse if (!prefixcmp(buffer.buf, \"ref: \")) {\n+\t\telse if (has_prefix(buffer.buf, \"ref: \")) {\n \t\t\tref->symref = xstrdup(buffer.buf + 5);\n \t\t\tret = 0;\n \t\t}\n@@ -1084,8 +1084,8 @@ int http_get_info_packs(const char *base_url, struct packed_git **packs_head)\n \t\tcase 'P':\n \t\t\ti++;\n \t\t\tif (i + 52 <= buf.len &&\n-\t\t\t    !prefixcmp(data + i, \" pack-\") &&\n-\t\t\t    !prefixcmp(data + i + 46, \".pack\\n\")) {\n+\t\t\t    has_prefix(data + i, \" pack-\") &&\n+\t\t\t    has_prefix(data + i + 46, \".pack\\n\")) {\n \t\t\t\tget_sha1_hex(data + i + 6, sha1);\n \t\t\t\tfetch_and_setup_pack_index(packs_head, sha1,\n \t\t\t\t\t\t      base_url);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230273","messageId":"20131109070720.18178.19524.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 21/86] imap-send: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:14Z","receivedAt":"2013-11-09T07:06:14Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n imap-send.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/imap-send.c b/imap-send.c\nindex 6f5cc4f..670de9f 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -1263,7 +1263,7 @@ static int count_messages(struct strbuf *all_msgs)\n \tchar *p = all_msgs->buf;\n \n \twhile (1) {\n-\t\tif (!prefixcmp(p, \"From \")) {\n+\t\tif (has_prefix(p, \"From \")) {\n \t\t\tp = strstr(p+5, \"\\nFrom: \");\n \t\t\tif (!p) break;\n \t\t\tp = strstr(p+7, \"\\nDate: \");\n@@ -1297,7 +1297,7 @@ static int split_msg(struct strbuf *all_msgs, struct strbuf *msg, int *ofs)\n \tdata = &all_msgs->buf[*ofs];\n \tlen = all_msgs->len - *ofs;\n \n-\tif (len < 5 || prefixcmp(data, \"From \"))\n+\tif (len < 5 || !has_prefix(data, \"From \"))\n \t\treturn 0;\n \n \tp = strchr(data, '\\n');\n@@ -1339,13 +1339,13 @@ static int git_imap_config(const char *key, const char *val, void *cb)\n \tif (!strcmp(\"folder\", key)) {\n \t\timap_folder = xstrdup(val);\n \t} else if (!strcmp(\"host\", key)) {\n-\t\tif (!prefixcmp(val, \"imap:\"))\n+\t\tif (has_prefix(val, \"imap:\"))\n \t\t\tval += 5;\n-\t\telse if (!prefixcmp(val, \"imaps:\")) {\n+\t\telse if (has_prefix(val, \"imaps:\")) {\n \t\t\tval += 6;\n \t\t\tserver.use_ssl = 1;\n \t\t}\n-\t\tif (!prefixcmp(val, \"//\"))\n+\t\tif (has_prefix(val, \"//\"))\n \t\t\tval += 2;\n \t\tserver.host = xstrdup(val);\n \t} else if (!strcmp(\"user\", key))\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230304","messageId":"20131109070720.18178.26715.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 22/86] help: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:15Z","receivedAt":"2013-11-09T07:06:15Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n help.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/help.c b/help.c\nindex f068925..b41d2d5 100644\n--- a/help.c\n+++ b/help.c\n@@ -148,7 +148,7 @@ static void list_commands_in_dir(struct cmdnames *cmds,\n \twhile ((de = readdir(dir)) != NULL) {\n \t\tint entlen;\n \n-\t\tif (prefixcmp(de->d_name, prefix))\n+\t\tif (!has_prefix(de->d_name, prefix))\n \t\t\tcontinue;\n \n \t\tstrbuf_setlen(&buf, len);\n@@ -255,7 +255,7 @@ static int git_unknown_cmd_config(const char *var, const char *value, void *cb)\n \tif (!strcmp(var, \"help.autocorrect\"))\n \t\tautocorrect = git_config_int(var,value);\n \t/* Also use aliases for command lookup */\n-\tif (!prefixcmp(var, \"alias.\"))\n+\tif (has_prefix(var, \"alias.\"))\n \t\tadd_cmdname(&aliases, var + 6, strlen(var + 6));\n \n \treturn git_default_config(var, value, cb);\n@@ -329,7 +329,7 @@ const char *help_unknown_cmd(const char *cmd)\n \t\tif ((n < ARRAY_SIZE(common_cmds)) && !cmp) {\n \t\t\t/* Yes, this is one of the common commands */\n \t\t\tn++; /* use the entry from common_cmds[] */\n-\t\t\tif (!prefixcmp(candidate, cmd)) {\n+\t\t\tif (has_prefix(candidate, cmd)) {\n \t\t\t\t/* Give prefix match a very good score */\n \t\t\t\tmain_cmds.names[i]->len = 0;\n \t\t\t\tcontinue;\n@@ -414,7 +414,7 @@ static int append_similar_ref(const char *refname, const unsigned char *sha1,\n \tstruct similar_ref_cb *cb = (struct similar_ref_cb *)(cb_data);\n \tchar *branch = strrchr(refname, '/') + 1;\n \t/* A remote branch of the same name is deemed similar */\n-\tif (!prefixcmp(refname, \"refs/remotes/\") &&\n+\tif (has_prefix(refname, \"refs/remotes/\") &&\n \t    !strcmp(branch, cb->base_ref))\n \t\tstring_list_append(cb->similar_refs,\n \t\t\t\t   refname + strlen(\"refs/remotes/\"));\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230276","messageId":"20131109070720.18178.15709.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 23/86] log-tree: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:16Z","receivedAt":"2013-11-09T07:06:16Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n log-tree.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/log-tree.c b/log-tree.c\nindex 8534d91..25b46a9 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -98,7 +98,7 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in\n \tstruct object *obj;\n \tenum decoration_type type = DECORATION_NONE;\n \n-\tif (!prefixcmp(refname, \"refs/replace/\")) {\n+\tif (has_prefix(refname, \"refs/replace/\")) {\n \t\tunsigned char original_sha1[20];\n \t\tif (!read_replace_refs)\n \t\t\treturn 0;\n@@ -116,11 +116,11 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in\n \tif (!obj)\n \t\treturn 0;\n \n-\tif (!prefixcmp(refname, \"refs/heads/\"))\n+\tif (has_prefix(refname, \"refs/heads/\"))\n \t\ttype = DECORATION_REF_LOCAL;\n-\telse if (!prefixcmp(refname, \"refs/remotes/\"))\n+\telse if (has_prefix(refname, \"refs/remotes/\"))\n \t\ttype = DECORATION_REF_REMOTE;\n-\telse if (!prefixcmp(refname, \"refs/tags/\"))\n+\telse if (has_prefix(refname, \"refs/tags/\"))\n \t\ttype = DECORATION_REF_TAG;\n \telse if (!strcmp(refname, \"refs/stash\"))\n \t\ttype = DECORATION_REF_STASH;\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230272","messageId":"20131109070720.18178.95423.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 24/86] merge-recursive: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:17Z","receivedAt":"2013-11-09T07:06:17Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n merge-recursive.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex dbb7104..9043362 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -2063,13 +2063,13 @@ int parse_merge_opt(struct merge_options *o, const char *s)\n \t\to->recursive_variant = MERGE_RECURSIVE_THEIRS;\n \telse if (!strcmp(s, \"subtree\"))\n \t\to->subtree_shift = \"\";\n-\telse if (!prefixcmp(s, \"subtree=\"))\n+\telse if (has_prefix(s, \"subtree=\"))\n \t\to->subtree_shift = s + strlen(\"subtree=\");\n \telse if (!strcmp(s, \"patience\"))\n \t\to->xdl_opts = DIFF_WITH_ALG(o, PATIENCE_DIFF);\n \telse if (!strcmp(s, \"histogram\"))\n \t\to->xdl_opts = DIFF_WITH_ALG(o, HISTOGRAM_DIFF);\n-\telse if (!prefixcmp(s, \"diff-algorithm=\")) {\n+\telse if (has_prefix(s, \"diff-algorithm=\")) {\n \t\tlong value = parse_algorithm_value(s + strlen(\"diff-algorithm=\"));\n \t\tif (value < 0)\n \t\t\treturn -1;\n@@ -2088,7 +2088,7 @@ int parse_merge_opt(struct merge_options *o, const char *s)\n \t\to->renormalize = 1;\n \telse if (!strcmp(s, \"no-renormalize\"))\n \t\to->renormalize = 0;\n-\telse if (!prefixcmp(s, \"rename-threshold=\")) {\n+\telse if (has_prefix(s, \"rename-threshold=\")) {\n \t\tconst char *score = s + strlen(\"rename-threshold=\");\n \t\tif ((o->rename_score = parse_rename_score(&score)) == -1 || *score != 0)\n \t\t\treturn -1;\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230310","messageId":"20131109070720.18178.81030.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 25/86] notes: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:18Z","receivedAt":"2013-11-09T07:06:18Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n notes.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/notes.c b/notes.c\nindex b69c0b8..e23d38a 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -1243,9 +1243,9 @@ static void format_note(struct notes_tree *t, const unsigned char *object_sha1,\n \t\tif (!ref || !strcmp(ref, GIT_NOTES_DEFAULT_REF)) {\n \t\t\tstrbuf_addstr(sb, \"\\nNotes:\\n\");\n \t\t} else {\n-\t\t\tif (!prefixcmp(ref, \"refs/\"))\n+\t\t\tif (has_prefix(ref, \"refs/\"))\n \t\t\t\tref += 5;\n-\t\t\tif (!prefixcmp(ref, \"notes/\"))\n+\t\t\tif (has_prefix(ref, \"notes/\"))\n \t\t\t\tref += 6;\n \t\t\tstrbuf_addf(sb, \"\\nNotes (%s):\\n\", ref);\n \t\t}\n@@ -1293,9 +1293,9 @@ int copy_note(struct notes_tree *t,\n \n void expand_notes_ref(struct strbuf *sb)\n {\n-\tif (!prefixcmp(sb->buf, \"refs/notes/\"))\n+\tif (has_prefix(sb->buf, \"refs/notes/\"))\n \t\treturn; /* we're happy */\n-\telse if (!prefixcmp(sb->buf, \"notes/\"))\n+\telse if (has_prefix(sb->buf, \"notes/\"))\n \t\tstrbuf_insert(sb, 0, \"refs/\", 5);\n \telse\n \t\tstrbuf_insert(sb, 0, \"refs/notes/\", 11);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230311","messageId":"20131109070720.18178.64556.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 26/86] refs: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:19Z","receivedAt":"2013-11-09T07:06:19Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n refs.c | 30 +++++++++++++++---------------\n 1 file changed, 15 insertions(+), 15 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 3710748..3dc38df 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -637,7 +637,7 @@ static int do_one_ref(struct ref_entry *entry, void *cb_data)\n \tstruct ref_entry *old_current_ref;\n \tint retval;\n \n-\tif (prefixcmp(entry->name, data->base))\n+\tif (!has_prefix(entry->name, data->base))\n \t\treturn 0;\n \n \tif (!(data->flags & DO_FOR_EACH_INCLUDE_BROKEN) &&\n@@ -1049,7 +1049,7 @@ static void read_packed_refs(FILE *f, struct ref_dir *dir)\n \t\tif (refname) {\n \t\t\tlast = create_ref_entry(refname, sha1, REF_ISPACKED, 1);\n \t\t\tif (peeled == PEELED_FULLY ||\n-\t\t\t    (peeled == PEELED_TAGS && !prefixcmp(refname, \"refs/tags/\")))\n+\t\t\t    (peeled == PEELED_TAGS && has_prefix(refname, \"refs/tags/\")))\n \t\t\t\tlast->flag |= REF_KNOWS_PEELED;\n \t\t\tadd_ref(dir, last);\n \t\t\tcontinue;\n@@ -1383,7 +1383,7 @@ const char *resolve_ref_unsafe(const char *refname, unsigned char *sha1, int rea\n \t\t\t\t\treturn NULL;\n \t\t\t}\n \t\t\tbuffer[len] = 0;\n-\t\t\tif (!prefixcmp(buffer, \"refs/\") &&\n+\t\t\tif (has_prefix(buffer, \"refs/\") &&\n \t\t\t\t\t!check_refname_format(buffer, 0)) {\n \t\t\t\tstrcpy(refname_buffer, buffer);\n \t\t\t\trefname = refname_buffer;\n@@ -1422,7 +1422,7 @@ const char *resolve_ref_unsafe(const char *refname, unsigned char *sha1, int rea\n \t\t/*\n \t\t * Is it a symbolic ref?\n \t\t */\n-\t\tif (prefixcmp(buffer, \"ref:\")) {\n+\t\tif (!has_prefix(buffer, \"ref:\")) {\n \t\t\t/*\n \t\t\t * Please note that FETCH_HEAD has a second\n \t\t\t * line containing other data.\n@@ -1844,7 +1844,7 @@ int for_each_glob_ref_in(each_ref_fn fn, const char *pattern,\n \tstruct ref_filter filter;\n \tint ret;\n \n-\tif (!prefix && prefixcmp(pattern, \"refs/\"))\n+\tif (!prefix && !has_prefix(pattern, \"refs/\"))\n \t\tstrbuf_addstr(&real_pattern, \"refs/\");\n \telse if (prefix)\n \t\tstrbuf_addstr(&real_pattern, prefix);\n@@ -1881,9 +1881,9 @@ int for_each_rawref(each_ref_fn fn, void *cb_data)\n const char *prettify_refname(const char *name)\n {\n \treturn name + (\n-\t\t!prefixcmp(name, \"refs/heads/\") ? 11 :\n-\t\t!prefixcmp(name, \"refs/tags/\") ? 10 :\n-\t\t!prefixcmp(name, \"refs/remotes/\") ? 13 :\n+\t\thas_prefix(name, \"refs/heads/\") ? 11 :\n+\t\thas_prefix(name, \"refs/tags/\") ? 10 :\n+\t\thas_prefix(name, \"refs/remotes/\") ? 13 :\n \t\t0);\n }\n \n@@ -2251,7 +2251,7 @@ static int pack_if_possible_fn(struct ref_entry *entry, void *cb_data)\n \tstruct pack_refs_cb_data *cb = cb_data;\n \tenum peel_status peel_status;\n \tstruct ref_entry *packed_entry;\n-\tint is_tag_ref = !prefixcmp(entry->name, \"refs/tags/\");\n+\tint is_tag_ref = has_prefix(entry->name, \"refs/tags/\");\n \n \t/* ALWAYS pack tags */\n \tif (!(cb->flags & PACK_REFS_ALL) && !is_tag_ref)\n@@ -2686,9 +2686,9 @@ int log_ref_setup(const char *refname, char *logfile, int bufsize)\n \n \tgit_snpath(logfile, bufsize, \"logs/%s\", refname);\n \tif (log_all_ref_updates &&\n-\t    (!prefixcmp(refname, \"refs/heads/\") ||\n-\t     !prefixcmp(refname, \"refs/remotes/\") ||\n-\t     !prefixcmp(refname, \"refs/notes/\") ||\n+\t    (has_prefix(refname, \"refs/heads/\") ||\n+\t     has_prefix(refname, \"refs/remotes/\") ||\n+\t     has_prefix(refname, \"refs/notes/\") ||\n \t     !strcmp(refname, \"HEAD\"))) {\n \t\tif (safe_create_leading_directories(logfile) < 0)\n \t\t\treturn error(\"unable to create directory for %s\",\n@@ -2758,7 +2758,7 @@ static int log_ref_write(const char *refname, const unsigned char *old_sha1,\n \n static int is_branch(const char *refname)\n {\n-\treturn !strcmp(refname, \"HEAD\") || !prefixcmp(refname, \"refs/heads/\");\n+\treturn !strcmp(refname, \"HEAD\") || has_prefix(refname, \"refs/heads/\");\n }\n \n int write_ref_sha1(struct ref_lock *lock,\n@@ -3457,7 +3457,7 @@ int parse_hide_refs_config(const char *var, const char *value, const char *secti\n {\n \tif (!strcmp(\"transfer.hiderefs\", var) ||\n \t    /* NEEDSWORK: use parse_config_key() once both are merged */\n-\t    (!prefixcmp(var, section) && var[strlen(section)] == '.' &&\n+\t    (has_prefix(var, section) && var[strlen(section)] == '.' &&\n \t     !strcmp(var + strlen(section), \".hiderefs\"))) {\n \t\tchar *ref;\n \t\tint len;\n@@ -3485,7 +3485,7 @@ int ref_is_hidden(const char *refname)\n \t\treturn 0;\n \tfor_each_string_list_item(item, hide_refs) {\n \t\tint len;\n-\t\tif (prefixcmp(refname, item->string))\n+\t\tif (!has_prefix(refname, item->string))\n \t\t\tcontinue;\n \t\tlen = strlen(item->string);\n \t\tif (!refname[len] || refname[len] == '/')\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230277","messageId":"20131109070720.18178.85578.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 27/86] setup: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:20Z","receivedAt":"2013-11-09T07:06:20Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n setup.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/setup.c b/setup.c\nindex f08dd64..6ed292a 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -82,7 +82,7 @@ int check_filename(const char *prefix, const char *arg)\n \tconst char *name;\n \tstruct stat st;\n \n-\tif (!prefixcmp(arg, \":/\")) {\n+\tif (has_prefix(arg, \":/\")) {\n \t\tif (arg[2] == '\\0') /* \":/\" is root dir, always exists */\n \t\t\treturn 1;\n \t\tname = arg + 2;\n@@ -307,7 +307,7 @@ const char *read_gitfile(const char *path)\n \tif (len != st.st_size)\n \t\tdie(\"Error reading %s\", path);\n \tbuf[len] = '\\0';\n-\tif (prefixcmp(buf, \"gitdir: \"))\n+\tif (!has_prefix(buf, \"gitdir: \"))\n \t\tdie(\"Invalid gitfile format: %s\", path);\n \twhile (buf[len - 1] == '\\n' || buf[len - 1] == '\\r')\n \t\tlen--;\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230271","messageId":"20131109070720.18178.4605.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 28/86] bisect: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:21Z","receivedAt":"2013-11-09T07:06:21Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n bisect.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex 1e46a4f..4819091 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -406,9 +406,9 @@ static int register_ref(const char *refname, const unsigned char *sha1,\n \tif (!strcmp(refname, \"bad\")) {\n \t\tcurrent_bad_sha1 = xmalloc(20);\n \t\thashcpy(current_bad_sha1, sha1);\n-\t} else if (!prefixcmp(refname, \"good-\")) {\n+\t} else if (has_prefix(refname, \"good-\")) {\n \t\tsha1_array_append(&good_revs, sha1);\n-\t} else if (!prefixcmp(refname, \"skip-\")) {\n+\t} else if (has_prefix(refname, \"skip-\")) {\n \t\tsha1_array_append(&skipped_revs, sha1);\n \t}\n \n-- \n1.8.4.1.566.geca833c\n"},{"id":"230308","messageId":"20131109070720.18178.57801.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 29/86] branch: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:22Z","receivedAt":"2013-11-09T07:06:22Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n branch.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex 9e6c68e..fc3a61d 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -50,7 +50,7 @@ static int should_setup_rebase(const char *origin)\n void install_branch_config(int flag, const char *local, const char *origin, const char *remote)\n {\n \tconst char *shortname = remote + 11;\n-\tint remote_is_branch = !prefixcmp(remote, \"refs/heads/\");\n+\tint remote_is_branch = has_prefix(remote, \"refs/heads/\");\n \tstruct strbuf key = STRBUF_INIT;\n \tint rebasing = should_setup_rebase(origin);\n \n@@ -272,7 +272,7 @@ void create_branch(const char *head,\n \t\tbreak;\n \tcase 1:\n \t\t/* Unique completion -- good, only if it is a real branch */\n-\t\tif (prefixcmp(real_ref, \"refs/heads/\") &&\n+\t\tif (!has_prefix(real_ref, \"refs/heads/\") &&\n \t\t    validate_remote_tracking_branch(real_ref)) {\n \t\t\tif (explicit_tracking)\n \t\t\t\tdie(_(upstream_not_branch), start_name);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230303","messageId":"20131109070720.18178.17480.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 30/86] http-push: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:23Z","receivedAt":"2013-11-09T07:06:23Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n http-push.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex 69200ba..0994344 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -771,7 +771,7 @@ static void handle_new_lock_ctx(struct xml_ctx *ctx, int tag_closed)\n \t\t\tlock->owner = xmalloc(strlen(ctx->cdata) + 1);\n \t\t\tstrcpy(lock->owner, ctx->cdata);\n \t\t} else if (!strcmp(ctx->name, DAV_ACTIVELOCK_TIMEOUT)) {\n-\t\t\tif (!prefixcmp(ctx->cdata, \"Second-\"))\n+\t\t\tif (has_prefix(ctx->cdata, \"Second-\"))\n \t\t\t\tlock->timeout =\n \t\t\t\t\tstrtol(ctx->cdata + 7, NULL, 10);\n \t\t} else if (!strcmp(ctx->name, DAV_ACTIVELOCK_TOKEN)) {\n@@ -1579,7 +1579,7 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)\n \t\treturn;\n \n \t/* If it's a symref, set the refname; otherwise try for a sha1 */\n-\tif (!prefixcmp((char *)buffer.buf, \"ref: \")) {\n+\tif (has_prefix((char *)buffer.buf, \"ref: \")) {\n \t\t*symref = xmemdupz((char *)buffer.buf + 5, buffer.len - 6);\n \t} else {\n \t\tget_sha1_hex(buffer.buf, sha1);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230274","messageId":"20131109070720.18178.73574.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 31/86] send-pack: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:24Z","receivedAt":"2013-11-09T07:06:24Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n send-pack.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/send-pack.c b/send-pack.c\nindex b228d65..c90049a 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -109,7 +109,7 @@ static int receive_status(int in, struct ref *refs)\n \tstruct ref *hint;\n \tint ret = 0;\n \tchar *line = packet_read_line(in, NULL);\n-\tif (prefixcmp(line, \"unpack \"))\n+\tif (!has_prefix(line, \"unpack \"))\n \t\treturn error(\"did not receive remote status\");\n \tif (strcmp(line, \"unpack ok\")) {\n \t\terror(\"unpack failed: %s\", line + 7);\n@@ -122,7 +122,7 @@ static int receive_status(int in, struct ref *refs)\n \t\tline = packet_read_line(in, NULL);\n \t\tif (!line)\n \t\t\tbreak;\n-\t\tif (prefixcmp(line, \"ok \") && prefixcmp(line, \"ng \")) {\n+\t\tif (!has_prefix(line, \"ok \") && !has_prefix(line, \"ng \")) {\n \t\t\terror(\"invalid ref status from remote: %s\", line);\n \t\t\tret = -1;\n \t\t\tbreak;\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230305","messageId":"20131109070720.18178.24891.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 32/86] http-backend: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:25Z","receivedAt":"2013-11-09T07:06:25Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n http-backend.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/http-backend.c b/http-backend.c\nindex 8c464bd..d0183b1 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -226,7 +226,7 @@ static int http_config(const char *var, const char *value, void *cb)\n \t\treturn 0;\n \t}\n \n-\tif (!prefixcmp(var, \"http.\")) {\n+\tif (has_prefix(var, \"http.\")) {\n \t\tint i;\n \n \t\tfor (i = 0; i < ARRAY_SIZE(rpc_service); i++) {\n@@ -247,7 +247,7 @@ static struct rpc_service *select_service(const char *name)\n \tstruct rpc_service *svc = NULL;\n \tint i;\n \n-\tif (prefixcmp(name, \"git-\"))\n+\tif (!has_prefix(name, \"git-\"))\n \t\tforbidden(\"Unsupported service: '%s'\", name);\n \n \tfor (i = 0; i < ARRAY_SIZE(rpc_service); i++) {\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230296","messageId":"20131109070720.18178.88664.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 33/86] notes-utils: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:26Z","receivedAt":"2013-11-09T07:06:26Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n notes-utils.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/notes-utils.c b/notes-utils.c\nindex 9107c37..0a4c3de 100644\n--- a/notes-utils.c\n+++ b/notes-utils.c\n@@ -70,7 +70,7 @@ static combine_notes_fn parse_combine_notes_fn(const char *v)\n static int notes_rewrite_config(const char *k, const char *v, void *cb)\n {\n \tstruct notes_rewrite_cfg *c = cb;\n-\tif (!prefixcmp(k, \"notes.rewrite.\") && !strcmp(k+14, c->cmd)) {\n+\tif (has_prefix(k, \"notes.rewrite.\") && !strcmp(k+14, c->cmd)) {\n \t\tc->enabled = git_config_bool(k, v);\n \t\treturn 0;\n \t} else if (!c->mode_from_env && !strcmp(k, \"notes.rewritemode\")) {\n@@ -85,7 +85,7 @@ static int notes_rewrite_config(const char *k, const char *v, void *cb)\n \t} else if (!c->refs_from_env && !strcmp(k, \"notes.rewriteref\")) {\n \t\t/* note that a refs/ prefix is implied in the\n \t\t * underlying for_each_glob_ref */\n-\t\tif (!prefixcmp(v, \"refs/notes/\"))\n+\t\tif (has_prefix(v, \"refs/notes/\"))\n \t\t\tstring_list_add_refs_by_glob(c->refs, v);\n \t\telse\n \t\t\twarning(_(\"Refusing to rewrite notes in %s\"\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230306","messageId":"20131109070720.18178.13134.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 34/86] pkt-line: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:27Z","receivedAt":"2013-11-09T07:06:27Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n pkt-line.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/pkt-line.c b/pkt-line.c\nindex 70f1950..d967727 100644\n--- a/pkt-line.c\n+++ b/pkt-line.c\n@@ -24,8 +24,8 @@ static void packet_trace(const char *buf, unsigned int len, int write)\n \tstrbuf_addf(&out, \"packet: %12s%c \",\n \t\t    packet_trace_prefix, write ? '>' : '<');\n \n-\tif ((len >= 4 && !prefixcmp(buf, \"PACK\")) ||\n-\t    (len >= 5 && !prefixcmp(buf+1, \"PACK\"))) {\n+\tif ((len >= 4 && has_prefix(buf, \"PACK\")) ||\n+\t    (len >= 5 && has_prefix(buf+1, \"PACK\"))) {\n \t\tstrbuf_addstr(&out, \"PACK ...\");\n \t\tunsetenv(trace_key);\n \t}\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230295","messageId":"20131109070720.18178.88863.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 35/86] alias: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:28Z","receivedAt":"2013-11-09T07:06:28Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n alias.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/alias.c b/alias.c\nindex eb9f08b..0933c87 100644\n--- a/alias.c\n+++ b/alias.c\n@@ -5,7 +5,7 @@ static char *alias_val;\n \n static int alias_lookup_cb(const char *k, const char *v, void *cb)\n {\n-\tif (!prefixcmp(k, \"alias.\") && !strcmp(k+6, alias_key)) {\n+\tif (has_prefix(k, \"alias.\") && !strcmp(k+6, alias_key)) {\n \t\tif (!v)\n \t\t\treturn config_error_nonbool(k);\n \t\talias_val = xstrdup(v);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230300","messageId":"20131109070720.18178.76499.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 36/86] attr: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:29Z","receivedAt":"2013-11-09T07:06:29Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n attr.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/attr.c b/attr.c\nindex 0e774c6..4c11f30 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -211,7 +211,7 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,\n \tname = cp;\n \tnamelen = strcspn(name, blank);\n \tif (strlen(ATTRIBUTE_MACRO_PREFIX) < namelen &&\n-\t    !prefixcmp(name, ATTRIBUTE_MACRO_PREFIX)) {\n+\t    has_prefix(name, ATTRIBUTE_MACRO_PREFIX)) {\n \t\tif (!macro_ok) {\n \t\t\tfprintf(stderr, \"%s not allowed: %s:%d\\n\",\n \t\t\t\tname, src, lineno);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230302","messageId":"20131109070720.18178.47748.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 37/86] connect: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:30Z","receivedAt":"2013-11-09T07:06:30Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n connect.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/connect.c b/connect.c\nindex 4086861..1cb4090 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -87,7 +87,7 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,\n \t\tif (!len)\n \t\t\tbreak;\n \n-\t\tif (len > 4 && !prefixcmp(buffer, \"ERR \"))\n+\t\tif (len > 4 && has_prefix(buffer, \"ERR \"))\n \t\t\tdie(\"remote error: %s\", buffer + 4);\n \n \t\tif (len < 42 || get_sha1_hex(buffer, old_sha1) || buffer[40] != ' ')\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230297","messageId":"20131109070720.18178.37111.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 38/86] pager: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:31Z","receivedAt":"2013-11-09T07:06:31Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n pager.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/pager.c b/pager.c\nindex fa19765..cd7bc43 100644\n--- a/pager.c\n+++ b/pager.c\n@@ -151,7 +151,7 @@ int decimal_width(int number)\n static int pager_command_config(const char *var, const char *value, void *data)\n {\n \tstruct pager_config *c = data;\n-\tif (!prefixcmp(var, \"pager.\") && !strcmp(var + 6, c->cmd)) {\n+\tif (has_prefix(var, \"pager.\") && !strcmp(var + 6, c->cmd)) {\n \t\tint b = git_config_maybe_bool(var, value);\n \t\tif (b >= 0)\n \t\t\tc->want = b;\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230301","messageId":"20131109070720.18178.716.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 39/86] convert: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:32Z","receivedAt":"2013-11-09T07:06:32Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n convert.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/convert.c b/convert.c\nindex 11a95fc..dc5d3ed 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -1121,7 +1121,7 @@ static int is_foreign_ident(const char *str)\n {\n \tint i;\n \n-\tif (prefixcmp(str, \"$Id: \"))\n+\tif (!has_prefix(str, \"$Id: \"))\n \t\treturn 0;\n \tfor (i = 5; str[i]; i++) {\n \t\tif (isspace(str[i]) && str[i+1] != '$')\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230299","messageId":"20131109070720.18178.63707.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 40/86] environment: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:33Z","receivedAt":"2013-11-09T07:06:33Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n environment.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/environment.c b/environment.c\nindex 378254c..827c6e8 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -176,7 +176,7 @@ const char *get_git_namespace(void)\n \n const char *strip_namespace(const char *namespaced_ref)\n {\n-\tif (prefixcmp(namespaced_ref, get_git_namespace()) != 0)\n+\tif (!has_prefix(namespaced_ref, get_git_namespace()))\n \t\treturn NULL;\n \treturn namespaced_ref + namespace_len;\n }\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230298","messageId":"20131109070720.18178.56673.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 41/86] shell: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:34Z","receivedAt":"2013-11-09T07:06:34Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n shell.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/shell.c b/shell.c\nindex 66350b2..3bbe774 100644\n--- a/shell.c\n+++ b/shell.c\n@@ -15,7 +15,7 @@ static int do_generic_cmd(const char *me, char *arg)\n \tsetup_path();\n \tif (!arg || !(arg = sq_dequote(arg)))\n \t\tdie(\"bad argument\");\n-\tif (prefixcmp(me, \"git-\"))\n+\tif (!has_prefix(me, \"git-\"))\n \t\tdie(\"bad command\");\n \n \tmy_argv[0] = me + 4;\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230294","messageId":"20131109070720.18178.68051.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 42/86] pathspec: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:35Z","receivedAt":"2013-11-09T07:06:35Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n pathspec.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/pathspec.c b/pathspec.c\nindex ad1a9f5..182b162 100644\n--- a/pathspec.c\n+++ b/pathspec.c\n@@ -150,7 +150,7 @@ static unsigned prefix_pathspec(struct pathspec_item *item,\n \t\t\t\t\tmagic |= pathspec_magic[i].bit;\n \t\t\t\t\tbreak;\n \t\t\t\t}\n-\t\t\t\tif (!prefixcmp(copyfrom, \"prefix:\")) {\n+\t\t\t\tif (has_prefix(copyfrom, \"prefix:\")) {\n \t\t\t\t\tchar *endptr;\n \t\t\t\t\tpathspec_prefix = strtol(copyfrom + 7,\n \t\t\t\t\t\t\t\t &endptr, 10);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230307","messageId":"20131109070720.18178.68022.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 43/86] submodule: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:36Z","receivedAt":"2013-11-09T07:06:36Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n submodule.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/submodule.c b/submodule.c\nindex 1905d75..21fe14e 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -201,7 +201,7 @@ void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,\n \n int submodule_config(const char *var, const char *value, void *cb)\n {\n-\tif (!prefixcmp(var, \"submodule.\"))\n+\tif (has_prefix(var, \"submodule.\"))\n \t\treturn parse_submodule_config_option(var, value);\n \telse if (!strcmp(var, \"fetch.recursesubmodules\")) {\n \t\tconfig_fetch_recurse_submodules = parse_fetch_recurse_submodules_arg(var, value);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230293","messageId":"20131109070720.18178.89929.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 44/86] test-string-list: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:37Z","receivedAt":"2013-11-09T07:06:37Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n test-string-list.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/test-string-list.c b/test-string-list.c\nindex 00ce6c9..e04a37c 100644\n--- a/test-string-list.c\n+++ b/test-string-list.c\n@@ -38,7 +38,7 @@ static void write_list_compact(const struct string_list *list)\n static int prefix_cb(struct string_list_item *item, void *cb_data)\n {\n \tconst char *prefix = (const char *)cb_data;\n-\treturn !prefixcmp(item->string, prefix);\n+\treturn has_prefix(item->string, prefix);\n }\n \n int main(int argc, char **argv)\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230292","messageId":"20131109070720.18178.29781.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 45/86] builtin/apply: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:38Z","receivedAt":"2013-11-09T07:06:38Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/apply.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex ef32e4f..49028da 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -1409,10 +1409,10 @@ static void recount_diff(const char *line, int size, struct fragment *fragment)\n \t\tcase '\\\\':\n \t\t\tcontinue;\n \t\tcase '@':\n-\t\t\tret = size < 3 || prefixcmp(line, \"@@ \");\n+\t\t\tret = size < 3 || !has_prefix(line, \"@@ \");\n \t\t\tbreak;\n \t\tcase 'd':\n-\t\t\tret = size < 5 || prefixcmp(line, \"diff \");\n+\t\t\tret = size < 5 || !has_prefix(line, \"diff \");\n \t\t\tbreak;\n \t\tdefault:\n \t\t\tret = -1;\n@@ -1798,11 +1798,11 @@ static struct fragment *parse_binary_hunk(char **buf_p,\n \n \t*status_p = 0;\n \n-\tif (!prefixcmp(buffer, \"delta \")) {\n+\tif (has_prefix(buffer, \"delta \")) {\n \t\tpatch_method = BINARY_DELTA_DEFLATED;\n \t\toriglen = strtoul(buffer + 6, NULL, 10);\n \t}\n-\telse if (!prefixcmp(buffer, \"literal \")) {\n+\telse if (has_prefix(buffer, \"literal \")) {\n \t\tpatch_method = BINARY_LITERAL_DEFLATED;\n \t\toriglen = strtoul(buffer + 8, NULL, 10);\n \t}\n@@ -3627,12 +3627,12 @@ static int preimage_sha1_in_gitlink_patch(struct patch *p, unsigned char sha1[20\n \t    hunk->oldpos == 1 && hunk->oldlines == 1 &&\n \t    /* does preimage begin with the heading? */\n \t    (preimage = memchr(hunk->patch, '\\n', hunk->size)) != NULL &&\n-\t    !prefixcmp(++preimage, heading) &&\n+\t    has_prefix(++preimage, heading) &&\n \t    /* does it record full SHA-1? */\n \t    !get_sha1_hex(preimage + sizeof(heading) - 1, sha1) &&\n \t    preimage[sizeof(heading) + 40 - 1] == '\\n' &&\n \t    /* does the abbreviated name on the index line agree with it? */\n-\t    !prefixcmp(preimage + sizeof(heading) - 1, p->old_sha1_prefix))\n+\t    has_prefix(preimage + sizeof(heading) - 1, p->old_sha1_prefix))\n \t\treturn 0; /* it all looks fine */\n \n \t/* we may have full object name on the index line */\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230285","messageId":"20131109070720.18178.2112.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 46/86] builtin/archive: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:39Z","receivedAt":"2013-11-09T07:06:39Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/archive.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/archive.c b/builtin/archive.c\nindex 49178f1..b808bb5 100644\n--- a/builtin/archive.c\n+++ b/builtin/archive.c\n@@ -57,9 +57,9 @@ static int run_remote_archiver(int argc, const char **argv,\n \tif (!buf)\n \t\tdie(_(\"git archive: expected ACK/NAK, got EOF\"));\n \tif (strcmp(buf, \"ACK\")) {\n-\t\tif (!prefixcmp(buf, \"NACK \"))\n+\t\tif (has_prefix(buf, \"NACK \"))\n \t\t\tdie(_(\"git archive: NACK %s\"), buf + 5);\n-\t\tif (!prefixcmp(buf, \"ERR \"))\n+\t\tif (has_prefix(buf, \"ERR \"))\n \t\t\tdie(_(\"remote error: %s\"), buf + 4);\n \t\tdie(_(\"git archive: protocol error\"));\n \t}\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230291","messageId":"20131109070720.18178.39137.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 47/86] builtin/branch: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:40Z","receivedAt":"2013-11-09T07:06:40Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/branch.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex ad0f86d..c4cb81c 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -81,13 +81,13 @@ static int parse_branch_color_slot(const char *var, int ofs)\n \n static int git_branch_config(const char *var, const char *value, void *cb)\n {\n-\tif (!prefixcmp(var, \"column.\"))\n+\tif (has_prefix(var, \"column.\"))\n \t\treturn git_column_config(var, value, \"branch\", &colopts);\n \tif (!strcmp(var, \"color.branch\")) {\n \t\tbranch_use_color = git_config_colorbool(var, value);\n \t\treturn 0;\n \t}\n-\tif (!prefixcmp(var, \"color.branch.\")) {\n+\tif (has_prefix(var, \"color.branch.\")) {\n \t\tint slot = parse_branch_color_slot(var, 13);\n \t\tif (slot < 0)\n \t\t\treturn 0;\n@@ -862,7 +862,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \tif (!strcmp(head, \"HEAD\")) {\n \t\tdetached = 1;\n \t} else {\n-\t\tif (prefixcmp(head, \"refs/heads/\"))\n+\t\tif (!has_prefix(head, \"refs/heads/\"))\n \t\t\tdie(_(\"HEAD not found below refs/heads!\"));\n \t\thead += 11;\n \t}\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230290","messageId":"20131109070720.18178.2421.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 48/86] builtin/checkout: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:41Z","receivedAt":"2013-11-09T07:06:41Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/checkout.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 0f57397..7ce15dd 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -781,7 +781,7 @@ static int switch_branches(const struct checkout_opts *opts,\n \tif (!(flag & REF_ISSYMREF))\n \t\told.path = NULL;\n \n-\tif (old.path && !prefixcmp(old.path, \"refs/heads/\"))\n+\tif (old.path && has_prefix(old.path, \"refs/heads/\"))\n \t\told.name = old.path + strlen(\"refs/heads/\");\n \n \tif (!new->name) {\n@@ -816,7 +816,7 @@ static int git_checkout_config(const char *var, const char *value, void *cb)\n \t\treturn 0;\n \t}\n \n-\tif (!prefixcmp(var, \"submodule.\"))\n+\tif (has_prefix(var, \"submodule.\"))\n \t\treturn parse_submodule_config_option(var, value);\n \n \treturn git_xmerge_config(var, value, NULL);\n@@ -1108,9 +1108,9 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \t\tconst char *argv0 = argv[0];\n \t\tif (!argc || !strcmp(argv0, \"--\"))\n \t\t\tdie (_(\"--track needs a branch name\"));\n-\t\tif (!prefixcmp(argv0, \"refs/\"))\n+\t\tif (has_prefix(argv0, \"refs/\"))\n \t\t\targv0 += 5;\n-\t\tif (!prefixcmp(argv0, \"remotes/\"))\n+\t\tif (has_prefix(argv0, \"remotes/\"))\n \t\t\targv0 += 8;\n \t\targv0 = strchr(argv0, '/');\n \t\tif (!argv0 || !argv0[1])\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230288","messageId":"20131109070720.18178.14270.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 49/86] builtin/clean: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:42Z","receivedAt":"2013-11-09T07:06:42Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/clean.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/clean.c b/builtin/clean.c\nindex 615cd57..98887cd 100644\n--- a/builtin/clean.c\n+++ b/builtin/clean.c\n@@ -100,7 +100,7 @@ static int parse_clean_color_slot(const char *var)\n \n static int git_clean_config(const char *var, const char *value, void *cb)\n {\n-\tif (!prefixcmp(var, \"column.\"))\n+\tif (has_prefix(var, \"column.\"))\n \t\treturn git_column_config(var, value, \"clean\", &colopts);\n \n \t/* honors the color.interactive* config variables which also\n@@ -109,7 +109,7 @@ static int git_clean_config(const char *var, const char *value, void *cb)\n \t\tclean_use_color = git_config_colorbool(var, value);\n \t\treturn 0;\n \t}\n-\tif (!prefixcmp(var, \"color.interactive.\")) {\n+\tif (has_prefix(var, \"color.interactive.\")) {\n \t\tint slot = parse_clean_color_slot(var +\n \t\t\t\t\t\t  strlen(\"color.interactive.\"));\n \t\tif (slot < 0)\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230289","messageId":"20131109070720.18178.10765.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 50/86] builtin/clone: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:43Z","receivedAt":"2013-11-09T07:06:43Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/clone.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 84fb1bd..49b7a08 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -508,7 +508,7 @@ static void write_followtags(const struct ref *refs, const char *msg)\n {\n \tconst struct ref *ref;\n \tfor (ref = refs; ref; ref = ref->next) {\n-\t\tif (prefixcmp(ref->name, \"refs/tags/\"))\n+\t\tif (!has_prefix(ref->name, \"refs/tags/\"))\n \t\t\tcontinue;\n \t\tif (has_suffix(ref->name, \"^{}\"))\n \t\t\tcontinue;\n@@ -578,7 +578,7 @@ static void update_remote_refs(const struct ref *refs,\n static void update_head(const struct ref *our, const struct ref *remote,\n \t\t\tconst char *msg)\n {\n-\tif (our && !prefixcmp(our->name, \"refs/heads/\")) {\n+\tif (our && has_prefix(our->name, \"refs/heads/\")) {\n \t\t/* Local default branch link */\n \t\tcreate_symref(\"HEAD\", our->name, NULL);\n \t\tif (!option_bare) {\n@@ -625,7 +625,7 @@ static int checkout(void)\n \t\tif (advice_detached_head)\n \t\t\tdetach_advice(sha1_to_hex(sha1));\n \t} else {\n-\t\tif (prefixcmp(head, \"refs/heads/\"))\n+\t\tif (!has_prefix(head, \"refs/heads/\"))\n \t\t\tdie(_(\"HEAD not found below refs/heads!\"));\n \t}\n \tfree(head);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230284","messageId":"20131109070720.18178.99199.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 51/86] builtin/column: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:44Z","receivedAt":"2013-11-09T07:06:44Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/column.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/column.c b/builtin/column.c\nindex e125a55..3664cc1 100644\n--- a/builtin/column.c\n+++ b/builtin/column.c\n@@ -34,7 +34,7 @@ int cmd_column(int argc, const char **argv, const char *prefix)\n \t};\n \n \t/* This one is special and must be the first one */\n-\tif (argc > 1 && !prefixcmp(argv[1], \"--command=\")) {\n+\tif (argc > 1 && has_prefix(argv[1], \"--command=\")) {\n \t\tcommand = argv[1] + 10;\n \t\tgit_config(column_config, (void *)command);\n \t} else\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230286","messageId":"20131109070720.18178.60526.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 52/86] builtin/commit: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:45Z","receivedAt":"2013-11-09T07:06:45Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/commit.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 6ab4605..a8c46c6 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -733,7 +733,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\t\t\teol = nl - sb.buf;\n \t\t\telse\n \t\t\t\teol = sb.len;\n-\t\t\tif (!prefixcmp(sb.buf + previous, \"\\nConflicts:\\n\")) {\n+\t\t\tif (has_prefix(sb.buf + previous, \"\\nConflicts:\\n\")) {\n \t\t\t\tignore_footer = sb.len - previous;\n \t\t\t\tbreak;\n \t\t\t}\n@@ -904,7 +904,7 @@ static int rest_is_empty(struct strbuf *sb, int start)\n \t\t\teol = sb->len;\n \n \t\tif (strlen(sign_off_header) <= eol - i &&\n-\t\t    !prefixcmp(sb->buf + i, sign_off_header)) {\n+\t\t    has_prefix(sb->buf + i, sign_off_header)) {\n \t\t\ti = eol;\n \t\t\tcontinue;\n \t\t}\n@@ -1183,7 +1183,7 @@ static int git_status_config(const char *k, const char *v, void *cb)\n {\n \tstruct wt_status *s = cb;\n \n-\tif (!prefixcmp(k, \"column.\"))\n+\tif (has_prefix(k, \"column.\"))\n \t\treturn git_column_config(k, v, \"status\", &s->colopts);\n \tif (!strcmp(k, \"status.submodulesummary\")) {\n \t\tint is_bool;\n@@ -1211,7 +1211,7 @@ static int git_status_config(const char *k, const char *v, void *cb)\n \t\ts->display_comment_prefix = git_config_bool(k, v);\n \t\treturn 0;\n \t}\n-\tif (!prefixcmp(k, \"status.color.\") || !prefixcmp(k, \"color.status.\")) {\n+\tif (has_prefix(k, \"status.color.\") || has_prefix(k, \"color.status.\")) {\n \t\tint slot = parse_status_slot(k, 13);\n \t\tif (slot < 0)\n \t\t\treturn 0;\n@@ -1377,7 +1377,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1,\n \n \thead = resolve_ref_unsafe(\"HEAD\", junk_sha1, 0, NULL);\n \tprintf(\"[%s%s \",\n-\t\t!prefixcmp(head, \"refs/heads/\") ?\n+\t\thas_prefix(head, \"refs/heads/\") ?\n \t\t\thead + 11 :\n \t\t\t!strcmp(head, \"HEAD\") ?\n \t\t\t\t_(\"detached HEAD\") :\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230287","messageId":"20131109070720.18178.41233.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 53/86] builtin/describe: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:46Z","receivedAt":"2013-11-09T07:06:46Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/describe.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex b9d3603..102d958 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -141,7 +141,7 @@ static void add_to_known_names(const char *path,\n \n static int get_name(const char *path, const unsigned char *sha1, int flag, void *cb_data)\n {\n-\tint is_tag = !prefixcmp(path, \"refs/tags/\");\n+\tint is_tag = has_prefix(path, \"refs/tags/\");\n \tunsigned char peeled[20];\n \tint is_annotated, prio;\n \n-- \n1.8.4.1.566.geca833c\n"},{"id":"230279","messageId":"20131109070720.18178.44653.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 54/86] builtin/fast-export: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:47Z","receivedAt":"2013-11-09T07:06:47Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/fast-export.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 78250ea..8a9136b 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -476,7 +476,7 @@ static void handle_tag(const char *name, struct tag *tag)\n \t\t}\n \t}\n \n-\tif (!prefixcmp(name, \"refs/tags/\"))\n+\tif (has_prefix(name, \"refs/tags/\"))\n \t\tname += 10;\n \tprintf(\"tag %s\\nfrom :%d\\n%.*s%sdata %d\\n%.*s\\n\",\n \t       name, tagged_mark,\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230281","messageId":"20131109070720.18178.20584.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 55/86] builtin/fetch-pack: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:48Z","receivedAt":"2013-11-09T07:06:48Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/fetch-pack.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c\nindex c8e8582..29a3b33 100644\n--- a/builtin/fetch-pack.c\n+++ b/builtin/fetch-pack.c\n@@ -48,11 +48,11 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)\n \tfor (i = 1; i < argc && *argv[i] == '-'; i++) {\n \t\tconst char *arg = argv[i];\n \n-\t\tif (!prefixcmp(arg, \"--upload-pack=\")) {\n+\t\tif (has_prefix(arg, \"--upload-pack=\")) {\n \t\t\targs.uploadpack = arg + 14;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--exec=\")) {\n+\t\tif (has_prefix(arg, \"--exec=\")) {\n \t\t\targs.uploadpack = arg + 7;\n \t\t\tcontinue;\n \t\t}\n@@ -85,7 +85,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)\n \t\t\targs.verbose = 1;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--depth=\")) {\n+\t\tif (has_prefix(arg, \"--depth=\")) {\n \t\t\targs.depth = strtol(arg + 8, NULL, 0);\n \t\t\tcontinue;\n \t\t}\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230283","messageId":"20131109070720.18178.30355.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 56/86] builtin/fetch: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:49Z","receivedAt":"2013-11-09T07:06:49Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/fetch.c | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 8eb6cd0..78d4add 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -313,7 +313,7 @@ static int update_local_ref(struct ref *ref,\n \t}\n \n \tif (!is_null_sha1(ref->old_sha1) &&\n-\t    !prefixcmp(ref->name, \"refs/tags/\")) {\n+\t    has_prefix(ref->name, \"refs/tags/\")) {\n \t\tint r;\n \t\tr = s_update_ref(\"updating tag\", ref, 0);\n \t\tstrbuf_addf(display, \"%c %-*s %-*s -> %s%s\",\n@@ -336,10 +336,10 @@ static int update_local_ref(struct ref *ref,\n \t\t * more likely to follow a standard layout.\n \t\t */\n \t\tconst char *name = remote_ref ? remote_ref->name : \"\";\n-\t\tif (!prefixcmp(name, \"refs/tags/\")) {\n+\t\tif (has_prefix(name, \"refs/tags/\")) {\n \t\t\tmsg = \"storing tag\";\n \t\t\twhat = _(\"[new tag]\");\n-\t\t} else if (!prefixcmp(name, \"refs/heads/\")) {\n+\t\t} else if (has_prefix(name, \"refs/heads/\")) {\n \t\t\tmsg = \"storing head\";\n \t\t\twhat = _(\"[new branch]\");\n \t\t} else {\n@@ -471,15 +471,15 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n \t\t\t\tkind = \"\";\n \t\t\t\twhat = \"\";\n \t\t\t}\n-\t\t\telse if (!prefixcmp(rm->name, \"refs/heads/\")) {\n+\t\t\telse if (has_prefix(rm->name, \"refs/heads/\")) {\n \t\t\t\tkind = \"branch\";\n \t\t\t\twhat = rm->name + 11;\n \t\t\t}\n-\t\t\telse if (!prefixcmp(rm->name, \"refs/tags/\")) {\n+\t\t\telse if (has_prefix(rm->name, \"refs/tags/\")) {\n \t\t\t\tkind = \"tag\";\n \t\t\t\twhat = rm->name + 10;\n \t\t\t}\n-\t\t\telse if (!prefixcmp(rm->name, \"refs/remotes/\")) {\n+\t\t\telse if (has_prefix(rm->name, \"refs/remotes/\")) {\n \t\t\t\tkind = \"remote-tracking branch\";\n \t\t\t\twhat = rm->name + 13;\n \t\t\t}\n@@ -644,7 +644,7 @@ static void find_non_local_tags(struct transport *transport,\n \n \tfor_each_ref(add_existing, &existing_refs);\n \tfor (ref = transport_get_remote_refs(transport); ref; ref = ref->next) {\n-\t\tif (prefixcmp(ref->name, \"refs/tags/\"))\n+\t\tif (!has_prefix(ref->name, \"refs/tags/\"))\n \t\t\tcontinue;\n \n \t\t/*\n@@ -892,7 +892,7 @@ static int get_remote_group(const char *key, const char *value, void *priv)\n {\n \tstruct remote_group_data *g = priv;\n \n-\tif (!prefixcmp(key, \"remotes.\") &&\n+\tif (has_prefix(key, \"remotes.\") &&\n \t\t\t!strcmp(key + 8, g->name)) {\n \t\t/* split list by white space */\n \t\tint space = strcspn(value, \" \\t\\n\");\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230280","messageId":"20131109070720.18178.90016.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 57/86] builtin/fmt-merge-msg: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:50Z","receivedAt":"2013-11-09T07:06:50Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/fmt-merge-msg.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex 1c04070..09a55bf 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -109,7 +109,7 @@ static int handle_line(char *line, struct merge_parents *merge_parents)\n \tif (len < 43 || line[40] != '\\t')\n \t\treturn 1;\n \n-\tif (!prefixcmp(line + 41, \"not-for-merge\"))\n+\tif (has_prefix(line + 41, \"not-for-merge\"))\n \t\treturn 0;\n \n \tif (line[41] != '\\t')\n@@ -155,16 +155,16 @@ static int handle_line(char *line, struct merge_parents *merge_parents)\n \tif (pulling_head) {\n \t\torigin = src;\n \t\tsrc_data->head_status |= 1;\n-\t} else if (!prefixcmp(line, \"branch \")) {\n+\t} else if (has_prefix(line, \"branch \")) {\n \t\torigin_data->is_local_branch = 1;\n \t\torigin = line + 7;\n \t\tstring_list_append(&src_data->branch, origin);\n \t\tsrc_data->head_status |= 2;\n-\t} else if (!prefixcmp(line, \"tag \")) {\n+\t} else if (has_prefix(line, \"tag \")) {\n \t\torigin = line;\n \t\tstring_list_append(&src_data->tag, origin + 4);\n \t\tsrc_data->head_status |= 2;\n-\t} else if (!prefixcmp(line, \"remote-tracking branch \")) {\n+\t} else if (has_prefix(line, \"remote-tracking branch \")) {\n \t\torigin = line + strlen(\"remote-tracking branch \");\n \t\tstring_list_append(&src_data->r_branch, origin);\n \t\tsrc_data->head_status |= 2;\n@@ -605,7 +605,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,\n \t\tresolve_refdup(\"HEAD\", head_sha1, 1, NULL);\n \tif (!current_branch)\n \t\tdie(\"No current branch\");\n-\tif (!prefixcmp(current_branch, \"refs/heads/\"))\n+\tif (has_prefix(current_branch, \"refs/heads/\"))\n \t\tcurrent_branch += 11;\n \n \tfind_merge_parents(&merge_parents, in, head_sha1);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230282","messageId":"20131109070720.18178.435.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 58/86] builtin/for-each-ref: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:51Z","receivedAt":"2013-11-09T07:06:51Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/for-each-ref.c | 14 +++++++-------\n 1 file changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c\nindex 1d4083c..c22f200 100644\n--- a/builtin/for-each-ref.c\n+++ b/builtin/for-each-ref.c\n@@ -432,7 +432,7 @@ static void grab_person(const char *who, struct atom_value *val, int deref, stru\n \t\tif (name[wholen] != 0 &&\n \t\t    strcmp(name + wholen, \"name\") &&\n \t\t    strcmp(name + wholen, \"email\") &&\n-\t\t    prefixcmp(name + wholen, \"date\"))\n+\t\t    !has_prefix(name + wholen, \"date\"))\n \t\t\tcontinue;\n \t\tif (!wholine)\n \t\t\twholine = find_wholine(who, wholen, buf, sz);\n@@ -444,7 +444,7 @@ static void grab_person(const char *who, struct atom_value *val, int deref, stru\n \t\t\tv->s = copy_name(wholine);\n \t\telse if (!strcmp(name + wholen, \"email\"))\n \t\t\tv->s = copy_email(wholine);\n-\t\telse if (!prefixcmp(name + wholen, \"date\"))\n+\t\telse if (has_prefix(name + wholen, \"date\"))\n \t\t\tgrab_date(wholine, v, name);\n \t}\n \n@@ -466,7 +466,7 @@ static void grab_person(const char *who, struct atom_value *val, int deref, stru\n \t\tif (deref)\n \t\t\tname++;\n \n-\t\tif (!prefixcmp(name, \"creatordate\"))\n+\t\tif (has_prefix(name, \"creatordate\"))\n \t\t\tgrab_date(wholine, v, name);\n \t\telse if (!strcmp(name, \"creator\"))\n \t\t\tv->s = copy_line(wholine);\n@@ -646,14 +646,14 @@ static void populate_value(struct refinfo *ref)\n \t\t\tname++;\n \t\t}\n \n-\t\tif (!prefixcmp(name, \"refname\"))\n+\t\tif (has_prefix(name, \"refname\"))\n \t\t\trefname = ref->refname;\n-\t\telse if (!prefixcmp(name, \"symref\"))\n+\t\telse if (has_prefix(name, \"symref\"))\n \t\t\trefname = ref->symref ? ref->symref : \"\";\n-\t\telse if (!prefixcmp(name, \"upstream\")) {\n+\t\telse if (has_prefix(name, \"upstream\")) {\n \t\t\tstruct branch *branch;\n \t\t\t/* only local branches may have an upstream */\n-\t\t\tif (prefixcmp(ref->refname, \"refs/heads/\"))\n+\t\t\tif (!has_prefix(ref->refname, \"refs/heads/\"))\n \t\t\t\tcontinue;\n \t\t\tbranch = branch_get(ref->refname + 11);\n \n-- \n1.8.4.1.566.geca833c\n"},{"id":"230278","messageId":"20131109070720.18178.73487.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 59/86] builtin/fsck: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:52Z","receivedAt":"2013-11-09T07:06:52Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/fsck.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 97ce678..a80e51f 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -442,7 +442,7 @@ static void fsck_dir(int i, char *path)\n \t\t\tadd_sha1_list(sha1, DIRENT_SORT_HINT(de));\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(de->d_name, \"tmp_obj_\"))\n+\t\tif (has_prefix(de->d_name, \"tmp_obj_\"))\n \t\t\tcontinue;\n \t\tfprintf(stderr, \"bad sha1 file: %s/%s\\n\", path, de->d_name);\n \t}\n@@ -484,7 +484,7 @@ static int fsck_handle_reflog(const char *logname, const unsigned char *sha1, in\n \n static int is_branch(const char *refname)\n {\n-\treturn !strcmp(refname, \"HEAD\") || !prefixcmp(refname, \"refs/heads/\");\n+\treturn !strcmp(refname, \"HEAD\") || has_prefix(refname, \"refs/heads/\");\n }\n \n static int fsck_handle_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)\n@@ -566,7 +566,7 @@ static int fsck_head_link(void)\n \tif (!strcmp(head_points_at, \"HEAD\"))\n \t\t/* detached HEAD */\n \t\tnull_is_error = 1;\n-\telse if (prefixcmp(head_points_at, \"refs/heads/\"))\n+\telse if (!has_prefix(head_points_at, \"refs/heads/\"))\n \t\treturn error(\"HEAD points to something strange (%s)\",\n \t\t\t     head_points_at);\n \tif (is_null_sha1(head_sha1)) {\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230351","messageId":"20131109070720.18178.6476.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 60/86] builtin/help: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:53Z","receivedAt":"2013-11-09T07:06:53Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/help.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/help.c b/builtin/help.c\nindex f1e236b..2478e9a 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -100,7 +100,7 @@ static int check_emacsclient_version(void)\n \t */\n \tfinish_command(&ec_process);\n \n-\tif (prefixcmp(buffer.buf, \"emacsclient\")) {\n+\tif (!has_prefix(buffer.buf, \"emacsclient\")) {\n \t\tstrbuf_release(&buffer);\n \t\treturn error(_(\"Failed to parse emacsclient version.\"));\n \t}\n@@ -258,7 +258,7 @@ static int add_man_viewer_info(const char *var, const char *value)\n \n static int git_help_config(const char *var, const char *value, void *cb)\n {\n-\tif (!prefixcmp(var, \"column.\"))\n+\tif (has_prefix(var, \"column.\"))\n \t\treturn git_column_config(var, value, \"help\", &colopts);\n \tif (!strcmp(var, \"help.format\")) {\n \t\tif (!value)\n@@ -278,7 +278,7 @@ static int git_help_config(const char *var, const char *value, void *cb)\n \t\tadd_man_viewer(value);\n \t\treturn 0;\n \t}\n-\tif (!prefixcmp(var, \"man.\"))\n+\tif (has_prefix(var, \"man.\"))\n \t\treturn add_man_viewer_info(var, value);\n \n \treturn git_default_config(var, value, cb);\n@@ -306,7 +306,7 @@ static const char *cmd_to_page(const char *git_cmd)\n {\n \tif (!git_cmd)\n \t\treturn \"git\";\n-\telse if (!prefixcmp(git_cmd, \"git\"))\n+\telse if (has_prefix(git_cmd, \"git\"))\n \t\treturn git_cmd;\n \telse if (is_git_command(git_cmd))\n \t\treturn prepend(\"git-\", git_cmd);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230341","messageId":"20131109070720.18178.94111.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 61/86] builtin/index-pack: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:54Z","receivedAt":"2013-11-09T07:06:54Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/index-pack.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 9e9eb4b..183cf1f 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -1534,9 +1534,9 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)\n \t\t\t\tstat_only = 1;\n \t\t\t} else if (!strcmp(arg, \"--keep\")) {\n \t\t\t\tkeep_msg = \"\";\n-\t\t\t} else if (!prefixcmp(arg, \"--keep=\")) {\n+\t\t\t} else if (has_prefix(arg, \"--keep=\")) {\n \t\t\t\tkeep_msg = arg + 7;\n-\t\t\t} else if (!prefixcmp(arg, \"--threads=\")) {\n+\t\t\t} else if (has_prefix(arg, \"--threads=\")) {\n \t\t\t\tchar *end;\n \t\t\t\tnr_threads = strtoul(arg+10, &end, 0);\n \t\t\t\tif (!arg[10] || *end || nr_threads < 0)\n@@ -1547,7 +1547,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)\n \t\t\t\t\t\t  \"ignoring %s\"), arg);\n \t\t\t\tnr_threads = 1;\n #endif\n-\t\t\t} else if (!prefixcmp(arg, \"--pack_header=\")) {\n+\t\t\t} else if (has_prefix(arg, \"--pack_header=\")) {\n \t\t\t\tstruct pack_header *hdr;\n \t\t\t\tchar *c;\n \n@@ -1566,7 +1566,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)\n \t\t\t\tif (index_name || (i+1) >= argc)\n \t\t\t\t\tusage(index_pack_usage);\n \t\t\t\tindex_name = argv[++i];\n-\t\t\t} else if (!prefixcmp(arg, \"--index-version=\")) {\n+\t\t\t} else if (has_prefix(arg, \"--index-version=\")) {\n \t\t\t\tchar *c;\n \t\t\t\topts.version = strtoul(arg + 16, &c, 10);\n \t\t\t\tif (opts.version > 2)\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230350","messageId":"20131109070720.18178.93850.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 62/86] builtin/init-db: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:55Z","receivedAt":"2013-11-09T07:06:55Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/init-db.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/init-db.c b/builtin/init-db.c\nindex 78aa387..7fe9d8c 100644\n--- a/builtin/init-db.c\n+++ b/builtin/init-db.c\n@@ -266,7 +266,7 @@ static int create_default_files(const char *template_path)\n \t\t/* allow template config file to override the default */\n \t\tif (log_all_ref_updates == -1)\n \t\t    git_config_set(\"core.logallrefupdates\", \"true\");\n-\t\tif (prefixcmp(git_dir, work_tree) ||\n+\t\tif (!has_prefix(git_dir, work_tree) ||\n \t\t    strcmp(git_dir + strlen(work_tree), \"/.git\")) {\n \t\t\tgit_config_set(\"core.worktree\", work_tree);\n \t\t}\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230349","messageId":"20131109070720.18178.86174.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 63/86] builtin/log: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:56Z","receivedAt":"2013-11-09T07:06:56Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/log.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 77d0f5f..054e663 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -390,7 +390,7 @@ static int git_log_config(const char *var, const char *value, void *cb)\n \t\tdefault_show_root = git_config_bool(var, value);\n \t\treturn 0;\n \t}\n-\tif (!prefixcmp(var, \"color.decorate.\"))\n+\tif (has_prefix(var, \"color.decorate.\"))\n \t\treturn parse_decorate_color_config(var, 15, value);\n \tif (!strcmp(var, \"log.mailmap\")) {\n \t\tuse_mailmap_config = git_config_bool(var, value);\n@@ -457,7 +457,7 @@ static int show_tag_object(const unsigned char *sha1, struct rev_info *rev)\n \t\tint new_offset = offset + 1;\n \t\twhile (new_offset < size && buf[new_offset++] != '\\n')\n \t\t\t; /* do nothing */\n-\t\tif (!prefixcmp(buf + offset, \"tagger \"))\n+\t\tif (has_prefix(buf + offset, \"tagger \"))\n \t\t\tshow_tagger(buf + offset + 7,\n \t\t\t\t    new_offset - offset - 7, rev);\n \t\toffset = new_offset;\n@@ -862,7 +862,7 @@ static char *find_branch_name(struct rev_info *rev)\n \tref = rev->cmdline.rev[positive].name;\n \ttip_sha1 = rev->cmdline.rev[positive].item->sha1;\n \tif (dwim_ref(ref, strlen(ref), branch_sha1, &full_ref) &&\n-\t    !prefixcmp(full_ref, \"refs/heads/\") &&\n+\t    has_prefix(full_ref, \"refs/heads/\") &&\n \t    !hashcmp(tip_sha1, branch_sha1))\n \t\tbranch = xstrdup(full_ref + strlen(\"refs/heads/\"));\n \tfree(full_ref);\n@@ -1368,7 +1368,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\t\tunsigned char sha1[20];\n \t\t\tconst char *ref;\n \t\t\tref = resolve_ref_unsafe(\"HEAD\", sha1, 1, NULL);\n-\t\t\tif (ref && !prefixcmp(ref, \"refs/heads/\"))\n+\t\t\tif (ref && has_prefix(ref, \"refs/heads/\"))\n \t\t\t\tbranch_name = xstrdup(ref + strlen(\"refs/heads/\"));\n \t\t\telse\n \t\t\t\tbranch_name = xstrdup(\"\"); /* no branch */\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230348","messageId":"20131109070720.18178.77768.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 64/86] builtin/ls-remote: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:57Z","receivedAt":"2013-11-09T07:06:57Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/ls-remote.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex 25e83cf..9050072 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -50,11 +50,11 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \t\tconst char *arg = argv[i];\n \n \t\tif (*arg == '-') {\n-\t\t\tif (!prefixcmp(arg, \"--upload-pack=\")) {\n+\t\t\tif (has_prefix(arg, \"--upload-pack=\")) {\n \t\t\t\tuploadpack = arg + 14;\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tif (!prefixcmp(arg, \"--exec=\")) {\n+\t\t\tif (has_prefix(arg, \"--exec=\")) {\n \t\t\t\tuploadpack = arg + 7;\n \t\t\t\tcontinue;\n \t\t\t}\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230347","messageId":"20131109070720.18178.13895.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 65/86] builtin/mailinfo: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:58Z","receivedAt":"2013-11-09T07:06:58Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/mailinfo.c | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin/mailinfo.c b/builtin/mailinfo.c\nindex 24a772d..c5da04c 100644\n--- a/builtin/mailinfo.c\n+++ b/builtin/mailinfo.c\n@@ -328,11 +328,11 @@ static int check_header(const struct strbuf *line,\n \t}\n \n \t/* for inbody stuff */\n-\tif (!prefixcmp(line->buf, \">From\") && isspace(line->buf[5])) {\n+\tif (has_prefix(line->buf, \">From\") && isspace(line->buf[5])) {\n \t\tret = 1; /* Should this return 0? */\n \t\tgoto check_header_out;\n \t}\n-\tif (!prefixcmp(line->buf, \"[PATCH]\") && isspace(line->buf[7])) {\n+\tif (has_prefix(line->buf, \"[PATCH]\") && isspace(line->buf[7])) {\n \t\tfor (i = 0; header[i]; i++) {\n \t\t\tif (!memcmp(\"Subject\", header[i], 7)) {\n \t\t\t\thandle_header(&hdr_data[i], line);\n@@ -361,7 +361,7 @@ static int is_rfc2822_header(const struct strbuf *line)\n \tchar *cp = line->buf;\n \n \t/* Count mbox From headers as headers */\n-\tif (!prefixcmp(cp, \"From \") || !prefixcmp(cp, \">From \"))\n+\tif (has_prefix(cp, \"From \") || has_prefix(cp, \">From \"))\n \t\treturn 1;\n \n \twhile ((ch = *cp++)) {\n@@ -671,11 +671,11 @@ static inline int patchbreak(const struct strbuf *line)\n \tsize_t i;\n \n \t/* Beginning of a \"diff -\" header? */\n-\tif (!prefixcmp(line->buf, \"diff -\"))\n+\tif (has_prefix(line->buf, \"diff -\"))\n \t\treturn 1;\n \n \t/* CVS \"Index: \" line? */\n-\tif (!prefixcmp(line->buf, \"Index: \"))\n+\tif (has_prefix(line->buf, \"Index: \"))\n \t\treturn 1;\n \n \t/*\n@@ -685,7 +685,7 @@ static inline int patchbreak(const struct strbuf *line)\n \tif (line->len < 4)\n \t\treturn 0;\n \n-\tif (!prefixcmp(line->buf, \"---\")) {\n+\tif (has_prefix(line->buf, \"---\")) {\n \t\t/* space followed by a filename? */\n \t\tif (line->buf[3] == ' ' && !isspace(line->buf[4]))\n \t\t\treturn 1;\n@@ -986,7 +986,7 @@ static int mailinfo(FILE *in, FILE *out, const char *msg, const char *patch)\n \n static int git_mailinfo_config(const char *var, const char *value, void *unused)\n {\n-\tif (prefixcmp(var, \"mailinfo.\"))\n+\tif (!has_prefix(var, \"mailinfo.\"))\n \t\treturn git_default_config(var, value, unused);\n \tif (!strcmp(var, \"mailinfo.scissors\")) {\n \t\tuse_scissors = git_config_bool(var, value);\n@@ -1020,7 +1020,7 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix)\n \t\t\tmetainfo_charset = def_charset;\n \t\telse if (!strcmp(argv[1], \"-n\"))\n \t\t\tmetainfo_charset = NULL;\n-\t\telse if (!prefixcmp(argv[1], \"--encoding=\"))\n+\t\telse if (has_prefix(argv[1], \"--encoding=\"))\n \t\t\tmetainfo_charset = argv[1] + 11;\n \t\telse if (!strcmp(argv[1], \"--scissors\"))\n \t\t\tuse_scissors = 1;\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230346","messageId":"20131109070720.18178.38648.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 66/86] builtin/merge-recursive: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:06:59Z","receivedAt":"2013-11-09T07:06:59Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/merge-recursive.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c\nindex e7f1a39..73896dc 100644\n--- a/builtin/merge-recursive.c\n+++ b/builtin/merge-recursive.c\n@@ -38,7 +38,7 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)\n \tfor (i = 1; i < argc; ++i) {\n \t\tconst char *arg = argv[i];\n \n-\t\tif (!prefixcmp(arg, \"--\")) {\n+\t\tif (has_prefix(arg, \"--\")) {\n \t\t\tif (!arg[2])\n \t\t\t\tbreak;\n \t\t\tif (parse_merge_opt(&o, arg + 2))\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230325","messageId":"20131109070720.18178.28589.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 67/86] builtin/merge: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:00Z","receivedAt":"2013-11-09T07:07:00Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/merge.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 02a69c1..5c70cec 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -453,17 +453,17 @@ static void merge_name(const char *remote, struct strbuf *msg)\n \t\tdie(_(\"'%s' does not point to a commit\"), remote);\n \n \tif (dwim_ref(remote, strlen(remote), branch_head, &found_ref) > 0) {\n-\t\tif (!prefixcmp(found_ref, \"refs/heads/\")) {\n+\t\tif (has_prefix(found_ref, \"refs/heads/\")) {\n \t\t\tstrbuf_addf(msg, \"%s\\t\\tbranch '%s' of .\\n\",\n \t\t\t\t    sha1_to_hex(branch_head), remote);\n \t\t\tgoto cleanup;\n \t\t}\n-\t\tif (!prefixcmp(found_ref, \"refs/tags/\")) {\n+\t\tif (has_prefix(found_ref, \"refs/tags/\")) {\n \t\t\tstrbuf_addf(msg, \"%s\\t\\ttag '%s' of .\\n\",\n \t\t\t\t    sha1_to_hex(branch_head), remote);\n \t\t\tgoto cleanup;\n \t\t}\n-\t\tif (!prefixcmp(found_ref, \"refs/remotes/\")) {\n+\t\tif (has_prefix(found_ref, \"refs/remotes/\")) {\n \t\t\tstrbuf_addf(msg, \"%s\\t\\tremote-tracking branch '%s' of .\\n\",\n \t\t\t\t    sha1_to_hex(branch_head), remote);\n \t\t\tgoto cleanup;\n@@ -577,8 +577,8 @@ static int git_merge_config(const char *k, const char *v, void *cb)\n {\n \tint status;\n \n-\tif (branch && !prefixcmp(k, \"branch.\") &&\n-\t\t!prefixcmp(k + 7, branch) &&\n+\tif (branch && has_prefix(k, \"branch.\") &&\n+\t\thas_prefix(k + 7, branch) &&\n \t\t!strcmp(k + 7 + strlen(branch), \".mergeoptions\")) {\n \t\tfree(branch_mergeoptions);\n \t\tbranch_mergeoptions = xstrdup(v);\n@@ -1113,7 +1113,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t * current branch.\n \t */\n \tbranch = branch_to_free = resolve_refdup(\"HEAD\", head_sha1, 0, &flag);\n-\tif (branch && !prefixcmp(branch, \"refs/heads/\"))\n+\tif (branch && has_prefix(branch, \"refs/heads/\"))\n \t\tbranch += 11;\n \tif (!branch || is_null_sha1(head_sha1))\n \t\thead_commit = NULL;\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230345","messageId":"20131109070720.18178.68234.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 68/86] builtin/name-rev: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:01Z","receivedAt":"2013-11-09T07:07:01Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/name-rev.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 20fcf8c..2b74220 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -101,9 +101,9 @@ static const char *name_ref_abbrev(const char *refname, int shorten_unambiguous)\n {\n \tif (shorten_unambiguous)\n \t\trefname = shorten_unambiguous_ref(refname, 0);\n-\telse if (!prefixcmp(refname, \"refs/heads/\"))\n+\telse if (has_prefix(refname, \"refs/heads/\"))\n \t\trefname = refname + 11;\n-\telse if (!prefixcmp(refname, \"refs/\"))\n+\telse if (has_prefix(refname, \"refs/\"))\n \t\trefname = refname + 5;\n \treturn refname;\n }\n@@ -149,7 +149,7 @@ static int name_ref(const char *path, const unsigned char *sha1, int flags, void\n \tint can_abbreviate_output = data->tags_only && data->name_only;\n \tint deref = 0;\n \n-\tif (data->tags_only && prefixcmp(path, \"refs/tags/\"))\n+\tif (data->tags_only && !has_prefix(path, \"refs/tags/\"))\n \t\treturn 0;\n \n \tif (data->ref_filter) {\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230344","messageId":"20131109070720.18178.62710.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 69/86] builtin/notes: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:02Z","receivedAt":"2013-11-09T07:07:02Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/notes.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex d459e23..4bc7385 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -347,7 +347,7 @@ static struct notes_tree *init_notes_check(const char *subcommand)\n \tinit_notes(NULL, NULL, NULL, 0);\n \tt = &default_notes_tree;\n \n-\tif (prefixcmp(t->ref, \"refs/notes/\"))\n+\tif (!has_prefix(t->ref, \"refs/notes/\"))\n \t\tdie(\"Refusing to %s notes in %s (outside of refs/notes/)\",\n \t\t    subcommand, t->ref);\n \treturn t;\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230342","messageId":"20131109070720.18178.14075.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 70/86] builtin/pack-objects: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:03Z","receivedAt":"2013-11-09T07:07:03Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/pack-objects.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex e86cd57..45ee54a 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2031,7 +2031,7 @@ static int add_ref_tag(const char *path, const unsigned char *sha1, int flag, vo\n {\n \tunsigned char peeled[20];\n \n-\tif (!prefixcmp(path, \"refs/tags/\") && /* is a tag? */\n+\tif (has_prefix(path, \"refs/tags/\") && /* is a tag? */\n \t    !peel_ref(path, peeled)        && /* peelable? */\n \t    locate_object_entry(peeled))      /* object packed? */\n \t\tadd_object_entry(sha1, OBJ_TAG, NULL, 0);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230343","messageId":"20131109070720.18178.82667.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 71/86] builtin/prune: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:04Z","receivedAt":"2013-11-09T07:07:04Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/prune.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex 6366917..59682ff 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -80,7 +80,7 @@ static int prune_dir(int i, char *path)\n \t\t\tprune_object(path, de->d_name, sha1);\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(de->d_name, \"tmp_obj_\")) {\n+\t\tif (has_prefix(de->d_name, \"tmp_obj_\")) {\n \t\t\tprune_tmp_object(path, de->d_name);\n \t\t\tcontinue;\n \t\t}\n@@ -119,7 +119,7 @@ static void remove_temporary_files(const char *path)\n \t\treturn;\n \t}\n \twhile ((de = readdir(dir)) != NULL)\n-\t\tif (!prefixcmp(de->d_name, \"tmp_\"))\n+\t\tif (has_prefix(de->d_name, \"tmp_\"))\n \t\t\tprune_tmp_object(path, de->d_name);\n \tclosedir(dir);\n }\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230340","messageId":"20131109070720.18178.25145.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 72/86] builtin/receive-pack: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:05Z","receivedAt":"2013-11-09T07:07:05Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/receive-pack.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 67ce1ef..a4de530 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -428,7 +428,7 @@ static const char *update(struct command *cmd)\n \tstruct ref_lock *lock;\n \n \t/* only refs/... are allowed */\n-\tif (prefixcmp(name, \"refs/\") || check_refname_format(name + 5, 0)) {\n+\tif (!has_prefix(name, \"refs/\") || check_refname_format(name + 5, 0)) {\n \t\trp_error(\"refusing to create funny ref '%s' remotely\", name);\n \t\treturn \"funny refname\";\n \t}\n@@ -459,7 +459,7 @@ static const char *update(struct command *cmd)\n \t}\n \n \tif (!is_null_sha1(old_sha1) && is_null_sha1(new_sha1)) {\n-\t\tif (deny_deletes && !prefixcmp(name, \"refs/heads/\")) {\n+\t\tif (deny_deletes && has_prefix(name, \"refs/heads/\")) {\n \t\t\trp_error(\"denying ref deletion for %s\", name);\n \t\t\treturn \"deletion prohibited\";\n \t\t}\n@@ -483,7 +483,7 @@ static const char *update(struct command *cmd)\n \n \tif (deny_non_fast_forwards && !is_null_sha1(new_sha1) &&\n \t    !is_null_sha1(old_sha1) &&\n-\t    !prefixcmp(name, \"refs/heads/\")) {\n+\t    has_prefix(name, \"refs/heads/\")) {\n \t\tstruct object *old_object, *new_object;\n \t\tstruct commit *old_commit, *new_commit;\n \n-- \n1.8.4.1.566.geca833c\n"},{"id":"230337","messageId":"20131109070720.18178.65381.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 73/86] builtin/reflog: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:06Z","receivedAt":"2013-11-09T07:07:06Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/reflog.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 6eb24c8..f1a2578 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -610,12 +610,12 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)\n \t\tconst char *arg = argv[i];\n \t\tif (!strcmp(arg, \"--dry-run\") || !strcmp(arg, \"-n\"))\n \t\t\tcb.dry_run = 1;\n-\t\telse if (!prefixcmp(arg, \"--expire=\")) {\n+\t\telse if (has_prefix(arg, \"--expire=\")) {\n \t\t\tif (parse_expiry_date(arg + 9, &cb.expire_total))\n \t\t\t\tdie(_(\"'%s' is not a valid timestamp\"), arg);\n \t\t\texplicit_expiry |= EXPIRE_TOTAL;\n \t\t}\n-\t\telse if (!prefixcmp(arg, \"--expire-unreachable=\")) {\n+\t\telse if (has_prefix(arg, \"--expire-unreachable=\")) {\n \t\t\tif (parse_expiry_date(arg + 21, &cb.expire_unreachable))\n \t\t\t\tdie(_(\"'%s' is not a valid timestamp\"), arg);\n \t\t\texplicit_expiry |= EXPIRE_UNREACH;\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230336","messageId":"20131109070720.18178.25613.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 74/86] builtin/remote: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:07Z","receivedAt":"2013-11-09T07:07:07Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/remote.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex b9a1024..e45358c 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -261,7 +261,7 @@ static const char *abbrev_ref(const char *name, const char *prefix)\n \n static int config_read_branches(const char *key, const char *value, void *cb)\n {\n-\tif (!prefixcmp(key, \"branch.\")) {\n+\tif (has_prefix(key, \"branch.\")) {\n \t\tconst char *orig_key = key;\n \t\tchar *name;\n \t\tstruct string_list_item *item;\n@@ -526,9 +526,9 @@ static int add_branch_for_removal(const char *refname,\n \t}\n \n \t/* don't delete non-remote-tracking refs */\n-\tif (prefixcmp(refname, \"refs/remotes/\")) {\n+\tif (!has_prefix(refname, \"refs/remotes/\")) {\n \t\t/* advise user how to delete local branches */\n-\t\tif (!prefixcmp(refname, \"refs/heads/\"))\n+\t\tif (has_prefix(refname, \"refs/heads/\"))\n \t\t\tstring_list_append(branches->skipped,\n \t\t\t\t\t   abbrev_branch(refname));\n \t\t/* silently skip over other non-remote refs */\n@@ -563,7 +563,7 @@ static int read_remote_branches(const char *refname,\n \tconst char *symref;\n \n \tstrbuf_addf(&buf, \"refs/remotes/%s/\", rename->old);\n-\tif (!prefixcmp(refname, buf.buf)) {\n+\tif (has_prefix(refname, buf.buf)) {\n \t\titem = string_list_append(rename->remote_branches, xstrdup(refname));\n \t\tsymref = resolve_ref_unsafe(refname, orig_sha1, 1, &flag);\n \t\tif (flag & REF_ISSYMREF)\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230335","messageId":"20131109070720.18178.4544.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 75/86] builtin/rev-parse: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:08Z","receivedAt":"2013-11-09T07:07:08Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/rev-parse.c | 24 ++++++++++++------------\n 1 file changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex c76b89d..b6c92e0 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -508,7 +508,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\t}\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"-n\")) {\n+\t\tif (has_prefix(arg, \"-n\")) {\n \t\t\tif ((filter & DO_FLAGS) && (filter & DO_REVS))\n \t\t\t\tshow(arg);\n \t\t\tcontinue;\n@@ -560,7 +560,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"--short\") ||\n-\t\t\t    !prefixcmp(arg, \"--short=\")) {\n+\t\t\t    has_prefix(arg, \"--short=\")) {\n \t\t\t\tfilter &= ~(DO_FLAGS|DO_NOREV);\n \t\t\t\tverify = 1;\n \t\t\t\tabbrev = DEFAULT_ABBREV;\n@@ -588,7 +588,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\t\tsymbolic = SHOW_SYMBOLIC_FULL;\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tif (!prefixcmp(arg, \"--abbrev-ref\") &&\n+\t\t\tif (has_prefix(arg, \"--abbrev-ref\") &&\n \t\t\t    (!arg[12] || arg[12] == '=')) {\n \t\t\t\tabbrev_ref = 1;\n \t\t\t\tabbrev_ref_strict = warn_ambiguous_refs;\n@@ -606,7 +606,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\t\tfor_each_ref(show_reference, NULL);\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tif (!prefixcmp(arg, \"--disambiguate=\")) {\n+\t\t\tif (has_prefix(arg, \"--disambiguate=\")) {\n \t\t\t\tfor_each_abbrev(arg + 15, show_abbrev, NULL);\n \t\t\t\tcontinue;\n \t\t\t}\n@@ -615,7 +615,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\t\tfor_each_ref_in(\"refs/bisect/good\", anti_reference, NULL);\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tif (!prefixcmp(arg, \"--branches=\")) {\n+\t\t\tif (has_prefix(arg, \"--branches=\")) {\n \t\t\t\tfor_each_glob_ref_in(show_reference, arg + 11,\n \t\t\t\t\t\"refs/heads/\", NULL);\n \t\t\t\tcontinue;\n@@ -624,7 +624,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\t\tfor_each_branch_ref(show_reference, NULL);\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tif (!prefixcmp(arg, \"--tags=\")) {\n+\t\t\tif (has_prefix(arg, \"--tags=\")) {\n \t\t\t\tfor_each_glob_ref_in(show_reference, arg + 7,\n \t\t\t\t\t\"refs/tags/\", NULL);\n \t\t\t\tcontinue;\n@@ -633,11 +633,11 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\t\tfor_each_tag_ref(show_reference, NULL);\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tif (!prefixcmp(arg, \"--glob=\")) {\n+\t\t\tif (has_prefix(arg, \"--glob=\")) {\n \t\t\t\tfor_each_glob_ref(show_reference, arg + 7, NULL);\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tif (!prefixcmp(arg, \"--remotes=\")) {\n+\t\t\tif (has_prefix(arg, \"--remotes=\")) {\n \t\t\t\tfor_each_glob_ref_in(show_reference, arg + 10,\n \t\t\t\t\t\"refs/remotes/\", NULL);\n \t\t\t\tcontinue;\n@@ -724,19 +724,19 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\t\t\t\t: \"false\");\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tif (!prefixcmp(arg, \"--since=\")) {\n+\t\t\tif (has_prefix(arg, \"--since=\")) {\n \t\t\t\tshow_datestring(\"--max-age=\", arg+8);\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tif (!prefixcmp(arg, \"--after=\")) {\n+\t\t\tif (has_prefix(arg, \"--after=\")) {\n \t\t\t\tshow_datestring(\"--max-age=\", arg+8);\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tif (!prefixcmp(arg, \"--before=\")) {\n+\t\t\tif (has_prefix(arg, \"--before=\")) {\n \t\t\t\tshow_datestring(\"--min-age=\", arg+9);\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tif (!prefixcmp(arg, \"--until=\")) {\n+\t\t\tif (has_prefix(arg, \"--until=\")) {\n \t\t\t\tshow_datestring(\"--min-age=\", arg+8);\n \t\t\t\tcontinue;\n \t\t\t}\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230326","messageId":"20131109070720.18178.21433.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 76/86] builtin/send-pack: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:09Z","receivedAt":"2013-11-09T07:07:09Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/send-pack.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/send-pack.c b/builtin/send-pack.c\nindex 4482f16..0c29e69 100644\n--- a/builtin/send-pack.c\n+++ b/builtin/send-pack.c\n@@ -115,15 +115,15 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)\n \t\tconst char *arg = *argv;\n \n \t\tif (*arg == '-') {\n-\t\t\tif (!prefixcmp(arg, \"--receive-pack=\")) {\n+\t\t\tif (has_prefix(arg, \"--receive-pack=\")) {\n \t\t\t\treceivepack = arg + 15;\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tif (!prefixcmp(arg, \"--exec=\")) {\n+\t\t\tif (has_prefix(arg, \"--exec=\")) {\n \t\t\t\treceivepack = arg + 7;\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tif (!prefixcmp(arg, \"--remote=\")) {\n+\t\t\tif (has_prefix(arg, \"--remote=\")) {\n \t\t\t\tremote_name = arg + 9;\n \t\t\t\tcontinue;\n \t\t\t}\n@@ -181,7 +181,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)\n \t\t\t\t\texit(1);\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tif (!prefixcmp(arg, \"--\" CAS_OPT_NAME \"=\")) {\n+\t\t\tif (has_prefix(arg, \"--\" CAS_OPT_NAME \"=\")) {\n \t\t\t\tif (parse_push_cas_option(&cas,\n \t\t\t\t\t\t\t  strchr(arg, '=') + 1, 0) < 0)\n \t\t\t\t\texit(1);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230334","messageId":"20131109070720.18178.54365.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 77/86] builtin/shortlog: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:10Z","receivedAt":"2013-11-09T07:07:10Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/shortlog.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/shortlog.c b/builtin/shortlog.c\nindex c226f76..3f35682 100644\n--- a/builtin/shortlog.c\n+++ b/builtin/shortlog.c\n@@ -65,7 +65,7 @@ static void insert_one_record(struct shortlog *log,\n \teol = strchr(oneline, '\\n');\n \tif (!eol)\n \t\teol = oneline + strlen(oneline);\n-\tif (!prefixcmp(oneline, \"[PATCH\")) {\n+\tif (has_prefix(oneline, \"[PATCH\")) {\n \t\tchar *eob = strchr(oneline, ']');\n \t\tif (eob && (!eol || eob < eol))\n \t\t\toneline = eob + 1;\n@@ -95,7 +95,7 @@ static void read_from_stdin(struct shortlog *log)\n \n \twhile (fgets(author, sizeof(author), stdin) != NULL) {\n \t\tif (!(author[0] == 'A' || author[0] == 'a') ||\n-\t\t    prefixcmp(author + 1, \"uthor: \"))\n+\t\t    !has_prefix(author + 1, \"uthor: \"))\n \t\t\tcontinue;\n \t\twhile (fgets(oneline, sizeof(oneline), stdin) &&\n \t\t       oneline[0] != '\\n')\n@@ -123,7 +123,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)\n \t\telse\n \t\t\teol++;\n \n-\t\tif (!prefixcmp(buffer, \"author \"))\n+\t\tif (has_prefix(buffer, \"author \"))\n \t\t\tauthor = buffer + 7;\n \t\tbuffer = eol;\n \t}\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230339","messageId":"20131109070720.18178.42384.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 78/86] builtin/show-branch: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:11Z","receivedAt":"2013-11-09T07:07:11Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/show-branch.c | 20 ++++++++++----------\n 1 file changed, 10 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex 001f29c..dc0b406 100644\n--- a/builtin/show-branch.c\n+++ b/builtin/show-branch.c\n@@ -285,7 +285,7 @@ static void show_one_commit(struct commit *commit, int no_name)\n \t\tpp_commit_easy(CMIT_FMT_ONELINE, commit, &pretty);\n \t\tpretty_str = pretty.buf;\n \t}\n-\tif (!prefixcmp(pretty_str, \"[PATCH] \"))\n+\tif (has_prefix(pretty_str, \"[PATCH] \"))\n \t\tpretty_str += 8;\n \n \tif (!no_name) {\n@@ -396,7 +396,7 @@ static int append_head_ref(const char *refname, const unsigned char *sha1, int f\n {\n \tunsigned char tmp[20];\n \tint ofs = 11;\n-\tif (prefixcmp(refname, \"refs/heads/\"))\n+\tif (!has_prefix(refname, \"refs/heads/\"))\n \t\treturn 0;\n \t/* If both heads/foo and tags/foo exists, get_sha1 would\n \t * get confused.\n@@ -410,7 +410,7 @@ static int append_remote_ref(const char *refname, const unsigned char *sha1, int\n {\n \tunsigned char tmp[20];\n \tint ofs = 13;\n-\tif (prefixcmp(refname, \"refs/remotes/\"))\n+\tif (!has_prefix(refname, \"refs/remotes/\"))\n \t\treturn 0;\n \t/* If both heads/foo and tags/foo exists, get_sha1 would\n \t * get confused.\n@@ -422,7 +422,7 @@ static int append_remote_ref(const char *refname, const unsigned char *sha1, int\n \n static int append_tag_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)\n {\n-\tif (prefixcmp(refname, \"refs/tags/\"))\n+\tif (!has_prefix(refname, \"refs/tags/\"))\n \t\treturn 0;\n \treturn append_ref(refname + 5, sha1, 0);\n }\n@@ -453,9 +453,9 @@ static int append_matching_ref(const char *refname, const unsigned char *sha1, i\n \t\treturn 0;\n \tif (fnmatch(match_ref_pattern, tail, 0))\n \t\treturn 0;\n-\tif (!prefixcmp(refname, \"refs/heads/\"))\n+\tif (has_prefix(refname, \"refs/heads/\"))\n \t\treturn append_head_ref(refname, sha1, flag, cb_data);\n-\tif (!prefixcmp(refname, \"refs/tags/\"))\n+\tif (has_prefix(refname, \"refs/tags/\"))\n \t\treturn append_tag_ref(refname, sha1, flag, cb_data);\n \treturn append_ref(refname, sha1, 0);\n }\n@@ -480,11 +480,11 @@ static int rev_is_head(char *head, int headlen, char *name,\n \tif ((!head[0]) ||\n \t    (head_sha1 && sha1 && hashcmp(head_sha1, sha1)))\n \t\treturn 0;\n-\tif (!prefixcmp(head, \"refs/heads/\"))\n+\tif (has_prefix(head, \"refs/heads/\"))\n \t\thead += 11;\n-\tif (!prefixcmp(name, \"refs/heads/\"))\n+\tif (has_prefix(name, \"refs/heads/\"))\n \t\tname += 11;\n-\telse if (!prefixcmp(name, \"heads/\"))\n+\telse if (has_prefix(name, \"heads/\"))\n \t\tname += 6;\n \treturn !strcmp(head, name);\n }\n@@ -813,7 +813,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \t\t\t\thas_head++;\n \t\t}\n \t\tif (!has_head) {\n-\t\t\tint offset = !prefixcmp(head, \"refs/heads/\") ? 11 : 0;\n+\t\t\tint offset = has_prefix(head, \"refs/heads/\") ? 11 : 0;\n \t\t\tappend_one_rev(head + offset);\n \t\t}\n \t}\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230328","messageId":"20131109070720.18178.83028.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 79/86] builtin/show-ref: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:12Z","receivedAt":"2013-11-09T07:07:12Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/show-ref.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex 9f3f5e3..5e978aa 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -37,8 +37,8 @@ static int show_ref(const char *refname, const unsigned char *sha1, int flag, vo\n \tif (tags_only || heads_only) {\n \t\tint match;\n \n-\t\tmatch = heads_only && !prefixcmp(refname, \"refs/heads/\");\n-\t\tmatch |= tags_only && !prefixcmp(refname, \"refs/tags/\");\n+\t\tmatch = heads_only && has_prefix(refname, \"refs/heads/\");\n+\t\tmatch |= tags_only && has_prefix(refname, \"refs/tags/\");\n \t\tif (!match)\n \t\t\treturn 0;\n \t}\n@@ -210,7 +210,7 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)\n \t\twhile (*pattern) {\n \t\t\tunsigned char sha1[20];\n \n-\t\t\tif (!prefixcmp(*pattern, \"refs/\") &&\n+\t\t\tif (has_prefix(*pattern, \"refs/\") &&\n \t\t\t    !read_ref(*pattern, sha1)) {\n \t\t\t\tif (!quiet)\n \t\t\t\t\tshow_one(*pattern, sha1);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230329","messageId":"20131109070720.18178.41674.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 80/86] builtin/symbolic-ref: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:13Z","receivedAt":"2013-11-09T07:07:13Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/symbolic-ref.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/symbolic-ref.c b/builtin/symbolic-ref.c\nindex f481959..868fab4 100644\n--- a/builtin/symbolic-ref.c\n+++ b/builtin/symbolic-ref.c\n@@ -65,7 +65,7 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)\n \t\tbreak;\n \tcase 2:\n \t\tif (!strcmp(argv[0], \"HEAD\") &&\n-\t\t    prefixcmp(argv[1], \"refs/\"))\n+\t\t    !has_prefix(argv[1], \"refs/\"))\n \t\t\tdie(\"Refusing to point HEAD outside of refs/\");\n \t\tcreate_symref(argv[0], argv[1], msg);\n \t\tbreak;\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230330","messageId":"20131109070720.18178.89055.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 81/86] builtin/tag: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:14Z","receivedAt":"2013-11-09T07:07:14Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/tag.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex ea55f1d..e7aaaa2 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -259,7 +259,7 @@ static int git_tag_config(const char *var, const char *value, void *cb)\n \tint status = git_gpg_config(var, value, cb);\n \tif (status)\n \t\treturn status;\n-\tif (!prefixcmp(var, \"column.\"))\n+\tif (has_prefix(var, \"column.\"))\n \t\treturn git_column_config(var, value, \"tag\", &colopts);\n \treturn git_default_config(var, value, cb);\n }\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230332","messageId":"20131109070720.18178.93247.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 82/86] builtin/tar-tree: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:15Z","receivedAt":"2013-11-09T07:07:15Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/tar-tree.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/tar-tree.c b/builtin/tar-tree.c\nindex ba3ffe6..7f225cc 100644\n--- a/builtin/tar-tree.c\n+++ b/builtin/tar-tree.c\n@@ -34,7 +34,7 @@ int cmd_tar_tree(int argc, const char **argv, const char *prefix)\n \tnargv[nargc++] = \"archive\";\n \tnargv[nargc++] = \"--format=tar\";\n \n-\tif (2 <= argc && !prefixcmp(argv[1], \"--remote=\")) {\n+\tif (2 <= argc && has_prefix(argv[1], \"--remote=\")) {\n \t\tnargv[nargc++] = argv[1];\n \t\targv++;\n \t\targc--;\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230331","messageId":"20131109070720.18178.51088.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 83/86] builtin/unpack-objects: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:16Z","receivedAt":"2013-11-09T07:07:16Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/unpack-objects.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 2217d7b..dc2dd77 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -523,7 +523,7 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)\n \t\t\t\tstrict = 1;\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tif (!prefixcmp(arg, \"--pack_header=\")) {\n+\t\t\tif (has_prefix(arg, \"--pack_header=\")) {\n \t\t\t\tstruct pack_header *hdr;\n \t\t\t\tchar *c;\n \n-- \n1.8.4.1.566.geca833c\n"},{"id":"230327","messageId":"20131109070720.18178.40463.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 84/86] builtin/update-ref: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:17Z","receivedAt":"2013-11-09T07:07:17Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/update-ref.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/update-ref.c b/builtin/update-ref.c\nindex 702e90d..d81d959 100644\n--- a/builtin/update-ref.c\n+++ b/builtin/update-ref.c\n@@ -229,15 +229,15 @@ static void update_refs_stdin(void)\n \t\t\tdie(\"empty command in input\");\n \t\telse if (isspace(*cmd.buf))\n \t\t\tdie(\"whitespace before command: %s\", cmd.buf);\n-\t\telse if (!prefixcmp(cmd.buf, \"update \"))\n+\t\telse if (has_prefix(cmd.buf, \"update \"))\n \t\t\tparse_cmd_update(cmd.buf + 7);\n-\t\telse if (!prefixcmp(cmd.buf, \"create \"))\n+\t\telse if (has_prefix(cmd.buf, \"create \"))\n \t\t\tparse_cmd_create(cmd.buf + 7);\n-\t\telse if (!prefixcmp(cmd.buf, \"delete \"))\n+\t\telse if (has_prefix(cmd.buf, \"delete \"))\n \t\t\tparse_cmd_delete(cmd.buf + 7);\n-\t\telse if (!prefixcmp(cmd.buf, \"verify \"))\n+\t\telse if (has_prefix(cmd.buf, \"verify \"))\n \t\t\tparse_cmd_verify(cmd.buf + 7);\n-\t\telse if (!prefixcmp(cmd.buf, \"option \"))\n+\t\telse if (has_prefix(cmd.buf, \"option \"))\n \t\t\tparse_cmd_option(cmd.buf + 7);\n \t\telse\n \t\t\tdie(\"unknown command: %s\", cmd.buf);\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230338","messageId":"20131109070720.18178.40165.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 85/86] builtin/upload-archive: replace prefixcmd() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:18Z","receivedAt":"2013-11-09T07:07:18Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/upload-archive.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/upload-archive.c b/builtin/upload-archive.c\nindex af2da35..298bc76 100644\n--- a/builtin/upload-archive.c\n+++ b/builtin/upload-archive.c\n@@ -37,7 +37,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)\n \t\tif (sent_argv.argc > MAX_ARGS)\n \t\t\tdie(\"Too many options (>%d)\", MAX_ARGS - 1);\n \n-\t\tif (prefixcmp(buf, arg_cmd))\n+\t\tif (!has_prefix(buf, arg_cmd))\n \t\t\tdie(\"'argument' token or flush expected\");\n \t\targv_array_push(&sent_argv, buf + strlen(arg_cmd));\n \t}\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230333","messageId":"20131109070720.18178.24378.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"[PATCH 86/86] strbuf: remove prefixcmp() as it has been replaced with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-09T07:07:19Z","receivedAt":"2013-11-09T07:07:19Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"prefixcmp() is now useless as the previous commit replaced it\neverywhere with has_prefix(). So let's now remove it.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n git-compat-util.h | 1 -\n strbuf.c          | 9 ---------\n 2 files changed, 10 deletions(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 7930f49..c5505e6 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -350,7 +350,6 @@ extern void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_lis\n extern void set_error_routine(void (*routine)(const char *err, va_list params));\n extern void set_die_is_recursing_routine(int (*routine)(void));\n \n-extern int prefixcmp(const char *str, const char *prefix);\n extern int has_prefix(const char *str, const char *prefix);\n extern int has_suffix(const char *str, const char *suffix);\n \ndiff --git a/strbuf.c b/strbuf.c\nindex 748be6d..199533c 100644\n--- a/strbuf.c\n+++ b/strbuf.c\n@@ -1,15 +1,6 @@\n #include \"cache.h\"\n #include \"refs.h\"\n \n-int prefixcmp(const char *str, const char *prefix)\n-{\n-\tfor (; ; str++, prefix++)\n-\t\tif (!*prefix)\n-\t\t\treturn 0;\n-\t\telse if (*str != *prefix)\n-\t\t\treturn (unsigned char)*prefix - (unsigned char)*str;\n-}\n-\n int has_prefix(const char *str, const char *prefix)\n {\n \tfor (; ; str++, prefix++)\n-- \n1.8.4.1.566.geca833c\n"},{"id":"230359","messageId":"87fvr5ps9m.fsf@linux-k42r.v.cablecom.net","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"Re: [PATCH 00/86] replace prefixcmp() with has_prefix()","fromName":"Thomas Rast","fromEmail":"tr@thomasrast.ch","sentAt":"2013-11-09T14:24:37Z","receivedAt":"2013-11-09T14:24:37Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Christian Couder <chriscool@tuxfamily.org> writes:\n\n> Christian Couder (86):\n>   strbuf: add has_prefix() to be used instead of prefixcmp()\n>   diff: replace prefixcmd() with has_prefix()\n>   fast-import: replace prefixcmd() with has_prefix()\n[...]\n>   builtin/update-ref: replace prefixcmd() with has_prefix()\n>   builtin/upload-archive: replace prefixcmd() with has_prefix()\n>   strbuf: remove prefixcmp() as it has been replaced with has_prefix()\n\nAll of your subjects except for the first and last say \"prefixcm*d*\". :-)\n\n-- \nThomas Rast\ntr@thomasrast.ch\n"},{"id":"230397","messageId":"5281012D.4060708@op5.se","threadId":"35313","inReplyTo":"20131109070358.18178.40248.chriscool@tuxfamily.org","subject":"Re: [PATCH 00/86] replace prefixcmp() with has_prefix()","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2013-11-11T16:09:17Z","receivedAt":"2013-11-11T16:09:17Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"On 2013-11-09 08:05, Christian Couder wrote:\n> Here is a big patch series to replace prefixcmp() with a new\n> has_prefix() function.\n>\n\nSeems like totally useless codechurn to me. Besides, prefixcmp()\nties in nicely with strcmp() and memcmp() (and returns 0 on a\nmatch just like its namesakes), whereas your function must return\nnon-zero on match and thus can't be used as a qsort() callback.\nGranted, prefixcmp() lends itself poorly to that as well, but at\nleast it's consistent with the other *cmp() functions.\n\nSo -1 on this whole series.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n\nConsidering the successes of the wars on alcohol, poverty, drugs and\nterror, I think we should give some serious thought to declaring war\non peace.\n"},{"id":"230477","messageId":"CAP8UFD3sGqYsk_0b5F3d6TE-ZvcSg46fqDRT62ubX8NSDPxUxw@mail.gmail.com","threadId":"35313","inReplyTo":"87fvr5ps9m.fsf@linux-k42r.v.cablecom.net","subject":"Re: [PATCH 00/86] replace prefixcmp() with has_prefix()","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2013-11-12T06:16:21Z","receivedAt":"2013-11-12T06:16:21Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Sat, Nov 9, 2013 at 3:24 PM, Thomas Rast <tr@thomasrast.ch> wrote:\n> Christian Couder <chriscool@tuxfamily.org> writes:\n>\n>> Christian Couder (86):\n>>   strbuf: add has_prefix() to be used instead of prefixcmp()\n>>   diff: replace prefixcmd() with has_prefix()\n>>   fast-import: replace prefixcmd() with has_prefix()\n> [...]\n>>   builtin/update-ref: replace prefixcmd() with has_prefix()\n>>   builtin/upload-archive: replace prefixcmd() with has_prefix()\n>>   strbuf: remove prefixcmp() as it has been replaced with has_prefix()\n>\n> All of your subjects except for the first and last say \"prefixcm*d*\". :-)\n\nYeah, sorry about that.\n\nJunio already sent me, with some others in cc, an email about this and\nI replied to all asking Junio if he wants me to resend with a fixed\nsubject, but unfortunately the mailing list was not among the\nrecipient of his email and my reply.\n\nThanks and sorry again,\nChristian.\n"},{"id":"230484","messageId":"20131112083240.GA1684@sigill.intra.peff.net","threadId":"35313","inReplyTo":"5281012D.4060708@op5.se","subject":"Re: [PATCH 00/86] replace prefixcmp() with has_prefix()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-11-12T08:32:40Z","receivedAt":"2013-11-12T08:32:40Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Nov 11, 2013 at 05:09:17PM +0100, Andreas Ericsson wrote:\n\n> On 2013-11-09 08:05, Christian Couder wrote:\n> >Here is a big patch series to replace prefixcmp() with a new\n> >has_prefix() function.\n> >\n> \n> Seems like totally useless codechurn to me. Besides, prefixcmp()\n> ties in nicely with strcmp() and memcmp() (and returns 0 on a\n> match just like its namesakes), whereas your function must return\n> non-zero on match and thus can't be used as a qsort() callback.\n> Granted, prefixcmp() lends itself poorly to that as well, but at\n> least it's consistent with the other *cmp() functions.\n\nI think you missed the earlier threads that let up to this, but the\nsummary is that prefixcmp does not really make any sense as a qsort\ncallback. Consider that comparing \"foobar\" and \"foo\" would yield 0, but\n\"foo\" and \"foobar\" would be positive.\n\nI am ambivalent on the code churn, but if we do apply it, we should\nprobably leave off the final patch (dropping prefixcmp) for a cycle to\nlet topics in flight catch up to the change. Just diffing \"master\" and\n\"next\", I see some new uses of prefixcmp which will need adjusted, along\nwith spots where the patches themselves will cause textual conflicts.\n\n-Peff\n"},{"id":"230496","messageId":"xmqqy54timsm.fsf@gitster.dls.corp.google.com","threadId":"35313","inReplyTo":"20131112083240.GA1684@sigill.intra.peff.net","subject":"Re: [PATCH 00/86] replace prefixcmp() with has_prefix()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-11-12T16:53:45Z","receivedAt":"2013-11-12T16:53:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> I am ambivalent on the code churn, but if we do apply it, we should\n> probably leave off the final patch (dropping prefixcmp) for a cycle to\n> let topics in flight catch up to the change. Just diffing \"master\" and\n> \"next\", I see some new uses of prefixcmp which will need adjusted, along\n> with spots where the patches themselves will cause textual conflicts.\n\nYes, I did that check too (but between 'maint' and 'pu'). I think it\nis a good idea to stop using whatever_cmp() name for things that are\nnot *cmp() functions in the longer term, but smooth migration is a\nbit tricky (but not as tricky as end-user visible transitions).\n\nEven though we already added has_suffix() for tail matches, it is\nnot too late to rethink, as it is not in 'master' yet.\n\nOne thing I noticed is that it is probably misnamed, or at least in\na way that invites confusion.  Can people tell which one of these is\ncorrect without looking at existing callsites?\n\n\thas_suffix(filename, \"txt\");\n        has_suffix(filename, \".txt\");\n\nThe semantics of the function we have is the latter and is better\ncalled endswith(), I suspect.  And the corresponding function to\ncheck for head matches should probably be called beginswith().\n"},{"id":"230509","messageId":"20131112201405.GA23418@sigill.intra.peff.net","threadId":"35313","inReplyTo":"xmqqy54timsm.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH 00/86] replace prefixcmp() with has_prefix()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-11-12T20:14:05Z","receivedAt":"2013-11-12T20:14:05Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Nov 12, 2013 at 08:53:45AM -0800, Junio C Hamano wrote:\n\n> Even though we already added has_suffix() for tail matches, it is\n> not too late to rethink, as it is not in 'master' yet.\n> \n> One thing I noticed is that it is probably misnamed, or at least in\n> a way that invites confusion.  Can people tell which one of these is\n> correct without looking at existing callsites?\n> \n> \thas_suffix(filename, \"txt\");\n> \thas_suffix(filename, \".txt\");\n\nTo me, it is obviously the latter. My name for \"thing at the end of a\nfile after the dot\" is \"extension\", not \"suffix\".\n\nI thought that was universal, but if there are people who find it\nconfusing, it is worth changing. After all, the point is to make the\ncode more readable.\n\n> The semantics of the function we have is the latter and is better\n> called endswith(), I suspect.  And the corresponding function to\n> check for head matches should probably be called beginswith().\n\nThose are OK to me. \"has_suffix\" would be my first choice, but if it is\nconfusing to others, your suggestions are fine.\n\n-Peff\n"},{"id":"230514","messageId":"20131112.214357.1022923291448967795.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"xmqqy54timsm.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH 00/86] replace prefixcmp() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-12T20:43:57Z","receivedAt":"2013-11-12T20:43:57Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"From: Junio C Hamano <gitster@pobox.com>\n> \n> Even though we already added has_suffix() for tail matches, it is\n> not too late to rethink, as it is not in 'master' yet.\n> \n> One thing I noticed is that it is probably misnamed, or at least in\n> a way that invites confusion.  Can people tell which one of these is\n> correct without looking at existing callsites?\n> \n>         has_suffix(filename, \"txt\");\n>         has_suffix(filename, \".txt\");\n> \n> The semantics of the function we have is the latter and is better\n> called endswith(), I suspect.  And the corresponding function to\n> check for head matches should probably be called beginswith().\n\nI don't know if has_suffix() is confusing for a native speaker.\n\nAfter a look at some languages, Python has \"startwith()\" and\n\"endswith()\", and Java has \"startWith()\" and \"endsWith()\".\n\nSo I agree that it is a good name. But while we are at it, why not\n\"ends_with()\" and \"begins_with()\"? To me using an underscore seems\nmore consistent with what we are doing in Git.\n\nThanks,\nChristian.\n"},{"id":"230537","messageId":"xmqq7gcdgvmf.fsf@gitster.dls.corp.google.com","threadId":"35313","inReplyTo":"20131112.214357.1022923291448967795.chriscool@tuxfamily.org","subject":"Re: [PATCH 00/86] replace prefixcmp() with has_prefix()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-11-12T21:26:00Z","receivedAt":"2013-11-12T21:26:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Couder <chriscool@tuxfamily.org> writes:\n\n> From: Junio C Hamano <gitster@pobox.com>\n>> \n>> Even though we already added has_suffix() for tail matches, it is\n>> not too late to rethink, as it is not in 'master' yet.\n>> \n>> One thing I noticed is that it is probably misnamed, or at least in\n>> a way that invites confusion.  Can people tell which one of these is\n>> correct without looking at existing callsites?\n>> \n>>         has_suffix(filename, \"txt\");\n>>         has_suffix(filename, \".txt\");\n>> \n>> The semantics of the function we have is the latter and is better\n>> called endswith(), I suspect.  And the corresponding function to\n>> check for head matches should probably be called beginswith().\n>\n> I don't know if has_suffix() is confusing for a native speaker.\n>\n> After a look at some languages, Python has \"startwith()\" and\n> \"endswith()\", and Java has \"startWith()\" and \"endsWith()\".\n>\n> But while we are at it, why not\n> \"ends_with()\" and \"begins_with()\"? To me using an underscore seems\n> more consistent with what we are doing in Git.\n\nSure.\n\nI do not think Peff and I were discussing at that level yet to\ndebate between camelCase and words_with_underscore.  We were mainly\ntalking about what words to be used, which needs to come before the\nfinal appearance.\n"},{"id":"230553","messageId":"20131113.074703.1555957018827670255.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"xmqq7gcdgvmf.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH 00/86] replace prefixcmp() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-13T06:47:03Z","receivedAt":"2013-11-13T06:47:03Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"From: Junio C Hamano <gitster@pobox.com>\n>\n> Christian Couder <chriscool@tuxfamily.org> writes: \n>>\n>> After a look at some languages, Python has \"startwith()\" and\n>> \"endswith()\", and Java has \"startWith()\" and \"endsWith()\".\n>>\n>> But while we are at it, why not\n>> \"ends_with()\" and \"begins_with()\"? To me using an underscore seems\n>> more consistent with what we are doing in Git.\n> \n> Sure.\n> \n> I do not think Peff and I were discussing at that level yet to\n> debate between camelCase and words_with_underscore.  We were mainly\n> talking about what words to be used, which needs to come before the\n> final appearance.\n\nOk.\n\nBy the way Ruby has \"start_with?\" and \"end_with?\". So the thing we can\ndiscuss, if we go this way are:\n\n\t1) with an \"s\" after the verb or not?\n\t2) should we use \"start\" or \"begin\"?\n\t3) with an underscore, nothing or camelCase\n\nMy preference is:\n\n1) with an \"s\"\n2) \"start\"\n3) underscore\n\nso that gives: starts_with() and ends_with()\n\nThanks,\nChristian.\n"},{"id":"230555","messageId":"20131113071747.GA31251@sigill.intra.peff.net","threadId":"35313","inReplyTo":"20131113.074703.1555957018827670255.chriscool@tuxfamily.org","subject":"Re: [PATCH 00/86] replace prefixcmp() with has_prefix()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-11-13T07:17:47Z","receivedAt":"2013-11-13T07:17:47Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Nov 13, 2013 at 07:47:03AM +0100, Christian Couder wrote:\n\n> My preference is:\n> \n> 1) with an \"s\"\n> 2) \"start\"\n> 3) underscore\n> \n> so that gives: starts_with() and ends_with()\n\nFWIW, that looks good to me, too. Whether there is confusion over the\nmeaning of \"suffix\" or not, it makes sense, all other things being\nequal, to use the same terms as other popular languages.\n\nLike you, I prefer \"with an s\", but we are deep in bikeshedding\nterritory now. I can live with anything. :)\n\n-Peff\n"},{"id":"230723","messageId":"20131117.095200.299497690980619465.chriscool@tuxfamily.org","threadId":"35313","inReplyTo":"20131113071747.GA31251@sigill.intra.peff.net","subject":"Re: [PATCH 00/86] replace prefixcmp() with has_prefix()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-11-17T08:52:00Z","receivedAt":"2013-11-17T08:52:00Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"From: Jeff King <peff@peff.net>\n>\n> On Wed, Nov 13, 2013 at 07:47:03AM +0100, Christian Couder wrote:\n> \n>> My preference is:\n>> \n>> 1) with an \"s\"\n>> 2) \"start\"\n>> 3) underscore\n>> \n>> so that gives: starts_with() and ends_with()\n> \n> FWIW, that looks good to me, too. Whether there is confusion over the\n> meaning of \"suffix\" or not, it makes sense, all other things being\n> equal, to use the same terms as other popular languages.\n> \n> Like you, I prefer \"with an s\", but we are deep in bikeshedding\n> territory now. I can live with anything. :)\n\nWhen I prepared a new version of my patch series, this time to rename\nsuffixcmp() to ends_with(), it appeared that we already have a static\nends_with() function in vcs-svn/fast_export.c with another slightly\ndifferent implementation :-)\n\nI will send a new version that will remove this redundant\nimplementation.\n\nCheers,\nChristian.\n"},{"id":"230750","messageId":"CAP8UFD0HjJha7gF7h_S3Hb5ZSqOW0nfHW=G=P6gu0LZaN=hfRQ@mail.gmail.com","threadId":"35313","inReplyTo":"20131117.095200.299497690980619465.chriscool@tuxfamily.org","subject":"Re: [PATCH 00/86] replace prefixcmp() with has_prefix()","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2013-11-18T10:42:04Z","receivedAt":"2013-11-18T10:42:04Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Sun, Nov 17, 2013 at 9:52 AM, Christian Couder\n<chriscool@tuxfamily.org> wrote:\n> From: Jeff King <peff@peff.net>\n>>\n>> On Wed, Nov 13, 2013 at 07:47:03AM +0100, Christian Couder wrote:\n>>\n>>> My preference is:\n>>>\n>>> 1) with an \"s\"\n>>> 2) \"start\"\n>>> 3) underscore\n>>>\n>>> so that gives: starts_with() and ends_with()\n>>\n>> FWIW, that looks good to me, too. Whether there is confusion over the\n>> meaning of \"suffix\" or not, it makes sense, all other things being\n>> equal, to use the same terms as other popular languages.\n>>\n>> Like you, I prefer \"with an s\", but we are deep in bikeshedding\n>> territory now. I can live with anything. :)\n>\n> When I prepared a new version of my patch series, this time to rename\n> suffixcmp() to ends_with(), it appeared that we already have a static\n> ends_with() function in vcs-svn/fast_export.c with another slightly\n> different implementation :-)\n>\n> I will send a new version that will remove this redundant\n> implementation.\n\nThere is also a new version of my 86 patch long series to replace\nprefixcmp() with starts_with() that I am ready to send, but I hesitate\nto spam the whole list :-)\nI can put it somewhere like GitHub where people can see everything and\nperhaps send only a few patches to the list, including the first and\nthe last.\n@Junio, how would you like me to proceed?\n\nThanks,\nChristian.\n"},{"id":"230815","messageId":"xmqq8uwk83wa.fsf@gitster.dls.corp.google.com","threadId":"35313","inReplyTo":"CAP8UFD0HjJha7gF7h_S3Hb5ZSqOW0nfHW=G=P6gu0LZaN=hfRQ@mail.gmail.com","subject":"Re: [PATCH 00/86] replace prefixcmp() with has_prefix()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-11-19T21:42:29Z","receivedAt":"2013-11-19T21:42:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Couder <christian.couder@gmail.com> writes:\n\n> There is also a new version of my 86 patch long series to replace\n> prefixcmp() with starts_with() that I am ready to send, but I hesitate\n> to spam the whole list :-)\n> I can put it somewhere like GitHub where people can see everything and\n> perhaps send only a few patches to the list, including the first and\n> the last.\n> @Junio, how would you like me to proceed?\n\nLet's hold this off for now. The other half of this series is\nalready in 'next' and I do not want to bother with the \"revert,\nrebranch and remerge\" dance this close to the 1.8.5 final.\n"}]}