summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cc44c76)
raw | patch | inline | side by side (parent: cc44c76)
author | Junio C Hamano <junkio@cox.net> | |
Tue, 20 Feb 2007 09:54:00 +0000 (01:54 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 21 Feb 2007 06:03:15 +0000 (22:03 -0800) |
Previous step converted use of strncmp() with literal string
mechanically even when the result is only used as a boolean:
if (!strncmp("foo", arg, 3)) ==> if (!(-prefixcmp(arg, "foo")))
This step manually cleans them up to read:
if (!prefixcmp(arg, "foo"))
Signed-off-by: Junio C Hamano <junkio@cox.net>
mechanically even when the result is only used as a boolean:
if (!strncmp("foo", arg, 3)) ==> if (!(-prefixcmp(arg, "foo")))
This step manually cleans them up to read:
if (!prefixcmp(arg, "foo"))
Signed-off-by: Junio C Hamano <junkio@cox.net>
13 files changed:
builtin-archive.c | patch | blob | history | |
builtin-blame.c | patch | blob | history | |
builtin-grep.c | patch | blob | history | |
builtin-pack-objects.c | patch | blob | history | |
builtin-push.c | patch | blob | history | |
builtin-rerere.c | patch | blob | history | |
builtin-show-branch.c | patch | blob | history | |
builtin-tar-tree.c | patch | blob | history | |
daemon.c | patch | blob | history | |
fast-import.c | patch | blob | history | |
fetch-pack.c | patch | blob | history | |
peek-remote.c | patch | blob | history | |
upload-pack.c | patch | blob | history |
diff --git a/builtin-archive.c b/builtin-archive.c
index 0c56de069830f1881e952fa620cc10068fa4431a..8ea6cb1efc4f988fb09051852f9e51fc88b5efd7 100644 (file)
--- a/builtin-archive.c
+++ b/builtin-archive.c
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
- if (!(-prefixcmp(arg, "--exec="))) {
+ if (!prefixcmp(arg, "--exec=")) {
if (exec_at)
die("multiple --exec specified");
exec = arg + 7;
diff --git a/builtin-blame.c b/builtin-blame.c
index db311bfba948206fbdc9087ebdf4d6cf585c1522..530b97f97d2661d53a39d2101eeadd86be2e6b00 100644 (file)
--- a/builtin-blame.c
+++ b/builtin-blame.c
output_option |= OUTPUT_LONG_OBJECT_NAME;
else if (!strcmp("-S", arg) && ++i < argc)
revs_file = argv[i];
- else if (!(-prefixcmp(arg, "-M"))) {
+ else if (!prefixcmp(arg, "-M")) {
opt |= PICKAXE_BLAME_MOVE;
blame_move_score = parse_score(arg+2);
}
- else if (!(-prefixcmp(arg, "-C"))) {
+ else if (!prefixcmp(arg, "-C")) {
if (opt & PICKAXE_BLAME_COPY)
opt |= PICKAXE_BLAME_COPY_HARDER;
opt |= PICKAXE_BLAME_COPY | PICKAXE_BLAME_MOVE;
blame_copy_score = parse_score(arg+2);
}
- else if (!(-prefixcmp(arg, "-L"))) {
+ else if (!prefixcmp(arg, "-L")) {
if (!arg[2]) {
if (++i >= argc)
usage(blame_usage);
diff --git a/builtin-grep.c b/builtin-grep.c
index cec22047c97a59dc37eb877073b69de1bec05a6b..f35f2d023cf56cb3c75c817455cfc53a98175f54 100644 (file)
--- a/builtin-grep.c
+++ b/builtin-grep.c
opt.word_regexp = 1;
continue;
}
- if (!(-prefixcmp(arg, "-A")) ||
- !(-prefixcmp(arg, "-B")) ||
- !(-prefixcmp(arg, "-C")) ||
+ if (!prefixcmp(arg, "-A") ||
+ !prefixcmp(arg, "-B") ||
+ !prefixcmp(arg, "-C") ||
(arg[0] == '-' && '1' <= arg[1] && arg[1] <= '9')) {
unsigned num;
const char *scan;
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 71113d8fb37ebd994fb42a6776d0bbe31979f510..b5ed9ce2c89daab7a69d399a6599e203dc04971a 100644 (file)
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
incremental = 1;
continue;
}
- if (!(-prefixcmp(arg, "--window="))) {
+ if (!prefixcmp(arg, "--window=")) {
char *end;
window = strtoul(arg+9, &end, 0);
if (!arg[9] || *end)
usage(pack_usage);
continue;
}
- if (!(-prefixcmp(arg, "--depth="))) {
+ if (!prefixcmp(arg, "--depth=")) {
char *end;
depth = strtoul(arg+8, &end, 0);
if (!arg[8] || *end)
continue;
}
if (!strcmp("--unpacked", arg) ||
- !(-prefixcmp(arg, "--unpacked=")) ||
+ !prefixcmp(arg, "--unpacked=") ||
!strcmp("--reflog", arg) ||
!strcmp("--all", arg)) {
use_internal_rev_list = 1;
diff --git a/builtin-push.c b/builtin-push.c
index 2b98ba32310810462151b233053b99b0b5ab627a..979efcc45fca1a39b125e02d14b1f5d096f813ba 100644 (file)
--- a/builtin-push.c
+++ b/builtin-push.c
int is_refspec;
char *s, *p;
- if (!(-prefixcmp(buffer, "URL:"))) {
+ if (!prefixcmp(buffer, "URL:")) {
is_refspec = 0;
s = buffer + 4;
- } else if (!(-prefixcmp(buffer, "Push:"))) {
+ } else if (!prefixcmp(buffer, "Push:")) {
is_refspec = 1;
s = buffer + 5;
} else
diff --git a/builtin-rerere.c b/builtin-rerere.c
index 978105b4973a96be5cba559c1bbcc7f7e24d83ce..dd1d4c1c1de310629282bcb772139e1edec22bf4 100644 (file)
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
SHA1_Init(&ctx);
while (fgets(buf, sizeof(buf), f)) {
- if (!(-prefixcmp(buf, "<<<<<<< ")))
+ if (!prefixcmp(buf, "<<<<<<< "))
hunk = 1;
- else if (!(-prefixcmp(buf, "=======")))
+ else if (!prefixcmp(buf, "======="))
hunk = 2;
- else if (!(-prefixcmp(buf, ">>>>>>> "))) {
+ else if (!prefixcmp(buf, ">>>>>>> ")) {
hunk_no++;
hunk = 0;
if (memcmp(one->ptr, two->ptr, one->nr < two->nr ?
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index bf6aee49f7e4fbb8dd15372f5876320d3daf41e8..402a8f79300eced54cf4024b8d10f4fd766996a1 100644 (file)
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -435,9 +435,9 @@ static int append_matching_ref(const char *refname, const unsigned char *sha1, i
return 0;
if (fnmatch(match_ref_pattern, tail, 0))
return 0;
- if (!(-prefixcmp(refname, "refs/heads/")))
+ if (!prefixcmp(refname, "refs/heads/"))
return append_head_ref(refname, sha1, flag, cb_data);
- if (!(-prefixcmp(refname, "refs/tags/")))
+ if (!prefixcmp(refname, "refs/tags/"))
return append_tag_ref(refname, sha1, flag, cb_data);
return append_ref(refname, sha1, 0);
}
diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c
index 28f8c1c164c25c8256de6b343b00edbf5d61be55..b04719ef20929d40ef0c898c37616a5e7316f272 100644 (file)
--- a/builtin-tar-tree.c
+++ b/builtin-tar-tree.c
nargv[nargc++] = "git-archive";
nargv[nargc++] = "--format=tar";
- if (2 <= argc && !(-prefixcmp(argv[1], "--remote="))) {
+ if (2 <= argc && !prefixcmp(argv[1], "--remote=")) {
nargv[nargc++] = argv[1];
argv++;
argc--;
diff --git a/daemon.c b/daemon.c
index cdbc23f63d0570fbb857357ec8b6aa2a97f2e32b..e74ecac952fa0d399a1ed0c426a9e27d96b3ddcb 100644 (file)
--- a/daemon.c
+++ b/daemon.c
for (i = 0; i < ARRAY_SIZE(daemon_service); i++) {
struct daemon_service *s = &(daemon_service[i]);
int namelen = strlen(s->name);
- if (!(-prefixcmp(line, "git-")) &&
+ if (!prefixcmp(line, "git-") &&
!strncmp(s->name, line + 4, namelen) &&
line[namelen + 4] == ' ') {
/*
diff --git a/fast-import.c b/fast-import.c
index 8e192c299139545edee152eaed44e09f2d405e87..5d040fdb001c05daab19d4b6e239512cbdb07aba 100644 (file)
--- a/fast-import.c
+++ b/fast-import.c
static void cmd_mark(void)
{
- if (!(-prefixcmp(command_buf.buf, "mark :"))) {
+ if (!prefixcmp(command_buf.buf, "mark :")) {
next_mark = strtoumax(command_buf.buf + 6, NULL, 10);
read_next_command();
}
size_t length;
char *buffer;
- if ((-prefixcmp(command_buf.buf, "data ")))
+ if (prefixcmp(command_buf.buf, "data "))
die("Expected 'data n' command, found: %s", command_buf.buf);
- if (!(-prefixcmp(command_buf.buf + 5, "<<"))) {
+ if (!prefixcmp(command_buf.buf + 5, "<<")) {
char *term = xstrdup(command_buf.buf + 5 + 2);
size_t sz = 8192, term_len = command_buf.len - 5 - 2;
length = 0;
oe = find_mark(strtoumax(p + 1, &x, 10));
hashcpy(sha1, oe->sha1);
p = x;
- } else if (!(-prefixcmp(p, "inline"))) {
+ } else if (!prefixcmp(p, "inline")) {
inline_data = 1;
p += 6;
} else {
const char *from;
struct branch *s;
- if ((-prefixcmp(command_buf.buf, "from ")))
+ if (prefixcmp(command_buf.buf, "from "))
return;
if (b->branch_tree.tree) {
struct branch *s;
*count = 0;
- while (!(-prefixcmp(command_buf.buf, "merge "))) {
+ while (!prefixcmp(command_buf.buf, "merge ")) {
from = strchr(command_buf.buf, ' ') + 1;
n = xmalloc(sizeof(*n));
s = lookup_branch(from);
read_next_command();
cmd_mark();
- if (!(-prefixcmp(command_buf.buf, "author "))) {
+ if (!prefixcmp(command_buf.buf, "author ")) {
author = parse_ident(command_buf.buf + 7);
read_next_command();
}
- if (!(-prefixcmp(command_buf.buf, "committer "))) {
+ if (!prefixcmp(command_buf.buf, "committer ")) {
committer = parse_ident(command_buf.buf + 10);
read_next_command();
}
for (;;) {
if (1 == command_buf.len)
break;
- else if (!(-prefixcmp(command_buf.buf, "M ")))
+ else if (!prefixcmp(command_buf.buf, "M "))
file_change_m(b);
- else if (!(-prefixcmp(command_buf.buf, "D ")))
+ else if (!prefixcmp(command_buf.buf, "D "))
file_change_d(b);
else if (!strcmp("deleteall", command_buf.buf))
file_change_deleteall(b);
read_next_command();
/* from ... */
- if ((-prefixcmp(command_buf.buf, "from ")))
+ if (prefixcmp(command_buf.buf, "from "))
die("Expected from command, got %s", command_buf.buf);
from = strchr(command_buf.buf, ' ') + 1;
s = lookup_branch(from);
read_next_command();
/* tagger ... */
- if ((-prefixcmp(command_buf.buf, "tagger ")))
+ if (prefixcmp(command_buf.buf, "tagger "))
die("Expected tagger command, got %s", command_buf.buf);
tagger = parse_ident(command_buf.buf + 7);
break;
else if (!strcmp("blob", command_buf.buf))
cmd_new_blob();
- else if (!(-prefixcmp(command_buf.buf, "commit ")))
+ else if (!prefixcmp(command_buf.buf, "commit "))
cmd_new_commit();
- else if (!(-prefixcmp(command_buf.buf, "tag ")))
+ else if (!prefixcmp(command_buf.buf, "tag "))
cmd_new_tag();
- else if (!(-prefixcmp(command_buf.buf, "reset ")))
+ else if (!prefixcmp(command_buf.buf, "reset "))
cmd_reset_branch();
else if (!strcmp("checkpoint", command_buf.buf))
cmd_checkpoint();
diff --git a/fetch-pack.c b/fetch-pack.c
index 1fd2c3adfb5328f0fd34fc6fb1fca42c924bd514..41bdd27b8fce5dd0656b9dcc71e6768f0b4796c6 100644 (file)
--- a/fetch-pack.c
+++ b/fetch-pack.c
int len;
while ((len = packet_read_line(fd[0], line, sizeof(line)))) {
- if (!(-prefixcmp(line, "shallow "))) {
+ if (!prefixcmp(line, "shallow ")) {
if (get_sha1_hex(line + 8, sha1))
die("invalid shallow line: %s", line);
register_shallow(sha1);
continue;
}
- if (!(-prefixcmp(line, "unshallow "))) {
+ if (!prefixcmp(line, "unshallow ")) {
if (get_sha1_hex(line + 10, sha1))
die("invalid unshallow line: %s", line);
if (!lookup_object(sha1))
char *arg = argv[i];
if (*arg == '-') {
- if (!(-prefixcmp(arg, "--upload-pack="))) {
+ if (!prefixcmp(arg, "--upload-pack=")) {
uploadpack = arg + 14;
continue;
}
- if (!(-prefixcmp(arg, "--exec="))) {
+ if (!prefixcmp(arg, "--exec=")) {
uploadpack = arg + 7;
continue;
}
verbose = 1;
continue;
}
- if (!(-prefixcmp(arg, "--depth="))) {
+ if (!prefixcmp(arg, "--depth=")) {
depth = strtol(arg + 8, NULL, 0);
if (stat(git_path("shallow"), &st))
st.st_mtime = 0;
diff --git a/peek-remote.c b/peek-remote.c
index 7b66228a22f7ddeeb652924e5f42df5e63b2a7b4..96bfac498bdc58c90c9bc136a1df7bac9bfa0d92 100644 (file)
--- a/peek-remote.c
+++ b/peek-remote.c
char *arg = argv[i];
if (*arg == '-') {
- if (!(-prefixcmp(arg, "--upload-pack="))) {
+ if (!prefixcmp(arg, "--upload-pack=")) {
uploadpack = arg + 14;
continue;
}
- if (!(-prefixcmp(arg, "--exec="))) {
+ if (!prefixcmp(arg, "--exec=")) {
uploadpack = arg + 7;
continue;
}
diff --git a/upload-pack.c b/upload-pack.c
index d7876cade9b4fede8c480d6656f30f71c44cbfd9..804bbb6c9eb788714afb493e331341206cebaaf3 100644 (file)
--- a/upload-pack.c
+++ b/upload-pack.c
if (!len)
break;
- if (!(-prefixcmp(line, "shallow "))) {
+ if (!prefixcmp(line, "shallow ")) {
unsigned char sha1[20];
struct object *object;
use_thin_pack = 0;
add_object_array(object, NULL, &shallows);
continue;
}
- if (!(-prefixcmp(line, "deepen "))) {
+ if (!prefixcmp(line, "deepen ")) {
char *end;
use_thin_pack = 0;
depth = strtol(line + 7, &end, 0);
die("Invalid deepen: %s", line);
continue;
}
- if ((-prefixcmp(line, "want ")) ||
+ if (prefixcmp(line, "want ") ||
get_sha1_hex(line+5, sha1_buf))
die("git-upload-pack: protocol error, "
"expected to get sha, not '%s'", line);