aboutsummaryrefslogtreecommitdiff
path: root/builtin-name-rev.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-02-20 01:53:29 -0800
committerJunio C Hamano <junkio@cox.net>2007-02-20 22:03:15 -0800
commitcc44c7655fe2dd0cfb46e841156634fe622df397 (patch)
tree6829fa96174f857c90e8baf966a2a8c7b924514a /builtin-name-rev.c
parentcff0302c14522ba7b34265ee39f23e6321a4777d (diff)
downloadgit-cc44c7655fe2dd0cfb46e841156634fe622df397.tar.gz
git-cc44c7655fe2dd0cfb46e841156634fe622df397.tar.xz
Mechanical conversion to use prefixcmp()
This mechanically converts strncmp() to use prefixcmp(), but only when the parameters match specific patterns, so that they can be verified easily. Leftover from this will be fixed in a separate step, including idiotic conversions like if (!strncmp("foo", arg, 3)) => if (!(-prefixcmp(arg, "foo"))) This was done by using this script in px.perl #!/usr/bin/perl -i.bak -p if (/strncmp\(([^,]+), "([^\\"]*)", (\d+)\)/ && (length($2) == $3)) { s|strncmp\(([^,]+), "([^\\"]*)", (\d+)\)|prefixcmp($1, "$2")|; } if (/strncmp\("([^\\"]*)", ([^,]+), (\d+)\)/ && (length($1) == $3)) { s|strncmp\("([^\\"]*)", ([^,]+), (\d+)\)|(-prefixcmp($2, "$1"))|; } and running: $ git grep -l strncmp -- '*.c' | xargs perl px.perl Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-name-rev.c')
-rw-r--r--builtin-name-rev.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/builtin-name-rev.c b/builtin-name-rev.c
index 36f1ba6d3..2c3d14c1b 100644
--- a/builtin-name-rev.c
+++ b/builtin-name-rev.c
@@ -85,7 +85,7 @@ static int name_ref(const char *path, const unsigned char *sha1, int flags, void
struct name_ref_data *data = cb_data;
int deref = 0;
- if (data->tags_only && strncmp(path, "refs/tags/", 10))
+ if (data->tags_only && prefixcmp(path, "refs/tags/"))
return 0;
if (data->ref_filter && fnmatch(data->ref_filter, path, 0))
@@ -101,9 +101,9 @@ static int name_ref(const char *path, const unsigned char *sha1, int flags, void
if (o && o->type == OBJ_COMMIT) {
struct commit *commit = (struct commit *)o;
- if (!strncmp(path, "refs/heads/", 11))
+ if (!prefixcmp(path, "refs/heads/"))
path = path + 11;
- else if (!strncmp(path, "refs/", 5))
+ else if (!prefixcmp(path, "refs/"))
path = path + 5;
name_rev(commit, xstrdup(path), 0, 0, deref);
@@ -156,7 +156,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
} else if (!strcmp(*argv, "--tags")) {
data.tags_only = 1;
continue;
- } else if (!strncmp(*argv, "--refs=", 7)) {
+ } else if (!prefixcmp(*argv, "--refs=")) {
data.ref_filter = *argv + 7;
continue;
} else if (!strcmp(*argv, "--all")) {