[PATCH 00/86] replace prefixcmp() with has_prefix()
STALE3764d
89 messages,
3 authors,
2016-06-15 · page 1 of 2 · open the first message on its own page
Here is a big patch series to replace prefixcmp() with a new
has_prefix() function.
So the first patch of this series introduces has_prefix()
and the last patch removes prefixcmp().
Except in a few cases, I used a script that does basically
the following to generate the commits in between:
===
#!/bin/bash
perl -pi -e 's/!prefixcmp\(/has_prefix\(/g' "$1"
perl -pi -e 's/prefixcmp\(/!has_prefix\(/g' "$1"
git commit -m "$1: replace prefixcmd() with has_prefix()" "$1"
===
The few special cases are the following ones:
- remote*: replace prefixcmd() with has_prefix()
- transport*: replace prefixcmd() with has_prefix()
- environment: replace prefixcmd() with has_prefix()
In first 2 cases above, I processed a few files at the same
time instead of just one.
In the case of "environment", I removed " != 0" after
"!has_prefix(...)" as it is not necessary and makes it
more difficult to understand the logic.
Of course it's possible to squash many of the commits
together if it is prefered.
Christian Couder (86):
strbuf: add has_prefix() to be used instead of prefixcmp()
diff: replace prefixcmd() with has_prefix()
fast-import: replace prefixcmd() with has_prefix()
remote*: replace prefixcmd() with has_prefix()
daemon: replace prefixcmd() with has_prefix()
pretty: replace prefixcmd() with has_prefix()
revision: replace prefixcmd() with has_prefix()
transport*: replace prefixcmd() with has_prefix()
config: replace prefixcmd() with has_prefix()
sha1_name: replace prefixcmd() with has_prefix()
wt-status: replace prefixcmd() with has_prefix()
upload-pack: replace prefixcmd() with has_prefix()
test-line-buffer: replace prefixcmd() with has_prefix()
parse-options: replace prefixcmd() with has_prefix()
fetch-pack: replace prefixcmd() with has_prefix()
git: replace prefixcmd() with has_prefix()
tag: replace prefixcmd() with has_prefix()
sequencer: replace prefixcmd() with has_prefix()
commit: replace prefixcmd() with has_prefix()
http: replace prefixcmd() with has_prefix()
imap-send: replace prefixcmd() with has_prefix()
help: replace prefixcmd() with has_prefix()
log-tree: replace prefixcmd() with has_prefix()
merge-recursive: replace prefixcmd() with has_prefix()
notes: replace prefixcmd() with has_prefix()
refs: replace prefixcmd() with has_prefix()
setup: replace prefixcmd() with has_prefix()
bisect: replace prefixcmd() with has_prefix()
branch: replace prefixcmd() with has_prefix()
http-push: replace prefixcmd() with has_prefix()
send-pack: replace prefixcmd() with has_prefix()
http-backend: replace prefixcmd() with has_prefix()
notes-utils: replace prefixcmd() with has_prefix()
pkt-line: replace prefixcmd() with has_prefix()
alias: replace prefixcmd() with has_prefix()
attr: replace prefixcmd() with has_prefix()
connect: replace prefixcmd() with has_prefix()
pager: replace prefixcmd() with has_prefix()
convert: replace prefixcmd() with has_prefix()
environment: replace prefixcmd() with has_prefix()
shell: replace prefixcmd() with has_prefix()
pathspec: replace prefixcmd() with has_prefix()
submodule: replace prefixcmd() with has_prefix()
test-string-list: replace prefixcmd() with has_prefix()
builtin/apply: replace prefixcmd() with has_prefix()
builtin/archive: replace prefixcmd() with has_prefix()
builtin/branch: replace prefixcmd() with has_prefix()
builtin/checkout: replace prefixcmd() with has_prefix()
builtin/clean: replace prefixcmd() with has_prefix()
builtin/clone: replace prefixcmd() with has_prefix()
builtin/column: replace prefixcmd() with has_prefix()
builtin/commit: replace prefixcmd() with has_prefix()
builtin/describe: replace prefixcmd() with has_prefix()
builtin/fast-export: replace prefixcmd() with has_prefix()
builtin/fetch-pack: replace prefixcmd() with has_prefix()
builtin/fetch: replace prefixcmd() with has_prefix()
builtin/fmt-merge-msg: replace prefixcmd() with has_prefix()
builtin/for-each-ref: replace prefixcmd() with has_prefix()
builtin/fsck: replace prefixcmd() with has_prefix()
builtin/help: replace prefixcmd() with has_prefix()
builtin/index-pack: replace prefixcmd() with has_prefix()
builtin/init-db: replace prefixcmd() with has_prefix()
builtin/log: replace prefixcmd() with has_prefix()
builtin/ls-remote: replace prefixcmd() with has_prefix()
builtin/mailinfo: replace prefixcmd() with has_prefix()
builtin/merge-recursive: replace prefixcmd() with has_prefix()
builtin/merge: replace prefixcmd() with has_prefix()
builtin/name-rev: replace prefixcmd() with has_prefix()
builtin/notes: replace prefixcmd() with has_prefix()
builtin/pack-objects: replace prefixcmd() with has_prefix()
builtin/prune: replace prefixcmd() with has_prefix()
builtin/receive-pack: replace prefixcmd() with has_prefix()
builtin/reflog: replace prefixcmd() with has_prefix()
builtin/remote: replace prefixcmd() with has_prefix()
builtin/rev-parse: replace prefixcmd() with has_prefix()
builtin/send-pack: replace prefixcmd() with has_prefix()
builtin/shortlog: replace prefixcmd() with has_prefix()
builtin/show-branch: replace prefixcmd() with has_prefix()
builtin/show-ref: replace prefixcmd() with has_prefix()
builtin/symbolic-ref: replace prefixcmd() with has_prefix()
builtin/tag: replace prefixcmd() with has_prefix()
builtin/tar-tree: replace prefixcmd() with has_prefix()
builtin/unpack-objects: replace prefixcmd() with has_prefix()
builtin/update-ref: replace prefixcmd() with has_prefix()
builtin/upload-archive: replace prefixcmd() with has_prefix()
strbuf: remove prefixcmp() as it has been replaced with has_prefix()
alias.c | 2 +-
attr.c | 2 +-
bisect.c | 4 +--
branch.c | 4 +--
builtin/apply.c | 12 +++----
builtin/archive.c | 4 +--
builtin/branch.c | 6 ++--
builtin/checkout.c | 8 ++---
builtin/clean.c | 4 +--
builtin/clone.c | 6 ++--
builtin/column.c | 2 +-
builtin/commit.c | 10 +++---
builtin/describe.c | 2 +-
builtin/fast-export.c | 2 +-
builtin/fetch-pack.c | 6 ++--
builtin/fetch.c | 16 +++++-----
builtin/fmt-merge-msg.c | 10 +++---
builtin/for-each-ref.c | 14 ++++-----
builtin/fsck.c | 6 ++--
builtin/help.c | 8 ++---
builtin/index-pack.c | 8 ++---
builtin/init-db.c | 2 +-
builtin/log.c | 8 ++---
builtin/ls-remote.c | 4 +--
builtin/mailinfo.c | 16 +++++-----
builtin/merge-recursive.c | 2 +-
builtin/merge.c | 12 +++----
builtin/name-rev.c | 6 ++--
builtin/notes.c | 2 +-
builtin/pack-objects.c | 2 +-
builtin/prune.c | 4 +--
builtin/receive-pack.c | 6 ++--
builtin/reflog.c | 4 +--
builtin/remote.c | 8 ++---
builtin/rev-parse.c | 24 +++++++-------
builtin/send-pack.c | 8 ++---
builtin/shortlog.c | 6 ++--
builtin/show-branch.c | 20 ++++++------
builtin/show-ref.c | 6 ++--
builtin/symbolic-ref.c | 2 +-
builtin/tag.c | 2 +-
builtin/tar-tree.c | 2 +-
builtin/unpack-objects.c | 2 +-
builtin/update-ref.c | 10 +++---
builtin/upload-archive.c | 2 +-
commit.c | 6 ++--
config.c | 16 +++++-----
connect.c | 2 +-
convert.c | 2 +-
daemon.c | 40 ++++++++++++------------
diff.c | 56 ++++++++++++++++-----------------
environment.c | 2 +-
fast-import.c | 80 +++++++++++++++++++++++------------------------
fetch-pack.c | 12 +++----
git-compat-util.h | 2 +-
git.c | 12 +++----
help.c | 8 ++---
http-backend.c | 4 +--
http-push.c | 4 +--
http.c | 8 ++---
imap-send.c | 10 +++---
log-tree.c | 8 ++---
merge-recursive.c | 6 ++--
notes-utils.c | 4 +--
notes.c | 8 ++---
pager.c | 2 +-
parse-options.c | 12 +++----
pathspec.c | 2 +-
pkt-line.c | 4 +--
pretty.c | 36 ++++++++++-----------
refs.c | 30 +++++++++---------
remote-curl.c | 14 ++++-----
remote-testsvn.c | 10 +++---
remote.c | 46 +++++++++++++--------------
revision.c | 38 +++++++++++-----------
send-pack.c | 4 +--
sequencer.c | 8 ++---
setup.c | 4 +--
sha1_name.c | 16 +++++-----
shell.c | 2 +-
strbuf.c | 6 ++--
submodule.c | 2 +-
tag.c | 10 +++---
test-line-buffer.c | 6 ++--
test-string-list.c | 2 +-
transport-helper.c | 16 +++++-----
transport.c | 28 ++++++++---------
upload-pack.c | 10 +++---
wt-status.c | 16 +++++-----
89 files changed, 455 insertions(+), 455 deletions(-)
--
1.8.4.1.566.geca833c
prefixcmp() cannot be really used as a comparison function as
it is not antisymmetric:
prefixcmp("foo", "foobar") < 0
prefixcmp("foobar", "foo") == 0
So it is not suitable as a function for passing to qsort.
And in fact it is used nowhere as a comparison function.
So we should replace it with a function that just checks for
equality.
As a first step toward this goal, this patch introduces
has_prefix().
Signed-off-by: Christian Couder <redacted>
---
git-compat-util.h | 1 +
strbuf.c | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git a/git-compat-util.h b/git-compat-util.h
index 0f6a31e..7930f49 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h @@ -351,6 +351,7 @@ extern void set_error_routine(void (*routine)(const char *err, va_list params));
extern void set_die_is_recursing_routine ( int ( * routine )( void ));
extern int prefixcmp ( const char * str , const char * prefix );
+ extern int has_prefix ( const char * str , const char * prefix );
extern int has_suffix ( const char * str , const char * suffix );
static inline const char * skip_prefix ( const char * str , const char * prefix ) diff --git a/strbuf.c b/strbuf.c
index 0d784b5..748be6d 100644
--- a/strbuf.c
+++ b/strbuf.c @@ -10,6 +10,15 @@ int prefixcmp(const char *str, const char *prefix)
return ( unsigned char ) * prefix - ( unsigned char ) * str ;
}
+ int has_prefix ( const char * str , const char * prefix )
+ {
+ for (; ; str ++ , prefix ++ )
+ if ( !* prefix )
+ return 1 ;
+ else if ( * str != * prefix )
+ return 0 ;
+ }
+
int has_suffix ( const char * str , const char * suffix )
{
int len = strlen ( str ), suflen = strlen ( suffix ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
parse-options.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/parse-options.c b/parse-options.c
index 62e9b1c..4f7fddc 100644
--- a/parse-options.c
+++ b/parse-options.c @@ -273,13 +273,13 @@ is_abbreviated:
if ( options -> flags & PARSE_OPT_NONEG )
continue ;
/* negated and abbreviated very much? */
- if ( ! prefixcmp ( "no-" , arg )) {
+ if ( has_prefix ( "no-" , arg )) {
flags |= OPT_UNSET ;
goto is_abbreviated ;
}
/* negated? */
- if ( prefixcmp ( arg , "no-" )) {
- if ( ! prefixcmp ( long_name , "no-" )) {
+ if ( ! has_prefix ( arg , "no-" )) {
+ if ( has_prefix ( long_name , "no-" )) {
long_name += 3 ;
opt_flags |= OPT_UNSET ;
goto again ; @@ -289,7 +289,7 @@ is_abbreviated:
flags |= OPT_UNSET ;
rest = skip_prefix ( arg + 3 , long_name );
/* abbreviated and negated? */
- if ( ! rest && ! prefixcmp ( long_name , arg + 3 ))
+ if ( ! rest && has_prefix ( long_name , arg + 3 ))
goto is_abbreviated ;
if ( ! rest )
continue ; @@ -334,7 +334,7 @@ static void check_typos(const char *arg, const struct option *options)
if ( strlen ( arg ) < 3 )
return ;
- if ( ! prefixcmp ( arg , "no-" )) {
+ if ( has_prefix ( arg , "no-" )) {
error ( "did you mean `--%s` (with two dashes ?)" , arg );
exit ( 129 );
} @@ -342,7 +342,7 @@ static void check_typos(const char *arg, const struct option *options)
for (; options -> type != OPTION_END ; options ++ ) {
if ( ! options -> long_name )
continue ;
- if ( ! prefixcmp ( options -> long_name , arg )) {
+ if ( has_prefix ( options -> long_name , arg )) {
error ( "did you mean `--%s` (with two dashes ?)" , arg );
exit ( 129 );
} --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
git.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/git.c b/git.c
index cb5208d..f077f49 100644
--- a/git.c
+++ b/git.c @@ -54,7 +54,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
/*
* Check remaining flags .
*/
- if ( ! prefixcmp ( cmd , "--exec-path" )) {
+ if ( has_prefix ( cmd , "--exec-path" )) {
cmd += 11 ;
if ( * cmd == '=' )
git_set_argv_exec_path ( cmd + 1 ); @@ -92,7 +92,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
* envchanged = 1 ;
( * argv ) ++ ;
( * argc ) -- ;
- } else if ( ! prefixcmp ( cmd , "--git-dir=" )) {
+ } else if ( has_prefix ( cmd , "--git-dir=" )) {
setenv ( GIT_DIR_ENVIRONMENT , cmd + 10 , 1 );
if ( envchanged )
* envchanged = 1 ; @@ -106,7 +106,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
* envchanged = 1 ;
( * argv ) ++ ;
( * argc ) -- ;
- } else if ( ! prefixcmp ( cmd , "--namespace=" )) {
+ } else if ( has_prefix ( cmd , "--namespace=" )) {
setenv ( GIT_NAMESPACE_ENVIRONMENT , cmd + 12 , 1 );
if ( envchanged )
* envchanged = 1 ; @@ -120,7 +120,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
* envchanged = 1 ;
( * argv ) ++ ;
( * argc ) -- ;
- } else if ( ! prefixcmp ( cmd , "--work-tree=" )) {
+ } else if ( has_prefix ( cmd , "--work-tree=" )) {
setenv ( GIT_WORK_TREE_ENVIRONMENT , cmd + 12 , 1 );
if ( envchanged )
* envchanged = 1 ; @@ -569,7 +569,7 @@ int main(int argc, char **av)
* So we just directly call the internal command handler , and
* die if that one cannot handle it .
*/
- if ( ! prefixcmp ( cmd , "git-" )) {
+ if ( has_prefix ( cmd , "git-" )) {
cmd += 4 ;
argv [ 0 ] = cmd ;
handle_internal_command ( argc , argv ); @@ -581,7 +581,7 @@ int main(int argc, char **av)
argc -- ;
handle_options ( & argv , & argc , NULL );
if ( argc > 0 ) {
- if ( ! prefixcmp ( argv [ 0 ], "--" ))
+ if ( has_prefix ( argv [ 0 ], "--" ))
argv [ 0 ] += 2 ;
} else {
/* The user didn't specify a command; give them help */ --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
sequencer.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index 06e52b4..64cc6f0 100644
--- a/sequencer.c
+++ b/sequencer.c @@ -41,7 +41,7 @@ static int is_cherry_picked_from_line(const char *buf, int len)
* We only care that it looks roughly like ( cherry picked from ...)
*/
return len > strlen ( cherry_picked_prefix ) + 1 &&
- ! prefixcmp ( buf , cherry_picked_prefix ) && buf [ len - 1 ] == ')' ;
+ has_prefix ( buf , cherry_picked_prefix ) && buf [ len - 1 ] == ')' ;
}
/* @@ -180,7 +180,7 @@ static char *get_encoding(const char *message)
while ( * p && * p != '\n' ) {
for ( eol = p + 1 ; * eol && * eol != '\n' ; eol ++ )
; /* do nothing */
- if ( ! prefixcmp ( p , "encoding " )) {
+ if ( has_prefix ( p , "encoding " )) {
char * result = xmalloc ( eol - 8 - p );
strlcpy ( result , p + 9 , eol - 8 - p );
return result ; @@ -705,10 +705,10 @@ static struct commit *parse_insn_line(char *bol, char *eol, struct replay_opts *
char * end_of_object_name ;
int saved , status , padding ;
- if ( ! prefixcmp ( bol , "pick" )) {
+ if ( has_prefix ( bol , "pick" )) {
action = REPLAY_PICK ;
bol += strlen ( "pick" );
- } else if ( ! prefixcmp ( bol , "revert" )) {
+ } else if ( has_prefix ( bol , "revert" )) {
action = REPLAY_REVERT ;
bol += strlen ( "revert" );
} else --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
fetch-pack.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/fetch-pack.c b/fetch-pack.c
index a0e0350..1526ed1 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c @@ -176,9 +176,9 @@ static void consume_shallow_list(struct fetch_pack_args *args, int fd)
*/
char * line ;
while (( line = packet_read_line ( fd , NULL ))) {
- if ( ! prefixcmp ( line , "shallow " ))
+ if ( has_prefix ( line , "shallow " ))
continue ;
- if ( ! prefixcmp ( line , "unshallow " ))
+ if ( has_prefix ( line , "unshallow " ))
continue ;
die ( "git fetch-pack: expected shallow list" );
} @@ -194,7 +194,7 @@ static enum ack_type get_ack(int fd, unsigned char *result_sha1)
die ( "git fetch-pack: expected ACK/NAK, got EOF" );
if ( ! strcmp ( line , "NAK" ))
return NAK ;
- if ( ! prefixcmp ( line , "ACK " )) {
+ if ( has_prefix ( line , "ACK " )) {
if ( ! get_sha1_hex ( line + 4 , result_sha1 )) {
if ( len < 45 )
return ACK ; @@ -323,13 +323,13 @@ static int find_common(struct fetch_pack_args *args,
send_request ( args , fd [ 1 ], & req_buf );
while (( line = packet_read_line ( fd [ 0 ], NULL ))) {
- if ( ! prefixcmp ( line , "shallow " )) {
+ if ( has_prefix ( line , "shallow " )) {
if ( get_sha1_hex ( line + 8 , sha1 ))
die ( "invalid shallow line: %s" , line );
register_shallow ( sha1 );
continue ;
}
- if ( ! prefixcmp ( line , "unshallow " )) {
+ if ( has_prefix ( line , "unshallow " )) {
if ( get_sha1_hex ( line + 10 , sha1 ))
die ( "invalid unshallow line: %s" , line );
if ( ! lookup_object ( sha1 )) @@ -523,7 +523,7 @@ static void filter_refs(struct fetch_pack_args *args,
}
if ( ! keep && args -> fetch_all &&
- ( ! args -> depth || prefixcmp ( ref -> name , "refs/tags/" )))
+ ( ! args -> depth || ! has_prefix ( ref -> name , "refs/tags/" )))
keep = 1 ;
if ( keep ) { --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
tag.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tag.c b/tag.c
index 78d272b..0b00c76 100644
--- a/tag.c
+++ b/tag.c @@ -86,7 +86,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
return -1 ;
bufptr += 48 ; /* "object " + sha1 + "\n" */
- if ( prefixcmp ( bufptr , "type " ))
+ if ( ! has_prefix ( bufptr , "type " ))
return -1 ;
bufptr += 5 ;
nl = memchr ( bufptr , '\n' , tail - bufptr ); @@ -109,7 +109,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
item -> tagged = NULL ;
}
- if ( bufptr + 4 < tail && ! prefixcmp ( bufptr , "tag " ))
+ if ( bufptr + 4 < tail && has_prefix ( bufptr , "tag " ))
; /* good */
else
return -1 ; @@ -120,7 +120,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
item -> tag = xmemdupz ( bufptr , nl - bufptr );
bufptr = nl + 1 ;
- if ( bufptr + 7 < tail && ! prefixcmp ( bufptr , "tagger " ))
+ if ( bufptr + 7 < tail && has_prefix ( bufptr , "tagger " ))
item -> date = parse_tag_date ( bufptr , tail );
else
item -> date = 0 ; @@ -160,8 +160,8 @@ size_t parse_signature(const char *buf, unsigned long size)
{
char * eol ;
size_t len = 0 ;
- while ( len < size && prefixcmp ( buf + len , PGP_SIGNATURE ) &&
- prefixcmp ( buf + len , PGP_MESSAGE )) {
+ while ( len < size && ! has_prefix ( buf + len , PGP_SIGNATURE ) &&
+ ! has_prefix ( buf + len , PGP_MESSAGE )) {
eol = memchr ( buf + len , '\n' , size - len );
len += eol ? eol - ( buf + len ) + 1 : size - len ;
} --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
bisect.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bisect.c b/bisect.c
index 1e46a4f..4819091 100644
--- a/bisect.c
+++ b/bisect.c @@ -406,9 +406,9 @@ static int register_ref(const char *refname, const unsigned char *sha1,
if ( ! strcmp ( refname , "bad" )) {
current_bad_sha1 = xmalloc ( 20 );
hashcpy ( current_bad_sha1 , sha1 );
- } else if ( ! prefixcmp ( refname , "good-" )) {
+ } else if ( has_prefix ( refname , "good-" )) {
sha1_array_append ( & good_revs , sha1 );
- } else if ( ! prefixcmp ( refname , "skip-" )) {
+ } else if ( has_prefix ( refname , "skip-" )) {
sha1_array_append ( & skipped_revs , sha1 );
}
--
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
merge-recursive.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/merge-recursive.c b/merge-recursive.c
index dbb7104..9043362 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c @@ -2063,13 +2063,13 @@ int parse_merge_opt(struct merge_options *o, const char *s)
o -> recursive_variant = MERGE_RECURSIVE_THEIRS ;
else if ( ! strcmp ( s , "subtree" ))
o -> subtree_shift = "" ;
- else if ( ! prefixcmp ( s , "subtree=" ))
+ else if ( has_prefix ( s , "subtree=" ))
o -> subtree_shift = s + strlen ( "subtree=" );
else if ( ! strcmp ( s , "patience" ))
o -> xdl_opts = DIFF_WITH_ALG ( o , PATIENCE_DIFF );
else if ( ! strcmp ( s , "histogram" ))
o -> xdl_opts = DIFF_WITH_ALG ( o , HISTOGRAM_DIFF );
- else if ( ! prefixcmp ( s , "diff-algorithm=" )) {
+ else if ( has_prefix ( s , "diff-algorithm=" )) {
long value = parse_algorithm_value ( s + strlen ( "diff-algorithm=" ));
if ( value < 0 )
return -1 ; @@ -2088,7 +2088,7 @@ int parse_merge_opt(struct merge_options *o, const char *s)
o -> renormalize = 1 ;
else if ( ! strcmp ( s , "no-renormalize" ))
o -> renormalize = 0 ;
- else if ( ! prefixcmp ( s , "rename-threshold=" )) {
+ else if ( has_prefix ( s , "rename-threshold=" )) {
const char * score = s + strlen ( "rename-threshold=" );
if (( o -> rename_score = parse_rename_score ( & score )) == -1 || * score != 0 )
return -1 ; --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
imap-send.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/imap-send.c b/imap-send.c
index 6f5cc4f..670de9f 100644
--- a/imap-send.c
+++ b/imap-send.c @@ -1263,7 +1263,7 @@ static int count_messages(struct strbuf *all_msgs)
char * p = all_msgs -> buf ;
while ( 1 ) {
- if ( ! prefixcmp ( p , "From " )) {
+ if ( has_prefix ( p , "From " )) {
p = strstr ( p + 5 , " \n From: " );
if ( ! p ) break ;
p = strstr ( p + 7 , " \n Date: " ); @@ -1297,7 +1297,7 @@ static int split_msg(struct strbuf *all_msgs, struct strbuf *msg, int *ofs)
data = & all_msgs -> buf [ * ofs ];
len = all_msgs -> len - * ofs ;
- if ( len < 5 || prefixcmp ( data , "From " ))
+ if ( len < 5 || ! has_prefix ( data , "From " ))
return 0 ;
p = strchr ( data , '\n' ); @@ -1339,13 +1339,13 @@ static int git_imap_config(const char *key, const char *val, void *cb)
if ( ! strcmp ( "folder" , key )) {
imap_folder = xstrdup ( val );
} else if ( ! strcmp ( "host" , key )) {
- if ( ! prefixcmp ( val , "imap:" ))
+ if ( has_prefix ( val , "imap:" ))
val += 5 ;
- else if ( ! prefixcmp ( val , "imaps:" )) {
+ else if ( has_prefix ( val , "imaps:" )) {
val += 6 ;
server . use_ssl = 1 ;
}
- if ( ! prefixcmp ( val , "//" ))
+ if ( has_prefix ( val , "//" ))
val += 2 ;
server . host = xstrdup ( val );
} else if ( ! strcmp ( "user" , key )) --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
send-pack.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/send-pack.c b/send-pack.c
index b228d65..c90049a 100644
--- a/send-pack.c
+++ b/send-pack.c @@ -109,7 +109,7 @@ static int receive_status(int in, struct ref *refs)
struct ref * hint ;
int ret = 0 ;
char * line = packet_read_line ( in , NULL );
- if ( prefixcmp ( line , "unpack " ))
+ if ( ! has_prefix ( line , "unpack " ))
return error ( "did not receive remote status" );
if ( strcmp ( line , "unpack ok" )) {
error ( "unpack failed: %s" , line + 7 ); @@ -122,7 +122,7 @@ static int receive_status(int in, struct ref *refs)
line = packet_read_line ( in , NULL );
if ( ! line )
break ;
- if ( prefixcmp ( line , "ok " ) && prefixcmp ( line , "ng " )) {
+ if ( ! has_prefix ( line , "ok " ) && ! has_prefix ( line , "ng " )) {
error ( "invalid ref status from remote: %s" , line );
ret = -1 ;
break ; --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
http.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/http.c b/http.c
index f3e1439..f2621cd 100644
--- a/http.c
+++ b/http.c @@ -422,7 +422,7 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
credential_from_url ( & http_auth , url );
if ( ! ssl_cert_password_required &&
getenv ( "GIT_SSL_CERT_PASSWORD_PROTECTED" ) &&
- ! prefixcmp ( url , "https://" ))
+ has_prefix ( url , "https://" ))
ssl_cert_password_required = 1 ;
}
@@ -985,7 +985,7 @@ int http_fetch_ref(const char *base, struct ref *ref)
strbuf_rtrim ( & buffer );
if ( buffer . len == 40 )
ret = get_sha1_hex ( buffer . buf , ref -> old_sha1 );
- else if ( ! prefixcmp ( buffer . buf , "ref: " )) {
+ else if ( has_prefix ( buffer . buf , "ref: " )) {
ref -> symref = xstrdup ( buffer . buf + 5 );
ret = 0 ;
} @@ -1084,8 +1084,8 @@ int http_get_info_packs(const char *base_url, struct packed_git **packs_head)
case 'P' :
i ++ ;
if ( i + 52 <= buf . len &&
- ! prefixcmp ( data + i , " pack-" ) &&
- ! prefixcmp ( data + i + 46 , ".pack \n " )) {
+ has_prefix ( data + i , " pack-" ) &&
+ has_prefix ( data + i + 46 , ".pack \n " )) {
get_sha1_hex ( data + i + 6 , sha1 );
fetch_and_setup_pack_index ( packs_head , sha1 ,
base_url ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
log-tree.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/log-tree.c b/log-tree.c
index 8534d91..25b46a9 100644
--- a/log-tree.c
+++ b/log-tree.c @@ -98,7 +98,7 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in
struct object * obj ;
enum decoration_type type = DECORATION_NONE ;
- if ( ! prefixcmp ( refname , "refs/replace/" )) {
+ if ( has_prefix ( refname , "refs/replace/" )) {
unsigned char original_sha1 [ 20 ];
if ( ! read_replace_refs )
return 0 ; @@ -116,11 +116,11 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in
if ( ! obj )
return 0 ;
- if ( ! prefixcmp ( refname , "refs/heads/" ))
+ if ( has_prefix ( refname , "refs/heads/" ))
type = DECORATION_REF_LOCAL ;
- else if ( ! prefixcmp ( refname , "refs/remotes/" ))
+ else if ( has_prefix ( refname , "refs/remotes/" ))
type = DECORATION_REF_REMOTE ;
- else if ( ! prefixcmp ( refname , "refs/tags/" ))
+ else if ( has_prefix ( refname , "refs/tags/" ))
type = DECORATION_REF_TAG ;
else if ( ! strcmp ( refname , "refs/stash" ))
type = DECORATION_REF_STASH ; --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
setup.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/setup.c b/setup.c
index f08dd64..6ed292a 100644
--- a/setup.c
+++ b/setup.c @@ -82,7 +82,7 @@ int check_filename(const char *prefix, const char *arg)
const char * name ;
struct stat st ;
- if ( ! prefixcmp ( arg , ":/" )) {
+ if ( has_prefix ( arg , ":/" )) {
if ( arg [ 2 ] == '\0' ) /* ":/" is root dir, always exists */
return 1 ;
name = arg + 2 ; @@ -307,7 +307,7 @@ const char *read_gitfile(const char *path)
if ( len != st . st_size )
die ( "Error reading %s" , path );
buf [ len ] = '\0' ;
- if ( prefixcmp ( buf , "gitdir: " ))
+ if ( ! has_prefix ( buf , "gitdir: " ))
die ( "Invalid gitfile format: %s" , path );
while ( buf [ len - 1 ] == '\n' || buf [ len - 1 ] == '\r' )
len -- ; --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/fsck.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 97ce678..a80e51f 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c @@ -442,7 +442,7 @@ static void fsck_dir(int i, char *path)
add_sha1_list ( sha1 , DIRENT_SORT_HINT ( de ));
continue ;
}
- if ( ! prefixcmp ( de -> d_name , "tmp_obj_" ))
+ if ( has_prefix ( de -> d_name , "tmp_obj_" ))
continue ;
fprintf ( stderr , "bad sha1 file: %s/%s \n " , path , de -> d_name );
} @@ -484,7 +484,7 @@ static int fsck_handle_reflog(const char *logname, const unsigned char *sha1, in
static int is_branch ( const char * refname )
{
- return ! strcmp ( refname , "HEAD" ) || ! prefixcmp ( refname , "refs/heads/" );
+ return ! strcmp ( refname , "HEAD" ) || has_prefix ( refname , "refs/heads/" );
}
static int fsck_handle_ref ( const char * refname , const unsigned char * sha1 , int flag , void * cb_data ) @@ -566,7 +566,7 @@ static int fsck_head_link(void)
if ( ! strcmp ( head_points_at , "HEAD" ))
/* detached HEAD */
null_is_error = 1 ;
- else if ( prefixcmp ( head_points_at , "refs/heads/" ))
+ else if ( ! has_prefix ( head_points_at , "refs/heads/" ))
return error ( "HEAD points to something strange (%s)" ,
head_points_at );
if ( is_null_sha1 ( head_sha1 )) { --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/fast-export.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 78250ea..8a9136b 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c @@ -476,7 +476,7 @@ static void handle_tag(const char *name, struct tag *tag)
}
}
- if ( ! prefixcmp ( name , "refs/tags/" ))
+ if ( has_prefix ( name , "refs/tags/" ))
name += 10 ;
printf ( "tag %s \n from :%d \n %.*s%sdata %d \n %.*s \n " ,
name , tagged_mark , --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/fmt-merge-msg.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index 1c04070..09a55bf 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c @@ -109,7 +109,7 @@ static int handle_line(char *line, struct merge_parents *merge_parents)
if ( len < 43 || line [ 40 ] != '\t' )
return 1 ;
- if ( ! prefixcmp ( line + 41 , "not-for-merge" ))
+ if ( has_prefix ( line + 41 , "not-for-merge" ))
return 0 ;
if ( line [ 41 ] != '\t' ) @@ -155,16 +155,16 @@ static int handle_line(char *line, struct merge_parents *merge_parents)
if ( pulling_head ) {
origin = src ;
src_data -> head_status |= 1 ;
- } else if ( ! prefixcmp ( line , "branch " )) {
+ } else if ( has_prefix ( line , "branch " )) {
origin_data -> is_local_branch = 1 ;
origin = line + 7 ;
string_list_append ( & src_data -> branch , origin );
src_data -> head_status |= 2 ;
- } else if ( ! prefixcmp ( line , "tag " )) {
+ } else if ( has_prefix ( line , "tag " )) {
origin = line ;
string_list_append ( & src_data -> tag , origin + 4 );
src_data -> head_status |= 2 ;
- } else if ( ! prefixcmp ( line , "remote-tracking branch " )) {
+ } else if ( has_prefix ( line , "remote-tracking branch " )) {
origin = line + strlen ( "remote-tracking branch " );
string_list_append ( & src_data -> r_branch , origin );
src_data -> head_status |= 2 ; @@ -605,7 +605,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
resolve_refdup ( "HEAD" , head_sha1 , 1 , NULL );
if ( ! current_branch )
die ( "No current branch" );
- if ( ! prefixcmp ( current_branch , "refs/heads/" ))
+ if ( has_prefix ( current_branch , "refs/heads/" ))
current_branch += 11 ;
find_merge_parents ( & merge_parents , in , head_sha1 ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/fetch-pack.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index c8e8582..29a3b33 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c @@ -48,11 +48,11 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
for ( i = 1 ; i < argc && * argv [ i ] == '-' ; i ++ ) {
const char * arg = argv [ i ];
- if ( ! prefixcmp ( arg , "--upload-pack=" )) {
+ if ( has_prefix ( arg , "--upload-pack=" )) {
args . uploadpack = arg + 14 ;
continue ;
}
- if ( ! prefixcmp ( arg , "--exec=" )) {
+ if ( has_prefix ( arg , "--exec=" )) {
args . uploadpack = arg + 7 ;
continue ;
} @@ -85,7 +85,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
args . verbose = 1 ;
continue ;
}
- if ( ! prefixcmp ( arg , "--depth=" )) {
+ if ( has_prefix ( arg , "--depth=" )) {
args . depth = strtol ( arg + 8 , NULL , 0 );
continue ;
} --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/for-each-ref.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index 1d4083c..c22f200 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c @@ -432,7 +432,7 @@ static void grab_person(const char *who, struct atom_value *val, int deref, stru
if ( name [ wholen ] != 0 &&
strcmp ( name + wholen , "name" ) &&
strcmp ( name + wholen , "email" ) &&
- prefixcmp ( name + wholen , "date" ))
+ ! has_prefix ( name + wholen , "date" ))
continue ;
if ( ! wholine )
wholine = find_wholine ( who , wholen , buf , sz ); @@ -444,7 +444,7 @@ static void grab_person(const char *who, struct atom_value *val, int deref, stru
v -> s = copy_name ( wholine );
else if ( ! strcmp ( name + wholen , "email" ))
v -> s = copy_email ( wholine );
- else if ( ! prefixcmp ( name + wholen , "date" ))
+ else if ( has_prefix ( name + wholen , "date" ))
grab_date ( wholine , v , name );
}
@@ -466,7 +466,7 @@ static void grab_person(const char *who, struct atom_value *val, int deref, stru
if ( deref )
name ++ ;
- if ( ! prefixcmp ( name , "creatordate" ))
+ if ( has_prefix ( name , "creatordate" ))
grab_date ( wholine , v , name );
else if ( ! strcmp ( name , "creator" ))
v -> s = copy_line ( wholine ); @@ -646,14 +646,14 @@ static void populate_value(struct refinfo *ref)
name ++ ;
}
- if ( ! prefixcmp ( name , "refname" ))
+ if ( has_prefix ( name , "refname" ))
refname = ref -> refname ;
- else if ( ! prefixcmp ( name , "symref" ))
+ else if ( has_prefix ( name , "symref" ))
refname = ref -> symref ? ref -> symref : "" ;
- else if ( ! prefixcmp ( name , "upstream" )) {
+ else if ( has_prefix ( name , "upstream" )) {
struct branch * branch ;
/* only local branches may have an upstream */
- if ( prefixcmp ( ref -> refname , "refs/heads/" ))
+ if ( ! has_prefix ( ref -> refname , "refs/heads/" ))
continue ;
branch = branch_get ( ref -> refname + 11 );
--
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/fetch.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 8eb6cd0..78d4add 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c @@ -313,7 +313,7 @@ static int update_local_ref(struct ref *ref,
}
if ( ! is_null_sha1 ( ref -> old_sha1 ) &&
- ! prefixcmp ( ref -> name , "refs/tags/" )) {
+ has_prefix ( ref -> name , "refs/tags/" )) {
int r ;
r = s_update_ref ( "updating tag" , ref , 0 );
strbuf_addf ( display , "%c %-*s %-*s -> %s%s" , @@ -336,10 +336,10 @@ static int update_local_ref(struct ref *ref,
* more likely to follow a standard layout .
*/
const char * name = remote_ref ? remote_ref -> name : "" ;
- if ( ! prefixcmp ( name , "refs/tags/" )) {
+ if ( has_prefix ( name , "refs/tags/" )) {
msg = "storing tag" ;
what = _ ( "[new tag]" );
- } else if ( ! prefixcmp ( name , "refs/heads/" )) {
+ } else if ( has_prefix ( name , "refs/heads/" )) {
msg = "storing head" ;
what = _ ( "[new branch]" );
} else { @@ -471,15 +471,15 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
kind = "" ;
what = "" ;
}
- else if ( ! prefixcmp ( rm -> name , "refs/heads/" )) {
+ else if ( has_prefix ( rm -> name , "refs/heads/" )) {
kind = "branch" ;
what = rm -> name + 11 ;
}
- else if ( ! prefixcmp ( rm -> name , "refs/tags/" )) {
+ else if ( has_prefix ( rm -> name , "refs/tags/" )) {
kind = "tag" ;
what = rm -> name + 10 ;
}
- else if ( ! prefixcmp ( rm -> name , "refs/remotes/" )) {
+ else if ( has_prefix ( rm -> name , "refs/remotes/" )) {
kind = "remote-tracking branch" ;
what = rm -> name + 13 ;
} @@ -644,7 +644,7 @@ static void find_non_local_tags(struct transport *transport,
for_each_ref ( add_existing , & existing_refs );
for ( ref = transport_get_remote_refs ( transport ); ref ; ref = ref -> next ) {
- if ( prefixcmp ( ref -> name , "refs/tags/" ))
+ if ( ! has_prefix ( ref -> name , "refs/tags/" ))
continue ;
/* @@ -892,7 +892,7 @@ static int get_remote_group(const char *key, const char *value, void *priv)
{
struct remote_group_data * g = priv ;
- if ( ! prefixcmp ( key , "remotes." ) &&
+ if ( has_prefix ( key , "remotes." ) &&
! strcmp ( key + 8 , g -> name )) {
/* split list by white space */
int space = strcspn ( value , " \t\n " ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/column.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/column.c b/builtin/column.c
index e125a55..3664cc1 100644
--- a/builtin/column.c
+++ b/builtin/column.c @@ -34,7 +34,7 @@ int cmd_column(int argc, const char **argv, const char *prefix)
};
/* This one is special and must be the first one */
- if ( argc > 1 && ! prefixcmp ( argv [ 1 ], "--command=" )) {
+ if ( argc > 1 && has_prefix ( argv [ 1 ], "--command=" )) {
command = argv [ 1 ] + 10 ;
git_config ( column_config , ( void * ) command );
} else --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/archive.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/archive.c b/builtin/archive.c
index 49178f1..b808bb5 100644
--- a/builtin/archive.c
+++ b/builtin/archive.c @@ -57,9 +57,9 @@ static int run_remote_archiver(int argc, const char **argv,
if ( ! buf )
die ( _ ( "git archive: expected ACK/NAK, got EOF" ));
if ( strcmp ( buf , "ACK" )) {
- if ( ! prefixcmp ( buf , "NACK " ))
+ if ( has_prefix ( buf , "NACK " ))
die ( _ ( "git archive: NACK %s" ), buf + 5 );
- if ( ! prefixcmp ( buf , "ERR " ))
+ if ( has_prefix ( buf , "ERR " ))
die ( _ ( "remote error: %s" ), buf + 4 );
die ( _ ( "git archive: protocol error" ));
} --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/commit.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index 6ab4605..a8c46c6 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c @@ -733,7 +733,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
eol = nl - sb . buf ;
else
eol = sb . len ;
- if ( ! prefixcmp ( sb . buf + previous , " \n Conflicts: \n " )) {
+ if ( has_prefix ( sb . buf + previous , " \n Conflicts: \n " )) {
ignore_footer = sb . len - previous ;
break ;
} @@ -904,7 +904,7 @@ static int rest_is_empty(struct strbuf *sb, int start)
eol = sb -> len ;
if ( strlen ( sign_off_header ) <= eol - i &&
- ! prefixcmp ( sb -> buf + i , sign_off_header )) {
+ has_prefix ( sb -> buf + i , sign_off_header )) {
i = eol ;
continue ;
} @@ -1183,7 +1183,7 @@ static int git_status_config(const char *k, const char *v, void *cb)
{
struct wt_status * s = cb ;
- if ( ! prefixcmp ( k , "column." ))
+ if ( has_prefix ( k , "column." ))
return git_column_config ( k , v , "status" , & s -> colopts );
if ( ! strcmp ( k , "status.submodulesummary" )) {
int is_bool ; @@ -1211,7 +1211,7 @@ static int git_status_config(const char *k, const char *v, void *cb)
s -> display_comment_prefix = git_config_bool ( k , v );
return 0 ;
}
- if ( ! prefixcmp ( k , "status.color." ) || ! prefixcmp ( k , "color.status." )) {
+ if ( has_prefix ( k , "status.color." ) || has_prefix ( k , "color.status." )) {
int slot = parse_status_slot ( k , 13 );
if ( slot < 0 )
return 0 ; @@ -1377,7 +1377,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1,
head = resolve_ref_unsafe ( "HEAD" , junk_sha1 , 0 , NULL );
printf ( "[%s%s " ,
- ! prefixcmp ( head , "refs/heads/" ) ?
+ has_prefix ( head , "refs/heads/" ) ?
head + 11 :
! strcmp ( head , "HEAD" ) ?
_ ( "detached HEAD" ) : --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/describe.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/describe.c b/builtin/describe.c
index b9d3603..102d958 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c @@ -141,7 +141,7 @@ static void add_to_known_names(const char *path,
static int get_name ( const char * path , const unsigned char * sha1 , int flag , void * cb_data )
{
- int is_tag = ! prefixcmp ( path , "refs/tags/" );
+ int is_tag = has_prefix ( path , "refs/tags/" );
unsigned char peeled [ 20 ];
int is_annotated , prio ;
--
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/clean.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/clean.c b/builtin/clean.c
index 615cd57..98887cd 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c @@ -100,7 +100,7 @@ static int parse_clean_color_slot(const char *var)
static int git_clean_config ( const char * var , const char * value , void * cb )
{
- if ( ! prefixcmp ( var , "column." ))
+ if ( has_prefix ( var , "column." ))
return git_column_config ( var , value , "clean" , & colopts );
/* honors the color.interactive* config variables which also @@ -109,7 +109,7 @@ static int git_clean_config(const char *var, const char *value, void *cb)
clean_use_color = git_config_colorbool ( var , value );
return 0 ;
}
- if ( ! prefixcmp ( var , "color.interactive." )) {
+ if ( has_prefix ( var , "color.interactive." )) {
int slot = parse_clean_color_slot ( var +
strlen ( "color.interactive." ));
if ( slot < 0 ) --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/clone.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index 84fb1bd..49b7a08 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c @@ -508,7 +508,7 @@ static void write_followtags(const struct ref *refs, const char *msg)
{
const struct ref * ref ;
for ( ref = refs ; ref ; ref = ref -> next ) {
- if ( prefixcmp ( ref -> name , "refs/tags/" ))
+ if ( ! has_prefix ( ref -> name , "refs/tags/" ))
continue ;
if ( has_suffix ( ref -> name , "^{}" ))
continue ; @@ -578,7 +578,7 @@ static void update_remote_refs(const struct ref *refs,
static void update_head ( const struct ref * our , const struct ref * remote ,
const char * msg )
{
- if ( our && ! prefixcmp ( our -> name , "refs/heads/" )) {
+ if ( our && has_prefix ( our -> name , "refs/heads/" )) {
/* Local default branch link */
create_symref ( "HEAD" , our -> name , NULL );
if ( ! option_bare ) { @@ -625,7 +625,7 @@ static int checkout(void)
if ( advice_detached_head )
detach_advice ( sha1_to_hex ( sha1 ));
} else {
- if ( prefixcmp ( head , "refs/heads/" ))
+ if ( ! has_prefix ( head , "refs/heads/" ))
die ( _ ( "HEAD not found below refs/heads!" ));
}
free ( head ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/checkout.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 0f57397..7ce15dd 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c @@ -781,7 +781,7 @@ static int switch_branches(const struct checkout_opts *opts,
if ( ! ( flag & REF_ISSYMREF ))
old . path = NULL ;
- if ( old . path && ! prefixcmp ( old . path , "refs/heads/" ))
+ if ( old . path && has_prefix ( old . path , "refs/heads/" ))
old . name = old . path + strlen ( "refs/heads/" );
if ( ! new -> name ) { @@ -816,7 +816,7 @@ static int git_checkout_config(const char *var, const char *value, void *cb)
return 0 ;
}
- if ( ! prefixcmp ( var , "submodule." ))
+ if ( has_prefix ( var , "submodule." ))
return parse_submodule_config_option ( var , value );
return git_xmerge_config ( var , value , NULL ); @@ -1108,9 +1108,9 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
const char * argv0 = argv [ 0 ];
if ( ! argc || ! strcmp ( argv0 , "--" ))
die ( _ ( "--track needs a branch name" ));
- if ( ! prefixcmp ( argv0 , "refs/" ))
+ if ( has_prefix ( argv0 , "refs/" ))
argv0 += 5 ;
- if ( ! prefixcmp ( argv0 , "remotes/" ))
+ if ( has_prefix ( argv0 , "remotes/" ))
argv0 += 8 ;
argv0 = strchr ( argv0 , '/' );
if ( ! argv0 || ! argv0 [ 1 ]) --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/branch.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index ad0f86d..c4cb81c 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c @@ -81,13 +81,13 @@ static int parse_branch_color_slot(const char *var, int ofs)
static int git_branch_config ( const char * var , const char * value , void * cb )
{
- if ( ! prefixcmp ( var , "column." ))
+ if ( has_prefix ( var , "column." ))
return git_column_config ( var , value , "branch" , & colopts );
if ( ! strcmp ( var , "color.branch" )) {
branch_use_color = git_config_colorbool ( var , value );
return 0 ;
}
- if ( ! prefixcmp ( var , "color.branch." )) {
+ if ( has_prefix ( var , "color.branch." )) {
int slot = parse_branch_color_slot ( var , 13 );
if ( slot < 0 )
return 0 ; @@ -862,7 +862,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
if ( ! strcmp ( head , "HEAD" )) {
detached = 1 ;
} else {
- if ( prefixcmp ( head , "refs/heads/" ))
+ if ( ! has_prefix ( head , "refs/heads/" ))
die ( _ ( "HEAD not found below refs/heads!" ));
head += 11 ;
} --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/apply.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/builtin/apply.c b/builtin/apply.c
index ef32e4f..49028da 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c @@ -1409,10 +1409,10 @@ static void recount_diff(const char *line, int size, struct fragment *fragment)
case '\\' :
continue ;
case '@' :
- ret = size < 3 || prefixcmp ( line , "@@ " );
+ ret = size < 3 || ! has_prefix ( line , "@@ " );
break ;
case 'd' :
- ret = size < 5 || prefixcmp ( line , "diff " );
+ ret = size < 5 || ! has_prefix ( line , "diff " );
break ;
default :
ret = -1 ; @@ -1798,11 +1798,11 @@ static struct fragment *parse_binary_hunk(char **buf_p,
* status_p = 0 ;
- if ( ! prefixcmp ( buffer , "delta " )) {
+ if ( has_prefix ( buffer , "delta " )) {
patch_method = BINARY_DELTA_DEFLATED ;
origlen = strtoul ( buffer + 6 , NULL , 10 );
}
- else if ( ! prefixcmp ( buffer , "literal " )) {
+ else if ( has_prefix ( buffer , "literal " )) {
patch_method = BINARY_LITERAL_DEFLATED ;
origlen = strtoul ( buffer + 8 , NULL , 10 );
} @@ -3627,12 +3627,12 @@ static int preimage_sha1_in_gitlink_patch(struct patch *p, unsigned char sha1[20
hunk -> oldpos == 1 && hunk -> oldlines == 1 &&
/* does preimage begin with the heading? */
( preimage = memchr ( hunk -> patch , '\n' , hunk -> size )) != NULL &&
- ! prefixcmp ( ++ preimage , heading ) &&
+ has_prefix ( ++ preimage , heading ) &&
/* does it record full SHA-1? */
! get_sha1_hex ( preimage + sizeof ( heading ) - 1 , sha1 ) &&
preimage [ sizeof ( heading ) + 40 - 1 ] == '\n' &&
/* does the abbreviated name on the index line agree with it? */
- ! prefixcmp ( preimage + sizeof ( heading ) - 1 , p -> old_sha1_prefix ))
+ has_prefix ( preimage + sizeof ( heading ) - 1 , p -> old_sha1_prefix ))
return 0 ; /* it all looks fine */
/* we may have full object name on the index line */ --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
test-string-list.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test-string-list.c b/test-string-list.c
index 00ce6c9..e04a37c 100644
--- a/test-string-list.c
+++ b/test-string-list.c @@ -38,7 +38,7 @@ static void write_list_compact(const struct string_list *list)
static int prefix_cb ( struct string_list_item * item , void * cb_data )
{
const char * prefix = ( const char * ) cb_data ;
- return ! prefixcmp ( item -> string , prefix );
+ return has_prefix ( item -> string , prefix );
}
int main ( int argc , char ** argv ) --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
pathspec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pathspec.c b/pathspec.c
index ad1a9f5..182b162 100644
--- a/pathspec.c
+++ b/pathspec.c @@ -150,7 +150,7 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
magic |= pathspec_magic [ i ]. bit ;
break ;
}
- if ( ! prefixcmp ( copyfrom , "prefix:" )) {
+ if ( has_prefix ( copyfrom , "prefix:" )) {
char * endptr ;
pathspec_prefix = strtol ( copyfrom + 7 ,
& endptr , 10 ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
alias.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/alias.c b/alias.c
index eb9f08b..0933c87 100644
--- a/alias.c
+++ b/alias.c @@ -5,7 +5,7 @@ static char *alias_val;
static int alias_lookup_cb ( const char * k , const char * v , void * cb )
{
- if ( ! prefixcmp ( k , "alias." ) && ! strcmp ( k + 6 , alias_key )) {
+ if ( has_prefix ( k , "alias." ) && ! strcmp ( k + 6 , alias_key )) {
if ( ! v )
return config_error_nonbool ( k );
alias_val = xstrdup ( v ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
notes-utils.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/notes-utils.c b/notes-utils.c
index 9107c37..0a4c3de 100644
--- a/notes-utils.c
+++ b/notes-utils.c @@ -70,7 +70,7 @@ static combine_notes_fn parse_combine_notes_fn(const char *v)
static int notes_rewrite_config ( const char * k , const char * v , void * cb )
{
struct notes_rewrite_cfg * c = cb ;
- if ( ! prefixcmp ( k , "notes.rewrite." ) && ! strcmp ( k + 14 , c -> cmd )) {
+ if ( has_prefix ( k , "notes.rewrite." ) && ! strcmp ( k + 14 , c -> cmd )) {
c -> enabled = git_config_bool ( k , v );
return 0 ;
} else if ( ! c -> mode_from_env && ! strcmp ( k , "notes.rewritemode" )) { @@ -85,7 +85,7 @@ static int notes_rewrite_config(const char *k, const char *v, void *cb)
} else if ( ! c -> refs_from_env && ! strcmp ( k , "notes.rewriteref" )) {
/* note that a refs/ prefix is implied in the
* underlying for_each_glob_ref */
- if ( ! prefixcmp ( v , "refs/notes/" ))
+ if ( has_prefix ( v , "refs/notes/" ))
string_list_add_refs_by_glob ( c -> refs , v );
else
warning ( _ ( "Refusing to rewrite notes in %s" --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
pager.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pager.c b/pager.c
index fa19765..cd7bc43 100644
--- a/pager.c
+++ b/pager.c @@ -151,7 +151,7 @@ int decimal_width(int number)
static int pager_command_config ( const char * var , const char * value , void * data )
{
struct pager_config * c = data ;
- if ( ! prefixcmp ( var , "pager." ) && ! strcmp ( var + 6 , c -> cmd )) {
+ if ( has_prefix ( var , "pager." ) && ! strcmp ( var + 6 , c -> cmd )) {
int b = git_config_maybe_bool ( var , value );
if ( b >= 0 )
c -> want = b ; --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
shell.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/shell.c b/shell.c
index 66350b2..3bbe774 100644
--- a/shell.c
+++ b/shell.c @@ -15,7 +15,7 @@ static int do_generic_cmd(const char *me, char *arg)
setup_path ();
if ( ! arg || ! ( arg = sq_dequote ( arg )))
die ( "bad argument" );
- if ( prefixcmp ( me , "git-" ))
+ if ( ! has_prefix ( me , "git-" ))
die ( "bad command" );
my_argv [ 0 ] = me + 4 ; --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
environment.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/environment.c b/environment.c
index 378254c..827c6e8 100644
--- a/environment.c
+++ b/environment.c @@ -176,7 +176,7 @@ const char *get_git_namespace(void)
const char * strip_namespace ( const char * namespaced_ref )
{
- if ( prefixcmp ( namespaced_ref , get_git_namespace ()) != 0 )
+ if ( ! has_prefix ( namespaced_ref , get_git_namespace ()))
return NULL ;
return namespaced_ref + namespace_len ;
} --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
attr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/attr.c b/attr.c
index 0e774c6..4c11f30 100644
--- a/attr.c
+++ b/attr.c @@ -211,7 +211,7 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,
name = cp ;
namelen = strcspn ( name , blank );
if ( strlen ( ATTRIBUTE_MACRO_PREFIX ) < namelen &&
- ! prefixcmp ( name , ATTRIBUTE_MACRO_PREFIX )) {
+ has_prefix ( name , ATTRIBUTE_MACRO_PREFIX )) {
if ( ! macro_ok ) {
fprintf ( stderr , "%s not allowed: %s:%d \n " ,
name , src , lineno ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
convert.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/convert.c b/convert.c
index 11a95fc..dc5d3ed 100644
--- a/convert.c
+++ b/convert.c @@ -1121,7 +1121,7 @@ static int is_foreign_ident(const char *str)
{
int i ;
- if ( prefixcmp ( str , "$Id: " ))
+ if ( ! has_prefix ( str , "$Id: " ))
return 0 ;
for ( i = 5 ; str [ i ]; i ++ ) {
if ( isspace ( str [ i ]) && str [ i + 1 ] != '$' ) --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
connect.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/connect.c b/connect.c
index 4086861..1cb4090 100644
--- a/connect.c
+++ b/connect.c @@ -87,7 +87,7 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
if ( ! len )
break ;
- if ( len > 4 && ! prefixcmp ( buffer , "ERR " ))
+ if ( len > 4 && has_prefix ( buffer , "ERR " ))
die ( "remote error: %s" , buffer + 4 );
if ( len < 42 || get_sha1_hex ( buffer , old_sha1 ) || buffer [ 40 ] != ' ' ) --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
http-push.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/http-push.c b/http-push.c
index 69200ba..0994344 100644
--- a/http-push.c
+++ b/http-push.c @@ -771,7 +771,7 @@ static void handle_new_lock_ctx(struct xml_ctx *ctx, int tag_closed)
lock -> owner = xmalloc ( strlen ( ctx -> cdata ) + 1 );
strcpy ( lock -> owner , ctx -> cdata );
} else if ( ! strcmp ( ctx -> name , DAV_ACTIVELOCK_TIMEOUT )) {
- if ( ! prefixcmp ( ctx -> cdata , "Second-" ))
+ if ( has_prefix ( ctx -> cdata , "Second-" ))
lock -> timeout =
strtol ( ctx -> cdata + 7 , NULL , 10 );
} else if ( ! strcmp ( ctx -> name , DAV_ACTIVELOCK_TOKEN )) { @@ -1579,7 +1579,7 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)
return ;
/* If it's a symref, set the refname; otherwise try for a sha1 */
- if ( ! prefixcmp (( char * ) buffer . buf , "ref: " )) {
+ if ( has_prefix (( char * ) buffer . buf , "ref: " )) {
* symref = xmemdupz (( char * ) buffer . buf + 5 , buffer . len - 6 );
} else {
get_sha1_hex ( buffer . buf , sha1 ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
help.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/help.c b/help.c
index f068925..b41d2d5 100644
--- a/help.c
+++ b/help.c @@ -148,7 +148,7 @@ static void list_commands_in_dir(struct cmdnames *cmds,
while (( de = readdir ( dir )) != NULL ) {
int entlen ;
- if ( prefixcmp ( de -> d_name , prefix ))
+ if ( ! has_prefix ( de -> d_name , prefix ))
continue ;
strbuf_setlen ( & buf , len ); @@ -255,7 +255,7 @@ static int git_unknown_cmd_config(const char *var, const char *value, void *cb)
if ( ! strcmp ( var , "help.autocorrect" ))
autocorrect = git_config_int ( var , value );
/* Also use aliases for command lookup */
- if ( ! prefixcmp ( var , "alias." ))
+ if ( has_prefix ( var , "alias." ))
add_cmdname ( & aliases , var + 6 , strlen ( var + 6 ));
return git_default_config ( var , value , cb ); @@ -329,7 +329,7 @@ const char *help_unknown_cmd(const char *cmd)
if (( n < ARRAY_SIZE ( common_cmds )) && ! cmp ) {
/* Yes, this is one of the common commands */
n ++ ; /* use the entry from common_cmds[] */
- if ( ! prefixcmp ( candidate , cmd )) {
+ if ( has_prefix ( candidate , cmd )) {
/* Give prefix match a very good score */
main_cmds . names [ i ] -> len = 0 ;
continue ; @@ -414,7 +414,7 @@ static int append_similar_ref(const char *refname, const unsigned char *sha1,
struct similar_ref_cb * cb = ( struct similar_ref_cb * )( cb_data );
char * branch = strrchr ( refname , '/' ) + 1 ;
/* A remote branch of the same name is deemed similar */
- if ( ! prefixcmp ( refname , "refs/remotes/" ) &&
+ if ( has_prefix ( refname , "refs/remotes/" ) &&
! strcmp ( branch , cb -> base_ref ))
string_list_append ( cb -> similar_refs ,
refname + strlen ( "refs/remotes/" )); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
http-backend.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/http-backend.c b/http-backend.c
index 8c464bd..d0183b1 100644
--- a/http-backend.c
+++ b/http-backend.c @@ -226,7 +226,7 @@ static int http_config(const char *var, const char *value, void *cb)
return 0 ;
}
- if ( ! prefixcmp ( var , "http." )) {
+ if ( has_prefix ( var , "http." )) {
int i ;
for ( i = 0 ; i < ARRAY_SIZE ( rpc_service ); i ++ ) { @@ -247,7 +247,7 @@ static struct rpc_service *select_service(const char *name)
struct rpc_service * svc = NULL ;
int i ;
- if ( prefixcmp ( name , "git-" ))
+ if ( ! has_prefix ( name , "git-" ))
forbidden ( "Unsupported service: '%s'" , name );
for ( i = 0 ; i < ARRAY_SIZE ( rpc_service ); i ++ ) { --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
pkt-line.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pkt-line.c b/pkt-line.c
index 70f1950..d967727 100644
--- a/pkt-line.c
+++ b/pkt-line.c @@ -24,8 +24,8 @@ static void packet_trace(const char *buf, unsigned int len, int write)
strbuf_addf ( & out , "packet: %12s%c " ,
packet_trace_prefix , write ? '>' : '<' );
- if (( len >= 4 && ! prefixcmp ( buf , "PACK" )) ||
- ( len >= 5 && ! prefixcmp ( buf + 1 , "PACK" ))) {
+ if (( len >= 4 && has_prefix ( buf , "PACK" )) ||
+ ( len >= 5 && has_prefix ( buf + 1 , "PACK" ))) {
strbuf_addstr ( & out , "PACK ..." );
unsetenv ( trace_key );
} --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
submodule.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/submodule.c b/submodule.c
index 1905d75..21fe14e 100644
--- a/submodule.c
+++ b/submodule.c @@ -201,7 +201,7 @@ void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,
int submodule_config ( const char * var , const char * value , void * cb )
{
- if ( ! prefixcmp ( var , "submodule." ))
+ if ( has_prefix ( var , "submodule." ))
return parse_submodule_config_option ( var , value );
else if ( ! strcmp ( var , "fetch.recursesubmodules" )) {
config_fetch_recurse_submodules = parse_fetch_recurse_submodules_arg ( var , value ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
branch.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/branch.c b/branch.c
index 9e6c68e..fc3a61d 100644
--- a/branch.c
+++ b/branch.c @@ -50,7 +50,7 @@ static int should_setup_rebase(const char *origin)
void install_branch_config ( int flag , const char * local , const char * origin , const char * remote )
{
const char * shortname = remote + 11 ;
- int remote_is_branch = ! prefixcmp ( remote , "refs/heads/" );
+ int remote_is_branch = has_prefix ( remote , "refs/heads/" );
struct strbuf key = STRBUF_INIT ;
int rebasing = should_setup_rebase ( origin );
@@ -272,7 +272,7 @@ void create_branch(const char *head,
break ;
case 1 :
/* Unique completion -- good, only if it is a real branch */
- if ( prefixcmp ( real_ref , "refs/heads/" ) &&
+ if ( ! has_prefix ( real_ref , "refs/heads/" ) &&
validate_remote_tracking_branch ( real_ref )) {
if ( explicit_tracking )
die ( _ ( upstream_not_branch ), start_name ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
commit.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/commit.c b/commit.c
index de16a3c..35b276d 100644
--- a/commit.c
+++ b/commit.c @@ -559,7 +559,7 @@ static void record_author_date(struct author_date_slab *author_date,
buf ;
buf = line_end + 1 ) {
line_end = strchrnul ( buf , '\n' );
- if ( prefixcmp ( buf , "author " )) {
+ if ( ! has_prefix ( buf , "author " )) {
if ( ! line_end [ 0 ] || line_end [ 1 ] == '\n' )
return ; /* end of header */
continue ; @@ -1106,7 +1106,7 @@ int parse_signed_commit(const unsigned char *sha1,
next = next ? next + 1 : tail ;
if ( in_signature && line [ 0 ] == ' ' )
sig = line + 1 ;
- else if ( ! prefixcmp ( line , gpg_sig_header ) &&
+ else if ( has_prefix ( line , gpg_sig_header ) &&
line [ gpg_sig_header_len ] == ' ' )
sig = line + gpg_sig_header_len + 1 ;
if ( sig ) { @@ -1186,7 +1186,7 @@ static void parse_gpg_output(struct signature_check *sigc)
for ( i = 0 ; i < ARRAY_SIZE ( sigcheck_gpg_status ); i ++ ) {
const char * found , * next ;
- if ( ! prefixcmp ( buf , sigcheck_gpg_status [ i ]. check + 1 )) {
+ if ( has_prefix ( buf , sigcheck_gpg_status [ i ]. check + 1 )) {
/* At the very beginning of the buffer */
found = buf + strlen ( sigcheck_gpg_status [ i ]. check + 1 );
} else { --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
notes.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/notes.c b/notes.c
index b69c0b8..e23d38a 100644
--- a/notes.c
+++ b/notes.c @@ -1243,9 +1243,9 @@ static void format_note(struct notes_tree *t, const unsigned char *object_sha1,
if ( ! ref || ! strcmp ( ref , GIT_NOTES_DEFAULT_REF )) {
strbuf_addstr ( sb , " \n Notes: \n " );
} else {
- if ( ! prefixcmp ( ref , "refs/" ))
+ if ( has_prefix ( ref , "refs/" ))
ref += 5 ;
- if ( ! prefixcmp ( ref , "notes/" ))
+ if ( has_prefix ( ref , "notes/" ))
ref += 6 ;
strbuf_addf ( sb , " \n Notes (%s): \n " , ref );
} @@ -1293,9 +1293,9 @@ int copy_note(struct notes_tree *t,
void expand_notes_ref ( struct strbuf * sb )
{
- if ( ! prefixcmp ( sb -> buf , "refs/notes/" ))
+ if ( has_prefix ( sb -> buf , "refs/notes/" ))
return ; /* we're happy */
- else if ( ! prefixcmp ( sb -> buf , "notes/" ))
+ else if ( has_prefix ( sb -> buf , "notes/" ))
strbuf_insert ( sb , 0 , "refs/" , 5 );
else
strbuf_insert ( sb , 0 , "refs/notes/" , 11 ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
refs.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/refs.c b/refs.c
index 3710748..3dc38df 100644
--- a/refs.c
+++ b/refs.c @@ -637,7 +637,7 @@ static int do_one_ref(struct ref_entry *entry, void *cb_data)
struct ref_entry * old_current_ref ;
int retval ;
- if ( prefixcmp ( entry -> name , data -> base ))
+ if ( ! has_prefix ( entry -> name , data -> base ))
return 0 ;
if ( ! ( data -> flags & DO_FOR_EACH_INCLUDE_BROKEN ) && @@ -1049,7 +1049,7 @@ static void read_packed_refs(FILE *f, struct ref_dir *dir)
if ( refname ) {
last = create_ref_entry ( refname , sha1 , REF_ISPACKED , 1 );
if ( peeled == PEELED_FULLY ||
- ( peeled == PEELED_TAGS && ! prefixcmp ( refname , "refs/tags/" )))
+ ( peeled == PEELED_TAGS && has_prefix ( refname , "refs/tags/" )))
last -> flag |= REF_KNOWS_PEELED ;
add_ref ( dir , last );
continue ; @@ -1383,7 +1383,7 @@ const char *resolve_ref_unsafe(const char *refname, unsigned char *sha1, int rea
return NULL ;
}
buffer [ len ] = 0 ;
- if ( ! prefixcmp ( buffer , "refs/" ) &&
+ if ( has_prefix ( buffer , "refs/" ) &&
! check_refname_format ( buffer , 0 )) {
strcpy ( refname_buffer , buffer );
refname = refname_buffer ; @@ -1422,7 +1422,7 @@ const char *resolve_ref_unsafe(const char *refname, unsigned char *sha1, int rea
/*
* Is it a symbolic ref ?
*/
- if ( prefixcmp ( buffer , "ref:" )) {
+ if ( ! has_prefix ( buffer , "ref:" )) {
/*
* Please note that FETCH_HEAD has a second
* line containing other data . @@ -1844,7 +1844,7 @@ int for_each_glob_ref_in(each_ref_fn fn, const char *pattern,
struct ref_filter filter ;
int ret ;
- if ( ! prefix && prefixcmp ( pattern , "refs/" ))
+ if ( ! prefix && ! has_prefix ( pattern , "refs/" ))
strbuf_addstr ( & real_pattern , "refs/" );
else if ( prefix )
strbuf_addstr ( & real_pattern , prefix ); @@ -1881,9 +1881,9 @@ int for_each_rawref(each_ref_fn fn, void *cb_data)
const char * prettify_refname ( const char * name )
{
return name + (
- ! prefixcmp ( name , "refs/heads/" ) ? 11 :
- ! prefixcmp ( name , "refs/tags/" ) ? 10 :
- ! prefixcmp ( name , "refs/remotes/" ) ? 13 :
+ has_prefix ( name , "refs/heads/" ) ? 11 :
+ has_prefix ( name , "refs/tags/" ) ? 10 :
+ has_prefix ( name , "refs/remotes/" ) ? 13 :
0 );
}
@@ -2251,7 +2251,7 @@ static int pack_if_possible_fn(struct ref_entry *entry, void *cb_data)
struct pack_refs_cb_data * cb = cb_data ;
enum peel_status peel_status ;
struct ref_entry * packed_entry ;
- int is_tag_ref = ! prefixcmp ( entry -> name , "refs/tags/" );
+ int is_tag_ref = has_prefix ( entry -> name , "refs/tags/" );
/* ALWAYS pack tags */
if ( ! ( cb -> flags & PACK_REFS_ALL ) && ! is_tag_ref ) @@ -2686,9 +2686,9 @@ int log_ref_setup(const char *refname, char *logfile, int bufsize)
git_snpath ( logfile , bufsize , "logs/%s" , refname );
if ( log_all_ref_updates &&
- ( ! prefixcmp ( refname , "refs/heads/" ) ||
- ! prefixcmp ( refname , "refs/remotes/" ) ||
- ! prefixcmp ( refname , "refs/notes/" ) ||
+ ( has_prefix ( refname , "refs/heads/" ) ||
+ has_prefix ( refname , "refs/remotes/" ) ||
+ has_prefix ( refname , "refs/notes/" ) ||
! strcmp ( refname , "HEAD" ))) {
if ( safe_create_leading_directories ( logfile ) < 0 )
return error ( "unable to create directory for %s" , @@ -2758,7 +2758,7 @@ static int log_ref_write(const char *refname, const unsigned char *old_sha1,
static int is_branch ( const char * refname )
{
- return ! strcmp ( refname , "HEAD" ) || ! prefixcmp ( refname , "refs/heads/" );
+ return ! strcmp ( refname , "HEAD" ) || has_prefix ( refname , "refs/heads/" );
}
int write_ref_sha1 ( struct ref_lock * lock , @@ -3457,7 +3457,7 @@ int parse_hide_refs_config(const char *var, const char *value, const char *secti
{
if ( ! strcmp ( "transfer.hiderefs" , var ) ||
/* NEEDSWORK: use parse_config_key() once both are merged */
- ( ! prefixcmp ( var , section ) && var [ strlen ( section )] == '.' &&
+ ( has_prefix ( var , section ) && var [ strlen ( section )] == '.' &&
! strcmp ( var + strlen ( section ), ".hiderefs" ))) {
char * ref ;
int len ; @@ -3485,7 +3485,7 @@ int ref_is_hidden(const char *refname)
return 0 ;
for_each_string_list_item ( item , hide_refs ) {
int len ;
- if ( prefixcmp ( refname , item -> string ))
+ if ( ! has_prefix ( refname , item -> string ))
continue ;
len = strlen ( item -> string );
if ( ! refname [ len ] || refname [ len ] == '/' ) --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
upload-pack.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/upload-pack.c b/upload-pack.c
index a6c54e0..ce4ae75 100644
--- a/upload-pack.c
+++ b/upload-pack.c @@ -394,7 +394,7 @@ static int get_common_commits(void)
got_other = 0 ;
continue ;
}
- if ( ! prefixcmp ( line , "have " )) {
+ if ( has_prefix ( line , "have " )) {
switch ( got_sha1 ( line + 5 , sha1 )) {
case -1 : /* they have what we do not */
got_other = 1 ; @@ -540,7 +540,7 @@ static void receive_needs(void)
if ( ! line )
break ;
- if ( ! prefixcmp ( line , "shallow " )) {
+ if ( has_prefix ( line , "shallow " )) {
unsigned char sha1 [ 20 ];
struct object * object ;
if ( get_sha1_hex ( line + 8 , sha1 )) @@ -556,14 +556,14 @@ static void receive_needs(void)
}
continue ;
}
- if ( ! prefixcmp ( line , "deepen " )) {
+ if ( has_prefix ( line , "deepen " )) {
char * end ;
depth = strtol ( line + 7 , & end , 0 );
if ( end == line + 7 || depth <= 0 )
die ( "Invalid deepen: %s" , line );
continue ;
}
- if ( prefixcmp ( line , "want " ) ||
+ if ( ! has_prefix ( line , "want " ) ||
get_sha1_hex ( line + 5 , sha1_buf ))
die ( "git upload-pack: protocol error, "
"expected to get sha, not '%s'" , line ); @@ -777,7 +777,7 @@ int main(int argc, char **argv)
strict = 1 ;
continue ;
}
- if ( ! prefixcmp ( arg , "--timeout=" )) {
+ if ( has_prefix ( arg , "--timeout=" )) {
timeout = atoi ( arg + 10 );
daemon_mode = 1 ;
continue ; --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
test-line-buffer.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/test-line-buffer.c b/test-line-buffer.c
index ef1d7ba..ed0d681 100644
--- a/test-line-buffer.c
+++ b/test-line-buffer.c @@ -19,7 +19,7 @@ static void handle_command(const char *command, const char *arg, struct line_buf
{
switch ( * command ) {
case 'b' :
- if ( ! prefixcmp ( command , "binary " )) {
+ if ( has_prefix ( command , "binary " )) {
struct strbuf sb = STRBUF_INIT ;
strbuf_addch ( & sb , '>' );
buffer_read_binary ( buf , & sb , strtouint32 ( arg )); @@ -28,12 +28,12 @@ static void handle_command(const char *command, const char *arg, struct line_buf
return ;
}
case 'c' :
- if ( ! prefixcmp ( command , "copy " )) {
+ if ( has_prefix ( command , "copy " )) {
buffer_copy_bytes ( buf , strtouint32 ( arg ));
return ;
}
case 's' :
- if ( ! prefixcmp ( command , "skip " )) {
+ if ( has_prefix ( command , "skip " )) {
buffer_skip_bytes ( buf , strtouint32 ( arg ));
return ;
} --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
wt-status.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index b4e44ba..47806d1 100644
--- a/wt-status.c
+++ b/wt-status.c @@ -803,7 +803,7 @@ static void wt_status_print_tracking(struct wt_status *s)
int i ;
assert ( s -> branch && ! s -> is_initial );
- if ( prefixcmp ( s -> branch , "refs/heads/" ))
+ if ( ! has_prefix ( s -> branch , "refs/heads/" ))
return ;
branch = branch_get ( s -> branch + 11 );
if ( ! format_tracking_info ( branch , & sb )) @@ -1062,9 +1062,9 @@ static char *read_and_strip_branch(const char *path)
strbuf_setlen ( & sb , sb . len - 1 );
if ( ! sb . len )
goto got_nothing ;
- if ( ! prefixcmp ( sb . buf , "refs/heads/" ))
+ if ( has_prefix ( sb . buf , "refs/heads/" ))
strbuf_remove ( & sb , 0 , strlen ( "refs/heads/" ));
- else if ( ! prefixcmp ( sb . buf , "refs/" ))
+ else if ( has_prefix ( sb . buf , "refs/" ))
;
else if ( ! get_sha1_hex ( sb . buf , sha1 )) {
const char * abbrev ; @@ -1094,7 +1094,7 @@ static int grab_1st_switch(unsigned char *osha1, unsigned char *nsha1,
struct grab_1st_switch_cbdata * cb = cb_data ;
const char * target = NULL , * end ;
- if ( prefixcmp ( message , "checkout: moving from " ))
+ if ( ! has_prefix ( message , "checkout: moving from " ))
return 0 ;
message += strlen ( "checkout: moving from " );
target = strstr ( message , " to " ); @@ -1129,9 +1129,9 @@ static void wt_status_get_detached_from(struct wt_status_state *state)
(( commit = lookup_commit_reference_gently ( sha1 , 1 )) != NULL &&
! hashcmp ( cb . nsha1 , commit -> object . sha1 )))) {
int ofs ;
- if ( ! prefixcmp ( ref , "refs/tags/" ))
+ if ( has_prefix ( ref , "refs/tags/" ))
ofs = strlen ( "refs/tags/" );
- else if ( ! prefixcmp ( ref , "refs/remotes/" ))
+ else if ( has_prefix ( ref , "refs/remotes/" ))
ofs = strlen ( "refs/remotes/" );
else
ofs = 0 ; @@ -1220,7 +1220,7 @@ void wt_status_print(struct wt_status *s)
if ( s -> branch ) {
const char * on_what = _ ( "On branch " );
const char * branch_name = s -> branch ;
- if ( ! prefixcmp ( branch_name , "refs/heads/" ))
+ if ( has_prefix ( branch_name , "refs/heads/" ))
branch_name += 11 ;
else if ( ! strcmp ( branch_name , "HEAD" )) {
branch_status_color = color ( WT_STATUS_NOBRANCH , s ); @@ -1421,7 +1421,7 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
return ;
branch_name = s -> branch ;
- if ( ! prefixcmp ( branch_name , "refs/heads/" ))
+ if ( has_prefix ( branch_name , "refs/heads/" ))
branch_name += 11 ;
else if ( ! strcmp ( branch_name , "HEAD" )) {
branch_name = _ ( "HEAD (no branch)" ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
sha1_name.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/sha1_name.c b/sha1_name.c
index 0e5fe7f..3224a39 100644
--- a/sha1_name.c
+++ b/sha1_name.c @@ -547,7 +547,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
if ( read_ref_at ( real_ref , at_time , nth , sha1 , NULL ,
& co_time , & co_tz , & co_cnt )) {
if ( ! len ) {
- if ( ! prefixcmp ( real_ref , "refs/heads/" )) {
+ if ( has_prefix ( real_ref , "refs/heads/" )) {
str = real_ref + 11 ;
len = strlen ( real_ref + 11 );
} else { @@ -677,15 +677,15 @@ static int peel_onion(const char *name, int len, unsigned char *sha1)
return -1 ;
sp ++ ; /* beginning of type name, or closing brace for empty */
- if ( ! prefixcmp ( sp , "commit}" ))
+ if ( has_prefix ( sp , "commit}" ))
expected_type = OBJ_COMMIT ;
- else if ( ! prefixcmp ( sp , "tag}" ))
+ else if ( has_prefix ( sp , "tag}" ))
expected_type = OBJ_TAG ;
- else if ( ! prefixcmp ( sp , "tree}" ))
+ else if ( has_prefix ( sp , "tree}" ))
expected_type = OBJ_TREE ;
- else if ( ! prefixcmp ( sp , "blob}" ))
+ else if ( has_prefix ( sp , "blob}" ))
expected_type = OBJ_BLOB ;
- else if ( ! prefixcmp ( sp , "object}" ))
+ else if ( has_prefix ( sp , "object}" ))
expected_type = OBJ_ANY ;
else if ( sp [ 0 ] == '}' )
expected_type = OBJ_NONE ; @@ -912,7 +912,7 @@ static int grab_nth_branch_switch(unsigned char *osha1, unsigned char *nsha1,
const char * match = NULL , * target = NULL ;
size_t len ;
- if ( ! prefixcmp ( message , "checkout: moving from " )) {
+ if ( has_prefix ( message , "checkout: moving from " )) {
match = message + strlen ( "checkout: moving from " );
target = strstr ( match , " to " );
} @@ -1305,7 +1305,7 @@ static void diagnose_invalid_index_path(int stage,
static char * resolve_relative_path ( const char * rel )
{
- if ( prefixcmp ( rel , "./" ) && prefixcmp ( rel , "../" ))
+ if ( ! has_prefix ( rel , "./" ) && ! has_prefix ( rel , "../" ))
return NULL ;
if ( ! startup_info ) --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
config.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/config.c b/config.c
index e1d66a1..8d5d70c 100644
--- a/config.c
+++ b/config.c @@ -969,25 +969,25 @@ static int git_default_mailmap_config(const char *var, const char *value)
int git_default_config ( const char * var , const char * value , void * dummy )
{
- if ( ! prefixcmp ( var , "core." ))
+ if ( has_prefix ( var , "core." ))
return git_default_core_config ( var , value );
- if ( ! prefixcmp ( var , "user." ))
+ if ( has_prefix ( var , "user." ))
return git_ident_config ( var , value , dummy );
- if ( ! prefixcmp ( var , "i18n." ))
+ if ( has_prefix ( var , "i18n." ))
return git_default_i18n_config ( var , value );
- if ( ! prefixcmp ( var , "branch." ))
+ if ( has_prefix ( var , "branch." ))
return git_default_branch_config ( var , value );
- if ( ! prefixcmp ( var , "push." ))
+ if ( has_prefix ( var , "push." ))
return git_default_push_config ( var , value );
- if ( ! prefixcmp ( var , "mailmap." ))
+ if ( has_prefix ( var , "mailmap." ))
return git_default_mailmap_config ( var , value );
- if ( ! prefixcmp ( var , "advice." ))
+ if ( has_prefix ( var , "advice." ))
return git_default_advice_config ( var , value );
if ( ! strcmp ( var , "pager.color" ) || ! strcmp ( var , "color.pager" )) { @@ -1872,7 +1872,7 @@ int parse_config_key(const char *var,
const char * dot ;
/* Does it start with "section." ? */
- if ( prefixcmp ( var , section ) || var [ section_len ] != '.' )
+ if ( ! has_prefix ( var , section ) || var [ section_len ] != '.' )
return -1 ;
/* --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
transport-helper.c | 16 ++++++++--------
transport.c | 28 ++++++++++++++--------------
2 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/transport-helper.c b/transport-helper.c
index b32e2d6..bf8d7a0 100644
--- a/transport-helper.c
+++ b/transport-helper.c @@ -190,7 +190,7 @@ static struct child_process *get_helper(struct transport *transport)
data -> export = 1 ;
else if ( ! strcmp ( capname , "check-connectivity" ))
data -> check_connectivity = 1 ;
- else if ( ! data -> refspecs && ! prefixcmp ( capname , "refspec " )) {
+ else if ( ! data -> refspecs && has_prefix ( capname , "refspec " )) {
ALLOC_GROW ( refspecs ,
refspec_nr + 1 ,
refspec_alloc ); @@ -199,17 +199,17 @@ static struct child_process *get_helper(struct transport *transport)
data -> connect = 1 ;
} else if ( ! strcmp ( capname , "signed-tags" )) {
data -> signed_tags = 1 ;
- } else if ( ! prefixcmp ( capname , "export-marks " )) {
+ } else if ( has_prefix ( capname , "export-marks " )) {
struct strbuf arg = STRBUF_INIT ;
strbuf_addstr ( & arg , "--export-marks=" );
strbuf_addstr ( & arg , capname + strlen ( "export-marks " ));
data -> export_marks = strbuf_detach ( & arg , NULL );
- } else if ( ! prefixcmp ( capname , "import-marks" )) {
+ } else if ( has_prefix ( capname , "import-marks" )) {
struct strbuf arg = STRBUF_INIT ;
strbuf_addstr ( & arg , "--import-marks=" );
strbuf_addstr ( & arg , capname + strlen ( "import-marks " ));
data -> import_marks = strbuf_detach ( & arg , NULL );
- } else if ( ! prefixcmp ( capname , "no-private-update" )) {
+ } else if ( has_prefix ( capname , "no-private-update" )) {
data -> no_private_update = 1 ;
} else if ( mandatory ) {
die ( "Unknown mandatory capability %s. This remote " @@ -310,7 +310,7 @@ static int set_helper_option(struct transport *transport,
if ( ! strcmp ( buf . buf , "ok" ))
ret = 0 ;
- else if ( ! prefixcmp ( buf . buf , "error" )) {
+ else if ( has_prefix ( buf . buf , "error" )) {
ret = -1 ;
} else if ( ! strcmp ( buf . buf , "unsupported" ))
ret = 1 ; @@ -374,7 +374,7 @@ static int fetch_with_fetch(struct transport *transport,
while ( 1 ) {
recvline ( data , & buf );
- if ( ! prefixcmp ( buf . buf , "lock " )) {
+ if ( has_prefix ( buf . buf , "lock " )) {
const char * name = buf . buf + 5 ;
if ( transport -> pack_lockfile )
warning ( "%s also locked %s" , data -> name , name ); @@ -645,10 +645,10 @@ static int push_update_ref_status(struct strbuf *buf,
char * refname , * msg ;
int status ;
- if ( ! prefixcmp ( buf -> buf , "ok " )) {
+ if ( has_prefix ( buf -> buf , "ok " )) {
status = REF_STATUS_OK ;
refname = buf -> buf + 3 ;
- } else if ( ! prefixcmp ( buf -> buf , "error " )) {
+ } else if ( has_prefix ( buf -> buf , "error " )) {
status = REF_STATUS_REMOTE_REJECT ;
refname = buf -> buf + 6 ;
} else diff --git a/transport.c b/transport.c
index 7202b77..24b781c 100644
--- a/transport.c
+++ b/transport.c @@ -169,13 +169,13 @@ static void set_upstreams(struct transport *transport, struct ref *refs,
remotename = ref -> name ;
tmp = resolve_ref_unsafe ( localname , sha , 1 , & flag );
if ( tmp && flag & REF_ISSYMREF &&
- ! prefixcmp ( tmp , "refs/heads/" ))
+ has_prefix ( tmp , "refs/heads/" ))
localname = tmp ;
/* Both source and destination must be local branches. */
- if ( ! localname || prefixcmp ( localname , "refs/heads/" ))
+ if ( ! localname || ! has_prefix ( localname , "refs/heads/" ))
continue ;
- if ( ! remotename || prefixcmp ( remotename , "refs/heads/" ))
+ if ( ! remotename || ! has_prefix ( remotename , "refs/heads/" ))
continue ;
if ( ! pretend ) @@ -191,7 +191,7 @@ static void set_upstreams(struct transport *transport, struct ref *refs,
static const char * rsync_url ( const char * url )
{
- return prefixcmp ( url , "rsync://" ) ? skip_prefix ( url , "rsync:" ) : url ;
+ return ! has_prefix ( url , "rsync://" ) ? skip_prefix ( url , "rsync:" ) : url ;
}
static struct ref * get_refs_via_rsync ( struct transport * transport , int for_push ) @@ -296,8 +296,8 @@ static int write_one_ref(const char *name, const unsigned char *sha1,
FILE * f ;
/* when called via for_each_ref(), flags is non-zero */
- if ( flags && prefixcmp ( name , "refs/heads/" ) &&
- prefixcmp ( name , "refs/tags/" ))
+ if ( flags && ! has_prefix ( name , "refs/heads/" ) &&
+ ! has_prefix ( name , "refs/tags/" ))
return 0 ;
strbuf_addstr ( buf , name ); @@ -652,7 +652,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)
print_ref_status ( '-' , "[deleted]" , ref , NULL , NULL , porcelain );
else if ( is_null_sha1 ( ref -> old_sha1 ))
print_ref_status ( '*' ,
- ( ! prefixcmp ( ref -> name , "refs/tags/" ) ? "[new tag]" :
+ ( has_prefix ( ref -> name , "refs/tags/" ) ? "[new tag]" :
"[new branch]" ),
ref , ref -> peer_ref , NULL , porcelain );
else { @@ -930,13 +930,13 @@ struct transport *transport_get(struct remote *remote, const char *url)
while ( is_urlschemechar ( p == url , * p ))
p ++ ;
- if ( ! prefixcmp ( p , "::" ))
+ if ( has_prefix ( p , "::" ))
helper = xstrndup ( url , p - url );
}
if ( helper ) {
transport_helper_init ( ret , helper );
- } else if ( ! prefixcmp ( url , "rsync:" )) {
+ } else if ( has_prefix ( url , "rsync:" )) {
ret -> get_refs_list = get_refs_via_rsync ;
ret -> fetch = fetch_objs_via_rsync ;
ret -> push = rsync_transport_push ; @@ -949,11 +949,11 @@ struct transport *transport_get(struct remote *remote, const char *url)
ret -> disconnect = close_bundle ;
ret -> smart_options = NULL ;
} else if ( ! is_url ( url )
- || ! prefixcmp ( url , "file://" )
- || ! prefixcmp ( url , "git://" )
- || ! prefixcmp ( url , "ssh://" )
- || ! prefixcmp ( url , "git+ssh://" )
- || ! prefixcmp ( url , "ssh+git://" )) {
+ || has_prefix ( url , "file://" )
+ || has_prefix ( url , "git://" )
+ || has_prefix ( url , "ssh://" )
+ || has_prefix ( url , "git+ssh://" )
+ || has_prefix ( url , "ssh+git://" )) {
/* These are builtin smart transports. */
struct git_transport_data * data = xcalloc ( 1 , sizeof ( * data ));
ret -> data = data ; --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
pretty.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/pretty.c b/pretty.c
index b4e32b7..961241a 100644
--- a/pretty.c
+++ b/pretty.c @@ -40,7 +40,7 @@ static int git_pretty_formats_config(const char *var, const char *value, void *c
const char * fmt ;
int i ;
- if ( prefixcmp ( var , "pretty." ))
+ if ( ! has_prefix ( var , "pretty." ))
return 0 ;
name = var + strlen ( "pretty." ); @@ -67,7 +67,7 @@ static int git_pretty_formats_config(const char *var, const char *value, void *c
commit_format -> name = xstrdup ( name );
commit_format -> format = CMIT_FMT_USERFORMAT ;
git_config_string ( & fmt , var , value );
- if ( ! prefixcmp ( fmt , "format:" ) || ! prefixcmp ( fmt , "tformat:" )) {
+ if ( has_prefix ( fmt , "format:" ) || has_prefix ( fmt , "tformat:" )) {
commit_format -> is_tformat = fmt [ 0 ] == 't' ;
fmt = strchr ( fmt , ':' ) + 1 ;
} else if ( strchr ( fmt , '%' )) @@ -115,7 +115,7 @@ static struct cmt_fmt_map *find_commit_format_recursive(const char *sought,
for ( i = 0 ; i < commit_formats_len ; i ++ ) {
size_t match_len ;
- if ( prefixcmp ( commit_formats [ i ]. name , sought ))
+ if ( ! has_prefix ( commit_formats [ i ]. name , sought ))
continue ;
match_len = strlen ( commit_formats [ i ]. name ); @@ -151,7 +151,7 @@ void get_commit_format(const char *arg, struct rev_info *rev)
rev -> commit_format = CMIT_FMT_DEFAULT ;
return ;
}
- if ( ! prefixcmp ( arg , "format:" ) || ! prefixcmp ( arg , "tformat:" )) {
+ if ( has_prefix ( arg , "format:" ) || has_prefix ( arg , "tformat:" )) {
save_user_format ( rev , strchr ( arg , ':' ) + 1 , arg [ 0 ] == 't' );
return ;
} @@ -840,10 +840,10 @@ static void parse_commit_header(struct format_commit_context *context)
if ( i == eol ) {
break ;
- } else if ( ! prefixcmp ( msg + i , "author " )) {
+ } else if ( has_prefix ( msg + i , "author " )) {
context -> author . off = i + 7 ;
context -> author . len = eol - i - 7 ;
- } else if ( ! prefixcmp ( msg + i , "committer " )) {
+ } else if ( has_prefix ( msg + i , "committer " )) {
context -> committer . off = i + 10 ;
context -> committer . len = eol - i - 10 ;
} @@ -983,7 +983,7 @@ static size_t parse_color(struct strbuf *sb, /* in UTF-8 */
if ( ! end )
return 0 ;
- if ( ! prefixcmp ( begin , "auto," )) {
+ if ( has_prefix ( begin , "auto," )) {
if ( ! want_color ( c -> pretty_ctx -> color ))
return end - placeholder + 1 ;
begin += 5 ; @@ -994,16 +994,16 @@ static size_t parse_color(struct strbuf *sb, /* in UTF-8 */
strbuf_addstr ( sb , color );
return end - placeholder + 1 ;
}
- if ( ! prefixcmp ( placeholder + 1 , "red" )) {
+ if ( has_prefix ( placeholder + 1 , "red" )) {
strbuf_addstr ( sb , GIT_COLOR_RED );
return 4 ;
- } else if ( ! prefixcmp ( placeholder + 1 , "green" )) {
+ } else if ( has_prefix ( placeholder + 1 , "green" )) {
strbuf_addstr ( sb , GIT_COLOR_GREEN );
return 6 ;
- } else if ( ! prefixcmp ( placeholder + 1 , "blue" )) {
+ } else if ( has_prefix ( placeholder + 1 , "blue" )) {
strbuf_addstr ( sb , GIT_COLOR_BLUE );
return 5 ;
- } else if ( ! prefixcmp ( placeholder + 1 , "reset" )) {
+ } else if ( has_prefix ( placeholder + 1 , "reset" )) {
strbuf_addstr ( sb , GIT_COLOR_RESET );
return 6 ;
} else @@ -1060,11 +1060,11 @@ static size_t parse_padding_placeholder(struct strbuf *sb,
end = strchr ( start , ')' );
if ( ! end || end == start )
return 0 ;
- if ( ! prefixcmp ( start , "trunc)" ))
+ if ( has_prefix ( start , "trunc)" ))
c -> truncate = trunc_right ;
- else if ( ! prefixcmp ( start , "ltrunc)" ))
+ else if ( has_prefix ( start , "ltrunc)" ))
c -> truncate = trunc_left ;
- else if ( ! prefixcmp ( start , "mtrunc)" ))
+ else if ( has_prefix ( start , "mtrunc)" ))
c -> truncate = trunc_middle ;
else
return 0 ; @@ -1089,7 +1089,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
/* these are independent of the commit */
switch ( placeholder [ 0 ]) {
case 'C' :
- if ( ! prefixcmp ( placeholder + 1 , "(auto)" )) {
+ if ( has_prefix ( placeholder + 1 , "(auto)" )) {
c -> auto_color = 1 ;
return 7 ; /* consumed 7 bytes, "C(auto)" */
} else { @@ -1556,7 +1556,7 @@ static void pp_header(struct pretty_print_context *pp,
continue ;
}
- if ( ! prefixcmp ( line , "parent " )) {
+ if ( has_prefix ( line , "parent " )) {
if ( linelen != 48 )
die ( "bad parent line in commit" );
continue ; @@ -1580,11 +1580,11 @@ static void pp_header(struct pretty_print_context *pp,
* FULL shows both authors but not dates .
* FULLER shows both authors and dates .
*/
- if ( ! prefixcmp ( line , "author " )) {
+ if ( has_prefix ( line , "author " )) {
strbuf_grow ( sb , linelen + 80 );
pp_user_info ( pp , "Author" , sb , line + 7 , encoding );
}
- if ( ! prefixcmp ( line , "committer " ) &&
+ if ( has_prefix ( line , "committer " ) &&
( pp -> fmt == CMIT_FMT_FULL || pp -> fmt == CMIT_FMT_FULLER )) {
strbuf_grow ( sb , linelen + 80 );
pp_user_info ( pp , "Commit" , sb , line + 10 , encoding ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
fast-import.c | 80 +++++++++++++++++++++++++++++------------------------------
1 file changed, 40 insertions(+), 40 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index f4d9969..14f69a1 100644
--- a/fast-import.c
+++ b/fast-import.c @@ -1877,8 +1877,8 @@ static int read_next_command(void)
return EOF ;
if ( ! seen_data_command
- && prefixcmp ( command_buf . buf , "feature " )
- && prefixcmp ( command_buf . buf , "option " )) {
+ && ! has_prefix ( command_buf . buf , "feature " )
+ && ! has_prefix ( command_buf . buf , "option " )) {
parse_argv ();
}
@@ -1898,7 +1898,7 @@ static int read_next_command(void)
rc -> prev -> next = rc ;
cmd_tail = rc ;
}
- if ( ! prefixcmp ( command_buf . buf , "cat-blob " )) {
+ if ( has_prefix ( command_buf . buf , "cat-blob " )) {
parse_cat_blob ();
continue ;
} @@ -1917,7 +1917,7 @@ static void skip_optional_lf(void)
static void parse_mark ( void )
{
- if ( ! prefixcmp ( command_buf . buf , "mark :" )) {
+ if ( has_prefix ( command_buf . buf , "mark :" )) {
next_mark = strtoumax ( command_buf . buf + 6 , NULL , 10 );
read_next_command ();
} @@ -1929,10 +1929,10 @@ static int parse_data(struct strbuf *sb, uintmax_t limit, uintmax_t *len_res)
{
strbuf_reset ( sb );
- if ( prefixcmp ( command_buf . buf , "data " ))
+ if ( ! has_prefix ( command_buf . buf , "data " ))
die ( "Expected 'data n' command, found: %s" , command_buf . buf );
- if ( ! prefixcmp ( command_buf . buf + 5 , "<<" )) {
+ if ( has_prefix ( command_buf . buf + 5 , "<<" )) {
char * term = xstrdup ( command_buf . buf + 5 + 2 );
size_t term_len = command_buf . len - 5 - 2 ;
@@ -2306,7 +2306,7 @@ static void file_change_m(struct branch *b)
if ( * p == ':' ) {
oe = find_mark ( parse_mark_ref_space ( & p ));
hashcpy ( sha1 , oe -> idx . sha1 );
- } else if ( ! prefixcmp ( p , "inline " )) {
+ } else if ( has_prefix ( p , "inline " )) {
inline_data = 1 ;
oe = NULL ; /* not used with inline_data, but makes gcc happy */
p += strlen ( "inline" ); /* advance to space */ @@ -2479,7 +2479,7 @@ static void note_change_n(struct branch *b, unsigned char *old_fanout)
if ( * p == ':' ) {
oe = find_mark ( parse_mark_ref_space ( & p ));
hashcpy ( sha1 , oe -> idx . sha1 );
- } else if ( ! prefixcmp ( p , "inline " )) {
+ } else if ( has_prefix ( p , "inline " )) {
inline_data = 1 ;
oe = NULL ; /* not used with inline_data, but makes gcc happy */
p += strlen ( "inline" ); /* advance to space */ @@ -2590,7 +2590,7 @@ static int parse_from(struct branch *b)
const char * from ;
struct branch * s ;
- if ( prefixcmp ( command_buf . buf , "from " ))
+ if ( ! has_prefix ( command_buf . buf , "from " ))
return 0 ;
if ( b -> branch_tree . tree ) { @@ -2636,7 +2636,7 @@ static struct hash_list *parse_merge(unsigned int *count)
struct branch * s ;
* count = 0 ;
- while ( ! prefixcmp ( command_buf . buf , "merge " )) {
+ while ( has_prefix ( command_buf . buf , "merge " )) {
from = strchr ( command_buf . buf , ' ' ) + 1 ;
n = xmalloc ( sizeof ( * n ));
s = lookup_branch ( from ); @@ -2687,11 +2687,11 @@ static void parse_new_commit(void)
read_next_command ();
parse_mark ();
- if ( ! prefixcmp ( command_buf . buf , "author " )) {
+ if ( has_prefix ( command_buf . buf , "author " )) {
author = parse_ident ( command_buf . buf + 7 );
read_next_command ();
}
- if ( ! prefixcmp ( command_buf . buf , "committer " )) {
+ if ( has_prefix ( command_buf . buf , "committer " )) {
committer = parse_ident ( command_buf . buf + 10 );
read_next_command ();
} @@ -2712,19 +2712,19 @@ static void parse_new_commit(void)
/* file_change* */
while ( command_buf . len > 0 ) {
- if ( ! prefixcmp ( command_buf . buf , "M " ))
+ if ( has_prefix ( command_buf . buf , "M " ))
file_change_m ( b );
- else if ( ! prefixcmp ( command_buf . buf , "D " ))
+ else if ( has_prefix ( command_buf . buf , "D " ))
file_change_d ( b );
- else if ( ! prefixcmp ( command_buf . buf , "R " ))
+ else if ( has_prefix ( command_buf . buf , "R " ))
file_change_cr ( b , 1 );
- else if ( ! prefixcmp ( command_buf . buf , "C " ))
+ else if ( has_prefix ( command_buf . buf , "C " ))
file_change_cr ( b , 0 );
- else if ( ! prefixcmp ( command_buf . buf , "N " ))
+ else if ( has_prefix ( command_buf . buf , "N " ))
note_change_n ( b , & prev_fanout );
else if ( ! strcmp ( "deleteall" , command_buf . buf ))
file_change_deleteall ( b );
- else if ( ! prefixcmp ( command_buf . buf , "ls " ))
+ else if ( has_prefix ( command_buf . buf , "ls " ))
parse_ls ( b );
else {
unread_command_buf = 1 ; @@ -2793,7 +2793,7 @@ static void parse_new_tag(void)
read_next_command ();
/* from ... */
- if ( prefixcmp ( command_buf . buf , "from " ))
+ if ( ! has_prefix ( command_buf . buf , "from " ))
die ( "Expected from command, got %s" , command_buf . buf );
from = strchr ( command_buf . buf , ' ' ) + 1 ;
s = lookup_branch ( from ); @@ -2821,7 +2821,7 @@ static void parse_new_tag(void)
read_next_command ();
/* tagger ... */
- if ( ! prefixcmp ( command_buf . buf , "tagger " )) {
+ if ( has_prefix ( command_buf . buf , "tagger " )) {
tagger = parse_ident ( command_buf . buf + 7 );
read_next_command ();
} else @@ -3209,7 +3209,7 @@ static void option_export_pack_edges(const char *edges)
static int parse_one_option ( const char * option )
{
- if ( ! prefixcmp ( option , "max-pack-size=" )) {
+ if ( has_prefix ( option , "max-pack-size=" )) {
unsigned long v ;
if ( ! git_parse_ulong ( option + 14 , & v ))
return 0 ; @@ -3221,20 +3221,20 @@ static int parse_one_option(const char *option)
v = 1024 * 1024 ;
}
max_packsize = v ;
- } else if ( ! prefixcmp ( option , "big-file-threshold=" )) {
+ } else if ( has_prefix ( option , "big-file-threshold=" )) {
unsigned long v ;
if ( ! git_parse_ulong ( option + 19 , & v ))
return 0 ;
big_file_threshold = v ;
- } else if ( ! prefixcmp ( option , "depth=" )) {
+ } else if ( has_prefix ( option , "depth=" )) {
option_depth ( option + 6 );
- } else if ( ! prefixcmp ( option , "active-branches=" )) {
+ } else if ( has_prefix ( option , "active-branches=" )) {
option_active_branches ( option + 16 );
- } else if ( ! prefixcmp ( option , "export-pack-edges=" )) {
+ } else if ( has_prefix ( option , "export-pack-edges=" )) {
option_export_pack_edges ( option + 18 );
- } else if ( ! prefixcmp ( option , "quiet" )) {
+ } else if ( has_prefix ( option , "quiet" )) {
show_stats = 0 ;
- } else if ( ! prefixcmp ( option , "stats" )) {
+ } else if ( has_prefix ( option , "stats" )) {
show_stats = 1 ;
} else {
return 0 ; @@ -3245,14 +3245,14 @@ static int parse_one_option(const char *option)
static int parse_one_feature ( const char * feature , int from_stream )
{
- if ( ! prefixcmp ( feature , "date-format=" )) {
+ if ( has_prefix ( feature , "date-format=" )) {
option_date_format ( feature + 12 );
- } else if ( ! prefixcmp ( feature , "import-marks=" )) {
+ } else if ( has_prefix ( feature , "import-marks=" )) {
option_import_marks ( feature + 13 , from_stream , 0 );
- } else if ( ! prefixcmp ( feature , "import-marks-if-exists=" )) {
+ } else if ( has_prefix ( feature , "import-marks-if-exists=" )) {
option_import_marks ( feature + strlen ( "import-marks-if-exists=" ),
from_stream , 1 );
- } else if ( ! prefixcmp ( feature , "export-marks=" )) {
+ } else if ( has_prefix ( feature , "export-marks=" )) {
option_export_marks ( feature + 13 );
} else if ( ! strcmp ( feature , "cat-blob" )) {
; /* Don't die - this feature is supported */ @@ -3350,7 +3350,7 @@ static void parse_argv(void)
if ( parse_one_feature ( a + 2 , 0 ))
continue ;
- if ( ! prefixcmp ( a + 2 , "cat-blob-fd=" )) {
+ if ( has_prefix ( a + 2 , "cat-blob-fd=" )) {
option_cat_blob_fd ( a + 2 + strlen ( "cat-blob-fd=" ));
continue ;
} @@ -3404,25 +3404,25 @@ int main(int argc, char **argv)
while ( read_next_command () != EOF ) {
if ( ! strcmp ( "blob" , command_buf . buf ))
parse_new_blob ();
- else if ( ! prefixcmp ( command_buf . buf , "ls " ))
+ else if ( has_prefix ( command_buf . buf , "ls " ))
parse_ls ( NULL );
- else if ( ! prefixcmp ( command_buf . buf , "commit " ))
+ else if ( has_prefix ( command_buf . buf , "commit " ))
parse_new_commit ();
- else if ( ! prefixcmp ( command_buf . buf , "tag " ))
+ else if ( has_prefix ( command_buf . buf , "tag " ))
parse_new_tag ();
- else if ( ! prefixcmp ( command_buf . buf , "reset " ))
+ else if ( has_prefix ( command_buf . buf , "reset " ))
parse_reset_branch ();
else if ( ! strcmp ( "checkpoint" , command_buf . buf ))
parse_checkpoint ();
else if ( ! strcmp ( "done" , command_buf . buf ))
break ;
- else if ( ! prefixcmp ( command_buf . buf , "progress " ))
+ else if ( has_prefix ( command_buf . buf , "progress " ))
parse_progress ();
- else if ( ! prefixcmp ( command_buf . buf , "feature " ))
+ else if ( has_prefix ( command_buf . buf , "feature " ))
parse_feature ();
- else if ( ! prefixcmp ( command_buf . buf , "option git " ))
+ else if ( has_prefix ( command_buf . buf , "option git " ))
parse_option ();
- else if ( ! prefixcmp ( command_buf . buf , "option " ))
+ else if ( has_prefix ( command_buf . buf , "option " ))
/* ignore non-git options*/ ;
else
die ( "Unsupported command: %s" , command_buf . buf ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
remote-curl.c | 14 +++++++-------
remote-testsvn.c | 10 +++++-----
remote.c | 46 +++++++++++++++++++++++-----------------------
3 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/remote-curl.c b/remote-curl.c
index b5ebe01..437b863 100644
--- a/remote-curl.c
+++ b/remote-curl.c @@ -212,7 +212,7 @@ static struct discovery* discover_refs(const char *service, int for_push)
free_discovery ( last );
strbuf_addf ( & buffer , "%sinfo/refs" , url );
- if (( ! prefixcmp ( url , "http://" ) || ! prefixcmp ( url , "https://" )) &&
+ if (( has_prefix ( url , "http://" ) || has_prefix ( url , "https://" )) &&
git_env_bool ( "GIT_SMART_HTTP" , 1 )) {
maybe_smart = 1 ;
if ( ! strchr ( url , '?' )) @@ -740,7 +740,7 @@ static void parse_fetch(struct strbuf *buf)
int alloc_heads = 0 , nr_heads = 0 ;
do {
- if ( ! prefixcmp ( buf -> buf , "fetch " )) {
+ if ( has_prefix ( buf -> buf , "fetch " )) {
char * p = buf -> buf + strlen ( "fetch " );
char * name ;
struct ref * ref ; @@ -863,7 +863,7 @@ static void parse_push(struct strbuf *buf)
int alloc_spec = 0 , nr_spec = 0 , i , ret ;
do {
- if ( ! prefixcmp ( buf -> buf , "push " )) {
+ if ( has_prefix ( buf -> buf , "push " )) {
ALLOC_GROW ( specs , nr_spec + 1 , alloc_spec );
specs [ nr_spec ++ ] = xstrdup ( buf -> buf + 5 );
} @@ -928,19 +928,19 @@ int main(int argc, const char **argv)
}
if ( buf . len == 0 )
break ;
- if ( ! prefixcmp ( buf . buf , "fetch " )) {
+ if ( has_prefix ( buf . buf , "fetch " )) {
if ( nongit )
die ( "Fetch attempted without a local repo" );
parse_fetch ( & buf );
- } else if ( ! strcmp ( buf . buf , "list" ) || ! prefixcmp ( buf . buf , "list " )) {
+ } else if ( ! strcmp ( buf . buf , "list" ) || has_prefix ( buf . buf , "list " )) {
int for_push = !! strstr ( buf . buf + 4 , "for-push" );
output_refs ( get_refs ( for_push ));
- } else if ( ! prefixcmp ( buf . buf , "push " )) {
+ } else if ( has_prefix ( buf . buf , "push " )) {
parse_push ( & buf );
- } else if ( ! prefixcmp ( buf . buf , "option " )) {
+ } else if ( has_prefix ( buf . buf , "option " )) {
char * name = buf . buf + strlen ( "option " );
char * value = strchr ( name , ' ' );
int result ; diff --git a/remote-testsvn.c b/remote-testsvn.c
index d7cd5d2..7a5d4c8 100644
--- a/remote-testsvn.c
+++ b/remote-testsvn.c @@ -82,7 +82,7 @@ static int parse_rev_note(const char *msg, struct rev_note *res)
len = end ? end - msg : strlen ( msg );
key = "Revision-number: " ;
- if ( ! prefixcmp ( msg , key )) {
+ if ( has_prefix ( msg , key )) {
long i ;
char * end ;
value = msg + strlen ( key ); @@ -154,7 +154,7 @@ static void check_or_regenerate_marks(int latestrev)
} else {
strbuf_addf ( & sb , ":%d " , latestrev );
while ( strbuf_getline ( & line , marksfile , '\n' ) != EOF ) {
- if ( ! prefixcmp ( line . buf , sb . buf )) {
+ if ( has_prefix ( line . buf , sb . buf )) {
found ++ ;
break ;
} @@ -264,7 +264,7 @@ static int do_command(struct strbuf *line)
return 1 ; /* end of command stream, quit */
}
if ( batch_cmd ) {
- if ( prefixcmp ( batch_cmd -> name , line -> buf ))
+ if ( ! has_prefix ( batch_cmd -> name , line -> buf ))
die ( "Active %s batch interrupted by %s" , batch_cmd -> name , line -> buf );
/* buffer batch lines */
string_list_append ( & batchlines , line -> buf ); @@ -272,7 +272,7 @@ static int do_command(struct strbuf *line)
}
for ( p = input_command_list ; p -> name ; p ++ ) {
- if ( ! prefixcmp ( line -> buf , p -> name ) && ( strlen ( p -> name ) == line -> len ||
+ if ( has_prefix ( line -> buf , p -> name ) && ( strlen ( p -> name ) == line -> len ||
line -> buf [ strlen ( p -> name )] == ' ' )) {
if ( p -> batchable ) {
batch_cmd = p ; @@ -304,7 +304,7 @@ int main(int argc, char **argv)
remote = remote_get ( argv [ 1 ]);
url_in = ( argc == 3 ) ? argv [ 2 ] : remote -> url [ 0 ];
- if ( ! prefixcmp ( url_in , "file://" )) {
+ if ( has_prefix ( url_in , "file://" )) {
dump_from_file = 1 ;
url = url_decode ( url_in + sizeof ( "file://" ) -1 );
} else { diff --git a/remote.c b/remote.c
index e9fedfa..84c0d9f 100644
--- a/remote.c
+++ b/remote.c @@ -76,7 +76,7 @@ static const char *alias_url(const char *url, struct rewrites *r)
if ( ! r -> rewrite [ i ])
continue ;
for ( j = 0 ; j < r -> rewrite [ i ] -> instead_of_nr ; j ++ ) {
- if ( ! prefixcmp ( url , r -> rewrite [ i ] -> instead_of [ j ]. s ) &&
+ if ( has_prefix ( url , r -> rewrite [ i ] -> instead_of [ j ]. s ) &&
( ! longest ||
longest -> len < r -> rewrite [ i ] -> instead_of [ j ]. len )) {
longest = & ( r -> rewrite [ i ] -> instead_of [ j ]); @@ -239,13 +239,13 @@ static void read_remotes_file(struct remote *remote)
int value_list ;
char * s , * p ;
- if ( ! prefixcmp ( buffer , "URL:" )) {
+ if ( has_prefix ( buffer , "URL:" )) {
value_list = 0 ;
s = buffer + 4 ;
- } else if ( ! prefixcmp ( buffer , "Push:" )) {
+ } else if ( has_prefix ( buffer , "Push:" )) {
value_list = 1 ;
s = buffer + 5 ;
- } else if ( ! prefixcmp ( buffer , "Pull:" )) {
+ } else if ( has_prefix ( buffer , "Pull:" )) {
value_list = 2 ;
s = buffer + 5 ;
} else @@ -337,7 +337,7 @@ static int handle_config(const char *key, const char *value, void *cb)
const char * subkey ;
struct remote * remote ;
struct branch * branch ;
- if ( ! prefixcmp ( key , "branch." )) {
+ if ( has_prefix ( key , "branch." )) {
name = key + 7 ;
subkey = strrchr ( name , '.' );
if ( ! subkey ) @@ -361,7 +361,7 @@ static int handle_config(const char *key, const char *value, void *cb)
}
return 0 ;
}
- if ( ! prefixcmp ( key , "url." )) {
+ if ( has_prefix ( key , "url." )) {
struct rewrite * rewrite ;
name = key + 4 ;
subkey = strrchr ( name , '.' ); @@ -380,7 +380,7 @@ static int handle_config(const char *key, const char *value, void *cb)
}
}
- if ( prefixcmp ( key , "remote." ))
+ if ( ! has_prefix ( key , "remote." ))
return 0 ;
name = key + 7 ;
@@ -487,7 +487,7 @@ static void read_config(void)
current_branch = NULL ;
head_ref = resolve_ref_unsafe ( "HEAD" , sha1 , 0 , & flag );
if ( head_ref && ( flag & REF_ISSYMREF ) &&
- ! prefixcmp ( head_ref , "refs/heads/" )) {
+ has_prefix ( head_ref , "refs/heads/" )) {
current_branch =
make_branch ( head_ref + strlen ( "refs/heads/" ), 0 );
} @@ -982,8 +982,8 @@ static int count_refspec_match(const char *pattern,
*/
if ( namelen != patlen &&
patlen != namelen - 5 &&
- prefixcmp ( name , "refs/heads/" ) &&
- prefixcmp ( name , "refs/tags/" )) {
+ ! has_prefix ( name , "refs/heads/" ) &&
+ ! has_prefix ( name , "refs/tags/" )) {
/* We want to catch the case where only weak
* matches are found and there are multiple
* matches , and where more than one strong @@ -1054,9 +1054,9 @@ static char *guess_ref(const char *name, struct ref *peer)
if ( ! r )
return NULL ;
- if ( ! prefixcmp ( r , "refs/heads/" ))
+ if ( has_prefix ( r , "refs/heads/" ))
strbuf_addstr ( & buf , "refs/heads/" );
- else if ( ! prefixcmp ( r , "refs/tags/" ))
+ else if ( has_prefix ( r , "refs/tags/" ))
strbuf_addstr ( & buf , "refs/tags/" );
else
return NULL ; @@ -1104,7 +1104,7 @@ static int match_explicit(struct ref *src, struct ref *dst,
dst_value = resolve_ref_unsafe ( matched_src -> name , sha1 , 1 , & flag );
if ( ! dst_value ||
(( flag & REF_ISSYMREF ) &&
- prefixcmp ( dst_value , "refs/heads/" )))
+ ! has_prefix ( dst_value , "refs/heads/" )))
die ( "%s cannot be resolved to branch." ,
matched_src -> name );
} @@ -1193,7 +1193,7 @@ static char *get_ref_match(const struct refspec *rs, int rs_nr, const struct ref
* including refs outside refs / heads / hierarchy , but
* that does not make much sense these days .
*/
- if ( ! send_mirror && prefixcmp ( ref -> name , "refs/heads/" ))
+ if ( ! send_mirror && ! has_prefix ( ref -> name , "refs/heads/" ))
return NULL ;
name = xstrdup ( ref -> name );
} @@ -1248,7 +1248,7 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
add_to_tips ( & sent_tips , ref -> peer_ref -> new_sha1 );
else
add_to_tips ( & sent_tips , ref -> old_sha1 );
- if ( ! prefixcmp ( ref -> name , "refs/tags/" ))
+ if ( has_prefix ( ref -> name , "refs/tags/" ))
string_list_append ( & dst_tag , ref -> name );
}
clear_commit_marks_many ( sent_tips . nr , sent_tips . tip , TMP_MARK ); @@ -1257,7 +1257,7 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
/* Collect tags they do not have. */
for ( ref = src ; ref ; ref = ref -> next ) {
- if ( prefixcmp ( ref -> name , "refs/tags/" ))
+ if ( ! has_prefix ( ref -> name , "refs/tags/" ))
continue ; /* not a tag */
if ( string_list_has_string ( & dst_tag , ref -> name ))
continue ; /* they already have it */ @@ -1481,7 +1481,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
*/
else if ( ! ref -> deletion && ! is_null_sha1 ( ref -> old_sha1 )) {
- if ( ! prefixcmp ( ref -> name , "refs/tags/" ))
+ if ( has_prefix ( ref -> name , "refs/tags/" ))
reject_reason = REF_STATUS_REJECT_ALREADY_EXISTS ;
else if ( ! has_sha1_file ( ref -> old_sha1 ))
reject_reason = REF_STATUS_REJECT_FETCH_FIRST ; @@ -1607,12 +1607,12 @@ static struct ref *get_local_ref(const char *name)
if ( ! name || name [ 0 ] == '\0' )
return NULL ;
- if ( ! prefixcmp ( name , "refs/" ))
+ if ( has_prefix ( name , "refs/" ))
return alloc_ref ( name );
- if ( ! prefixcmp ( name , "heads/" ) ||
- ! prefixcmp ( name , "tags/" ) ||
- ! prefixcmp ( name , "remotes/" ))
+ if ( has_prefix ( name , "heads/" ) ||
+ has_prefix ( name , "tags/" ) ||
+ has_prefix ( name , "remotes/" ))
return alloc_ref_with_prefix ( "refs/" , 5 , name );
return alloc_ref_with_prefix ( "refs/heads/" , 11 , name ); @@ -1647,7 +1647,7 @@ int get_fetch_map(const struct ref *remote_refs,
for ( rmp = & ref_map ; * rmp ; ) {
if (( * rmp ) -> peer_ref ) {
- if ( prefixcmp (( * rmp ) -> peer_ref -> name , "refs/" ) ||
+ if ( ! has_prefix (( * rmp ) -> peer_ref -> name , "refs/" ) ||
check_refname_format (( * rmp ) -> peer_ref -> name , 0 )) {
struct ref * ignore = * rmp ;
error ( "* Ignoring funny ref '%s' locally" , @@ -1931,7 +1931,7 @@ struct ref *guess_remote_head(const struct ref *head,
/* Look for another ref that points there */
for ( r = refs ; r ; r = r -> next ) {
if ( r != head &&
- ! prefixcmp ( r -> name , "refs/heads/" ) &&
+ has_prefix ( r -> name , "refs/heads/" ) &&
! hashcmp ( r -> old_sha1 , head -> old_sha1 )) {
* tail = copy_ref ( r );
tail = & (( * tail ) -> next ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
diff.c | 56 ++++++++++++++++++++++++++++----------------------------
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/diff.c b/diff.c
index a04a34d..b42523a 100644
--- a/diff.c
+++ b/diff.c @@ -235,7 +235,7 @@ int git_diff_basic_config(const char *var, const char *value, void *cb)
if ( userdiff_config ( var , value ) < 0 )
return -1 ;
- if ( ! prefixcmp ( var , "diff.color." ) || ! prefixcmp ( var , "color.diff." )) {
+ if ( has_prefix ( var , "diff.color." ) || has_prefix ( var , "color.diff." )) {
int slot = parse_diff_color_slot ( var , 11 );
if ( slot < 0 )
return 0 ; @@ -264,7 +264,7 @@ int git_diff_basic_config(const char *var, const char *value, void *cb)
return 0 ;
}
- if ( ! prefixcmp ( var , "submodule." ))
+ if ( has_prefix ( var , "submodule." ))
return parse_submodule_config_option ( var , value );
return git_default_config ( var , value , cb ); @@ -1215,7 +1215,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
diff_words_append ( line , len ,
& ecbdata -> diff_words -> plus );
return ;
- } else if ( ! prefixcmp ( line , " \\ " )) {
+ } else if ( has_prefix ( line , " \\ " )) {
/*
* Eat the "no newline at eof" marker as if we
* saw a "+" or "-" line with nothing on it , @@ -2387,9 +2387,9 @@ static void builtin_diff(const char *name_a,
xdiff_set_find_func ( & xecfg , pe -> pattern , pe -> cflags );
if ( ! diffopts )
;
- else if ( ! prefixcmp ( diffopts , "--unified=" ))
+ else if ( has_prefix ( diffopts , "--unified=" ))
xecfg . ctxlen = strtoul ( diffopts + 10 , NULL , 10 );
- else if ( ! prefixcmp ( diffopts , "-u" ))
+ else if ( has_prefix ( diffopts , "-u" ))
xecfg . ctxlen = strtoul ( diffopts + 2 , NULL , 10 );
if ( o -> word_diff )
init_diff_words_data ( & ecbdata , o , one , two ); @@ -3388,7 +3388,7 @@ int parse_long_opt(const char *opt, const char **argv,
if ( arg [ 0 ] != '-' || arg [ 1 ] != '-' )
return 0 ;
arg += strlen ( "--" );
- if ( prefixcmp ( arg , opt ))
+ if ( ! has_prefix ( arg , opt ))
return 0 ;
arg += strlen ( opt );
if ( * arg == '=' ) { /* sticked form: --option=value */ @@ -3419,7 +3419,7 @@ static int stat_opt(struct diff_options *options, const char **av)
switch ( * arg ) {
case '-' :
- if ( ! prefixcmp ( arg , "-width" )) {
+ if ( has_prefix ( arg , "-width" )) {
arg += strlen ( "-width" );
if ( * arg == '=' )
width = strtoul ( arg + 1 , & end , 10 ); @@ -3429,7 +3429,7 @@ static int stat_opt(struct diff_options *options, const char **av)
width = strtoul ( av [ 1 ], & end , 10 );
argcount = 2 ;
}
- } else if ( ! prefixcmp ( arg , "-name-width" )) {
+ } else if ( has_prefix ( arg , "-name-width" )) {
arg += strlen ( "-name-width" );
if ( * arg == '=' )
name_width = strtoul ( arg + 1 , & end , 10 ); @@ -3439,7 +3439,7 @@ static int stat_opt(struct diff_options *options, const char **av)
name_width = strtoul ( av [ 1 ], & end , 10 );
argcount = 2 ;
}
- } else if ( ! prefixcmp ( arg , "-graph-width" )) {
+ } else if ( has_prefix ( arg , "-graph-width" )) {
arg += strlen ( "-graph-width" );
if ( * arg == '=' )
graph_width = strtoul ( arg + 1 , & end , 10 ); @@ -3449,7 +3449,7 @@ static int stat_opt(struct diff_options *options, const char **av)
graph_width = strtoul ( av [ 1 ], & end , 10 );
argcount = 2 ;
}
- } else if ( ! prefixcmp ( arg , "-count" )) {
+ } else if ( has_prefix ( arg , "-count" )) {
arg += strlen ( "-count" );
if ( * arg == '=' )
count = strtoul ( arg + 1 , & end , 10 ); @@ -3611,15 +3611,15 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
options -> output_format |= DIFF_FORMAT_SHORTSTAT ;
else if ( ! strcmp ( arg , "-X" ) || ! strcmp ( arg , "--dirstat" ))
return parse_dirstat_opt ( options , "" );
- else if ( ! prefixcmp ( arg , "-X" ))
+ else if ( has_prefix ( arg , "-X" ))
return parse_dirstat_opt ( options , arg + 2 );
- else if ( ! prefixcmp ( arg , "--dirstat=" ))
+ else if ( has_prefix ( arg , "--dirstat=" ))
return parse_dirstat_opt ( options , arg + 10 );
else if ( ! strcmp ( arg , "--cumulative" ))
return parse_dirstat_opt ( options , "cumulative" );
else if ( ! strcmp ( arg , "--dirstat-by-file" ))
return parse_dirstat_opt ( options , "files" );
- else if ( ! prefixcmp ( arg , "--dirstat-by-file=" )) {
+ else if ( has_prefix ( arg , "--dirstat-by-file=" )) {
parse_dirstat_opt ( options , "files" );
return parse_dirstat_opt ( options , arg + 18 );
} @@ -3636,17 +3636,17 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
options -> output_format |= DIFF_FORMAT_NAME_STATUS ;
else if ( ! strcmp ( arg , "-s" ) || ! strcmp ( arg , "--no-patch" ))
options -> output_format |= DIFF_FORMAT_NO_OUTPUT ;
- else if ( ! prefixcmp ( arg , "--stat" ))
+ else if ( has_prefix ( arg , "--stat" ))
/* --stat, --stat-width, --stat-name-width, or --stat-count */
return stat_opt ( options , av );
/* renames options */
- else if ( ! prefixcmp ( arg , "-B" ) || ! prefixcmp ( arg , "--break-rewrites=" ) ||
+ else if ( has_prefix ( arg , "-B" ) || has_prefix ( arg , "--break-rewrites=" ) ||
! strcmp ( arg , "--break-rewrites" )) {
if (( options -> break_opt = diff_scoreopt_parse ( arg )) == -1 )
return error ( "invalid argument to -B: %s" , arg + 2 );
}
- else if ( ! prefixcmp ( arg , "-M" ) || ! prefixcmp ( arg , "--find-renames=" ) ||
+ else if ( has_prefix ( arg , "-M" ) || has_prefix ( arg , "--find-renames=" ) ||
! strcmp ( arg , "--find-renames" )) {
if (( options -> rename_score = diff_scoreopt_parse ( arg )) == -1 )
return error ( "invalid argument to -M: %s" , arg + 2 ); @@ -3655,7 +3655,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
else if ( ! strcmp ( arg , "-D" ) || ! strcmp ( arg , "--irreversible-delete" )) {
options -> irreversible_delete = 1 ;
}
- else if ( ! prefixcmp ( arg , "-C" ) || ! prefixcmp ( arg , "--find-copies=" ) ||
+ else if ( has_prefix ( arg , "-C" ) || has_prefix ( arg , "--find-copies=" ) ||
! strcmp ( arg , "--find-copies" )) {
if ( options -> detect_rename == DIFF_DETECT_COPY )
DIFF_OPT_SET ( options , FIND_COPIES_HARDER ); @@ -3671,7 +3671,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
DIFF_OPT_CLR ( options , RENAME_EMPTY );
else if ( ! strcmp ( arg , "--relative" ))
DIFF_OPT_SET ( options , RELATIVE_NAME );
- else if ( ! prefixcmp ( arg , "--relative=" )) {
+ else if ( has_prefix ( arg , "--relative=" )) {
DIFF_OPT_SET ( options , RELATIVE_NAME );
options -> prefix = arg + 11 ;
} @@ -3724,7 +3724,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
DIFF_OPT_CLR ( options , FOLLOW_RENAMES );
else if ( ! strcmp ( arg , "--color" ))
options -> use_color = 1 ;
- else if ( ! prefixcmp ( arg , "--color=" )) {
+ else if ( has_prefix ( arg , "--color=" )) {
int value = git_config_colorbool ( NULL , arg + 8 );
if ( value < 0 )
return error ( "option `color' expects \" always \" , \" auto \" , or \" never \" " ); @@ -3736,7 +3736,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
options -> use_color = 1 ;
options -> word_diff = DIFF_WORDS_COLOR ;
}
- else if ( ! prefixcmp ( arg , "--color-words=" )) {
+ else if ( has_prefix ( arg , "--color-words=" )) {
options -> use_color = 1 ;
options -> word_diff = DIFF_WORDS_COLOR ;
options -> word_regex = arg + 14 ; @@ -3745,7 +3745,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
if ( options -> word_diff == DIFF_WORDS_NONE )
options -> word_diff = DIFF_WORDS_PLAIN ;
}
- else if ( ! prefixcmp ( arg , "--word-diff=" )) {
+ else if ( has_prefix ( arg , "--word-diff=" )) {
const char * type = arg + 12 ;
if ( ! strcmp ( type , "plain" ))
options -> word_diff = DIFF_WORDS_PLAIN ; @@ -3781,12 +3781,12 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
else if ( ! strcmp ( arg , "--ignore-submodules" )) {
DIFF_OPT_SET ( options , OVERRIDE_SUBMODULE_CONFIG );
handle_ignore_submodules_arg ( options , "all" );
- } else if ( ! prefixcmp ( arg , "--ignore-submodules=" )) {
+ } else if ( has_prefix ( arg , "--ignore-submodules=" )) {
DIFF_OPT_SET ( options , OVERRIDE_SUBMODULE_CONFIG );
handle_ignore_submodules_arg ( options , arg + 20 );
} else if ( ! strcmp ( arg , "--submodule" ))
DIFF_OPT_SET ( options , SUBMODULE_LOG );
- else if ( ! prefixcmp ( arg , "--submodule=" ))
+ else if ( has_prefix ( arg , "--submodule=" ))
return parse_submodule_opt ( options , arg + 12 );
/* misc options */ @@ -3822,7 +3822,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
}
else if ( ! strcmp ( arg , "--abbrev" ))
options -> abbrev = DEFAULT_ABBREV ;
- else if ( ! prefixcmp ( arg , "--abbrev=" )) {
+ else if ( has_prefix ( arg , "--abbrev=" )) {
options -> abbrev = strtoul ( arg + 9 , NULL , 10 );
if ( options -> abbrev < MINIMUM_ABBREV )
options -> abbrev = MINIMUM_ABBREV ; @@ -3904,15 +3904,15 @@ static int diff_scoreopt_parse(const char *opt)
cmd = * opt ++ ;
if ( cmd == '-' ) {
/* convert the long-form arguments into short-form versions */
- if ( ! prefixcmp ( opt , "break-rewrites" )) {
+ if ( has_prefix ( opt , "break-rewrites" )) {
opt += strlen ( "break-rewrites" );
if ( * opt == 0 || * opt ++ == '=' )
cmd = 'B' ;
- } else if ( ! prefixcmp ( opt , "find-copies" )) {
+ } else if ( has_prefix ( opt , "find-copies" )) {
opt += strlen ( "find-copies" );
if ( * opt == 0 || * opt ++ == '=' )
cmd = 'C' ;
- } else if ( ! prefixcmp ( opt , "find-renames" )) {
+ } else if ( has_prefix ( opt , "find-renames" )) {
opt += strlen ( "find-renames" );
if ( * opt == 0 || * opt ++ == '=' )
cmd = 'M' ; @@ -4322,7 +4322,7 @@ static void patch_id_consume(void *priv, char *line, unsigned long len)
int new_len ;
/* Ignore line numbers when computing the SHA1 of the patch */
- if ( ! prefixcmp ( line , "@@ -" ))
+ if ( has_prefix ( line , "@@ -" ))
return ;
new_len = remove_space ( line , len ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
daemon.c | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/daemon.c b/daemon.c
index 34916c5..4b23800 100644
--- a/daemon.c
+++ b/daemon.c @@ -235,7 +235,7 @@ static int service_enabled;
static int git_daemon_config ( const char * var , const char * value , void * cb )
{
- if ( ! prefixcmp ( var , "daemon." ) &&
+ if ( has_prefix ( var , "daemon." ) &&
! strcmp ( var + 7 , service_looking_at -> config_name )) {
service_enabled = git_config_bool ( var , value );
return 0 ; @@ -633,7 +633,7 @@ static int execute(void)
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 ( has_prefix ( line , "git-" ) &&
! strncmp ( s -> name , line + 4 , namelen ) &&
line [ namelen + 4 ] == ' ' ) {
/* @@ -1165,11 +1165,11 @@ int main(int argc, char **argv)
for ( i = 1 ; i < argc ; i ++ ) {
char * arg = argv [ i ];
- if ( ! prefixcmp ( arg , "--listen=" )) {
+ if ( has_prefix ( arg , "--listen=" )) {
string_list_append ( & listen_addr , xstrdup_tolower ( arg + 9 ));
continue ;
}
- if ( ! prefixcmp ( arg , "--port=" )) {
+ if ( has_prefix ( arg , "--port=" )) {
char * end ;
unsigned long n ;
n = strtoul ( arg + 7 , & end , 0 ); @@ -1199,19 +1199,19 @@ int main(int argc, char **argv)
export_all_trees = 1 ;
continue ;
}
- if ( ! prefixcmp ( arg , "--access-hook=" )) {
+ if ( has_prefix ( arg , "--access-hook=" )) {
access_hook = arg + 14 ;
continue ;
}
- if ( ! prefixcmp ( arg , "--timeout=" )) {
+ if ( has_prefix ( arg , "--timeout=" )) {
timeout = atoi ( arg + 10 );
continue ;
}
- if ( ! prefixcmp ( arg , "--init-timeout=" )) {
+ if ( has_prefix ( arg , "--init-timeout=" )) {
init_timeout = atoi ( arg + 15 );
continue ;
}
- if ( ! prefixcmp ( arg , "--max-connections=" )) {
+ if ( has_prefix ( arg , "--max-connections=" )) {
max_connections = atoi ( arg + 18 );
if ( max_connections < 0 )
max_connections = 0 ; /* unlimited */ @@ -1221,7 +1221,7 @@ int main(int argc, char **argv)
strict_paths = 1 ;
continue ;
}
- if ( ! prefixcmp ( arg , "--base-path=" )) {
+ if ( has_prefix ( arg , "--base-path=" )) {
base_path = arg + 12 ;
continue ;
} @@ -1229,7 +1229,7 @@ int main(int argc, char **argv)
base_path_relaxed = 1 ;
continue ;
}
- if ( ! prefixcmp ( arg , "--interpolated-path=" )) {
+ if ( has_prefix ( arg , "--interpolated-path=" )) {
interpolated_path = arg + 20 ;
continue ;
} @@ -1241,11 +1241,11 @@ int main(int argc, char **argv)
user_path = "" ;
continue ;
}
- if ( ! prefixcmp ( arg , "--user-path=" )) {
+ if ( has_prefix ( arg , "--user-path=" )) {
user_path = arg + 12 ;
continue ;
}
- if ( ! prefixcmp ( arg , "--pid-file=" )) {
+ if ( has_prefix ( arg , "--pid-file=" )) {
pid_file = arg + 11 ;
continue ;
} @@ -1254,35 +1254,35 @@ int main(int argc, char **argv)
log_syslog = 1 ;
continue ;
}
- if ( ! prefixcmp ( arg , "--user=" )) {
+ if ( has_prefix ( arg , "--user=" )) {
user_name = arg + 7 ;
continue ;
}
- if ( ! prefixcmp ( arg , "--group=" )) {
+ if ( has_prefix ( arg , "--group=" )) {
group_name = arg + 8 ;
continue ;
}
- if ( ! prefixcmp ( arg , "--enable=" )) {
+ if ( has_prefix ( arg , "--enable=" )) {
enable_service ( arg + 9 , 1 );
continue ;
}
- if ( ! prefixcmp ( arg , "--disable=" )) {
+ if ( has_prefix ( arg , "--disable=" )) {
enable_service ( arg + 10 , 0 );
continue ;
}
- if ( ! prefixcmp ( arg , "--allow-override=" )) {
+ if ( has_prefix ( arg , "--allow-override=" )) {
make_service_overridable ( arg + 17 , 1 );
continue ;
}
- if ( ! prefixcmp ( arg , "--forbid-override=" )) {
+ if ( has_prefix ( arg , "--forbid-override=" )) {
make_service_overridable ( arg + 18 , 0 );
continue ;
}
- if ( ! prefixcmp ( arg , "--informative-errors" )) {
+ if ( has_prefix ( arg , "--informative-errors" )) {
informative_errors = 1 ;
continue ;
}
- if ( ! prefixcmp ( arg , "--no-informative-errors" )) {
+ if ( has_prefix ( arg , "--no-informative-errors" )) {
informative_errors = 0 ;
continue ;
} --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
revision.c | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/revision.c b/revision.c
index 0173e01..968320a 100644
--- a/revision.c
+++ b/revision.c @@ -1576,9 +1576,9 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
! strcmp ( arg , "--tags" ) || ! strcmp ( arg , "--remotes" ) ||
! strcmp ( arg , "--reflog" ) || ! strcmp ( arg , "--not" ) ||
! strcmp ( arg , "--no-walk" ) || ! strcmp ( arg , "--do-walk" ) ||
- ! strcmp ( arg , "--bisect" ) || ! prefixcmp ( arg , "--glob=" ) ||
- ! prefixcmp ( arg , "--branches=" ) || ! prefixcmp ( arg , "--tags=" ) ||
- ! prefixcmp ( arg , "--remotes=" ) || ! prefixcmp ( arg , "--no-walk=" ))
+ ! strcmp ( arg , "--bisect" ) || has_prefix ( arg , "--glob=" ) ||
+ has_prefix ( arg , "--branches=" ) || has_prefix ( arg , "--tags=" ) ||
+ has_prefix ( arg , "--remotes=" ) || has_prefix ( arg , "--no-walk=" ))
{
unkv [( * unkc ) ++ ] = arg ;
return 1 ; @@ -1601,7 +1601,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
revs -> max_count = atoi ( argv [ 1 ]);
revs -> no_walk = 0 ;
return 2 ;
- } else if ( ! prefixcmp ( arg , "-n" )) {
+ } else if ( has_prefix ( arg , "-n" )) {
revs -> max_count = atoi ( arg + 2 );
revs -> no_walk = 0 ;
} else if (( argcount = parse_long_opt ( "max-age" , argv , & optarg ))) { @@ -1661,7 +1661,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
} else if ( ! strcmp ( arg , "--author-date-order" )) {
revs -> sort_order = REV_SORT_BY_AUTHOR_DATE ;
revs -> topo_order = 1 ;
- } else if ( ! prefixcmp ( arg , "--early-output" )) {
+ } else if ( has_prefix ( arg , "--early-output" )) {
int count = 100 ;
switch ( arg [ 14 ]) {
case '=' : @@ -1686,13 +1686,13 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
revs -> min_parents = 2 ;
} else if ( ! strcmp ( arg , "--no-merges" )) {
revs -> max_parents = 1 ;
- } else if ( ! prefixcmp ( arg , "--min-parents=" )) {
+ } else if ( has_prefix ( arg , "--min-parents=" )) {
revs -> min_parents = atoi ( arg + 14 );
- } else if ( ! prefixcmp ( arg , "--no-min-parents" )) {
+ } else if ( has_prefix ( arg , "--no-min-parents" )) {
revs -> min_parents = 0 ;
- } else if ( ! prefixcmp ( arg , "--max-parents=" )) {
+ } else if ( has_prefix ( arg , "--max-parents=" )) {
revs -> max_parents = atoi ( arg + 14 );
- } else if ( ! prefixcmp ( arg , "--no-max-parents" )) {
+ } else if ( has_prefix ( arg , "--no-max-parents" )) {
revs -> max_parents = -1 ;
} else if ( ! strcmp ( arg , "--boundary" )) {
revs -> boundary = 1 ; @@ -1742,7 +1742,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
revs -> verify_objects = 1 ;
} else if ( ! strcmp ( arg , "--unpacked" )) {
revs -> unpacked = 1 ;
- } else if ( ! prefixcmp ( arg , "--unpacked=" )) {
+ } else if ( has_prefix ( arg , "--unpacked=" )) {
die ( "--unpacked=<packfile> no longer supported." );
} else if ( ! strcmp ( arg , "-r" )) {
revs -> diff = 1 ; @@ -1767,7 +1767,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
revs -> verbose_header = 1 ;
revs -> pretty_given = 1 ;
get_commit_format ( arg + 8 , revs );
- } else if ( ! prefixcmp ( arg , "--pretty=" ) || ! prefixcmp ( arg , "--format=" )) {
+ } else if ( has_prefix ( arg , "--pretty=" ) || has_prefix ( arg , "--format=" )) {
/*
* Detached form ( "--pretty X" as opposed to "--pretty=X" )
* not allowed , since the argument is optional . @@ -1781,12 +1781,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
revs -> notes_opt . use_default_notes = 1 ;
} else if ( ! strcmp ( arg , "--show-signature" )) {
revs -> show_signature = 1 ;
- } else if ( ! prefixcmp ( arg , "--show-notes=" ) ||
- ! prefixcmp ( arg , "--notes=" )) {
+ } else if ( has_prefix ( arg , "--show-notes=" ) ||
+ has_prefix ( arg , "--notes=" )) {
struct strbuf buf = STRBUF_INIT ;
revs -> show_notes = 1 ;
revs -> show_notes_given = 1 ;
- if ( ! prefixcmp ( arg , "--show-notes" )) {
+ if ( has_prefix ( arg , "--show-notes" )) {
if ( revs -> notes_opt . use_default_notes < 0 )
revs -> notes_opt . use_default_notes = 1 ;
strbuf_addstr ( & buf , arg + 13 ); @@ -1829,7 +1829,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
revs -> abbrev = 0 ;
} else if ( ! strcmp ( arg , "--abbrev" )) {
revs -> abbrev = DEFAULT_ABBREV ;
- } else if ( ! prefixcmp ( arg , "--abbrev=" )) {
+ } else if ( has_prefix ( arg , "--abbrev=" )) {
revs -> abbrev = strtoul ( arg + 9 , NULL , 10 );
if ( revs -> abbrev < MINIMUM_ABBREV )
revs -> abbrev = MINIMUM_ABBREV ; @@ -1968,15 +1968,15 @@ static int handle_revision_pseudo_opt(const char *submodule,
init_all_refs_cb ( & cb , revs , * flags );
for_each_glob_ref ( handle_one_ref , optarg , & cb );
return argcount ;
- } else if ( ! prefixcmp ( arg , "--branches=" )) {
+ } else if ( has_prefix ( arg , "--branches=" )) {
struct all_refs_cb cb ;
init_all_refs_cb ( & cb , revs , * flags );
for_each_glob_ref_in ( handle_one_ref , arg + 11 , "refs/heads/" , & cb );
- } else if ( ! prefixcmp ( arg , "--tags=" )) {
+ } else if ( has_prefix ( arg , "--tags=" )) {
struct all_refs_cb cb ;
init_all_refs_cb ( & cb , revs , * flags );
for_each_glob_ref_in ( handle_one_ref , arg + 7 , "refs/tags/" , & cb );
- } else if ( ! prefixcmp ( arg , "--remotes=" )) {
+ } else if ( has_prefix ( arg , "--remotes=" )) {
struct all_refs_cb cb ;
init_all_refs_cb ( & cb , revs , * flags );
for_each_glob_ref_in ( handle_one_ref , arg + 10 , "refs/remotes/" , & cb ); @@ -1986,7 +1986,7 @@ static int handle_revision_pseudo_opt(const char *submodule,
* flags ^= UNINTERESTING | BOTTOM ;
} else if ( ! strcmp ( arg , "--no-walk" )) {
revs -> no_walk = REVISION_WALK_NO_WALK_SORTED ;
- } else if ( ! prefixcmp ( arg , "--no-walk=" )) {
+ } else if ( has_prefix ( arg , "--no-walk=" )) {
/*
* Detached form ( "--no-walk X" as opposed to "--no-walk=X" )
* not allowed , since the argument is optional . --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/merge.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/builtin/merge.c b/builtin/merge.c
index 02a69c1..5c70cec 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c @@ -453,17 +453,17 @@ static void merge_name(const char *remote, struct strbuf *msg)
die ( _ ( "'%s' does not point to a commit" ), remote );
if ( dwim_ref ( remote , strlen ( remote ), branch_head , & found_ref ) > 0 ) {
- if ( ! prefixcmp ( found_ref , "refs/heads/" )) {
+ if ( has_prefix ( found_ref , "refs/heads/" )) {
strbuf_addf ( msg , "%s \t\t branch '%s' of . \n " ,
sha1_to_hex ( branch_head ), remote );
goto cleanup ;
}
- if ( ! prefixcmp ( found_ref , "refs/tags/" )) {
+ if ( has_prefix ( found_ref , "refs/tags/" )) {
strbuf_addf ( msg , "%s \t\t tag '%s' of . \n " ,
sha1_to_hex ( branch_head ), remote );
goto cleanup ;
}
- if ( ! prefixcmp ( found_ref , "refs/remotes/" )) {
+ if ( has_prefix ( found_ref , "refs/remotes/" )) {
strbuf_addf ( msg , "%s \t\t remote-tracking branch '%s' of . \n " ,
sha1_to_hex ( branch_head ), remote );
goto cleanup ; @@ -577,8 +577,8 @@ static int git_merge_config(const char *k, const char *v, void *cb)
{
int status ;
- if ( branch && ! prefixcmp ( k , "branch." ) &&
- ! prefixcmp ( k + 7 , branch ) &&
+ if ( branch && has_prefix ( k , "branch." ) &&
+ has_prefix ( k + 7 , branch ) &&
! strcmp ( k + 7 + strlen ( branch ), ".mergeoptions" )) {
free ( branch_mergeoptions );
branch_mergeoptions = xstrdup ( v ); @@ -1113,7 +1113,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* current branch .
*/
branch = branch_to_free = resolve_refdup ( "HEAD" , head_sha1 , 0 , & flag );
- if ( branch && ! prefixcmp ( branch , "refs/heads/" ))
+ if ( branch && has_prefix ( branch , "refs/heads/" ))
branch += 11 ;
if ( ! branch || is_null_sha1 ( head_sha1 ))
head_commit = NULL ; --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/send-pack.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/builtin/send-pack.c b/builtin/send-pack.c
index 4482f16..0c29e69 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c @@ -115,15 +115,15 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
const char * arg = * argv ;
if ( * arg == '-' ) {
- if ( ! prefixcmp ( arg , "--receive-pack=" )) {
+ if ( has_prefix ( arg , "--receive-pack=" )) {
receivepack = arg + 15 ;
continue ;
}
- if ( ! prefixcmp ( arg , "--exec=" )) {
+ if ( has_prefix ( arg , "--exec=" )) {
receivepack = arg + 7 ;
continue ;
}
- if ( ! prefixcmp ( arg , "--remote=" )) {
+ if ( has_prefix ( arg , "--remote=" )) {
remote_name = arg + 9 ;
continue ;
} @@ -181,7 +181,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
exit ( 1 );
continue ;
}
- if ( ! prefixcmp ( arg , "--" CAS_OPT_NAME "=" )) {
+ if ( has_prefix ( arg , "--" CAS_OPT_NAME "=" )) {
if ( parse_push_cas_option ( & cas ,
strchr ( arg , '=' ) + 1 , 0 ) < 0 )
exit ( 1 ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/update-ref.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/builtin/update-ref.c b/builtin/update-ref.c
index 702e90d..d81d959 100644
--- a/builtin/update-ref.c
+++ b/builtin/update-ref.c @@ -229,15 +229,15 @@ static void update_refs_stdin(void)
die ( "empty command in input" );
else if ( isspace ( * cmd . buf ))
die ( "whitespace before command: %s" , cmd . buf );
- else if ( ! prefixcmp ( cmd . buf , "update " ))
+ else if ( has_prefix ( cmd . buf , "update " ))
parse_cmd_update ( cmd . buf + 7 );
- else if ( ! prefixcmp ( cmd . buf , "create " ))
+ else if ( has_prefix ( cmd . buf , "create " ))
parse_cmd_create ( cmd . buf + 7 );
- else if ( ! prefixcmp ( cmd . buf , "delete " ))
+ else if ( has_prefix ( cmd . buf , "delete " ))
parse_cmd_delete ( cmd . buf + 7 );
- else if ( ! prefixcmp ( cmd . buf , "verify " ))
+ else if ( has_prefix ( cmd . buf , "verify " ))
parse_cmd_verify ( cmd . buf + 7 );
- else if ( ! prefixcmp ( cmd . buf , "option " ))
+ else if ( has_prefix ( cmd . buf , "option " ))
parse_cmd_option ( cmd . buf + 7 );
else
die ( "unknown command: %s" , cmd . buf ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/show-ref.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 9f3f5e3..5e978aa 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c @@ -37,8 +37,8 @@ static int show_ref(const char *refname, const unsigned char *sha1, int flag, vo
if ( tags_only || heads_only ) {
int match ;
- match = heads_only && ! prefixcmp ( refname , "refs/heads/" );
- match |= tags_only && ! prefixcmp ( refname , "refs/tags/" );
+ match = heads_only && has_prefix ( refname , "refs/heads/" );
+ match |= tags_only && has_prefix ( refname , "refs/tags/" );
if ( ! match )
return 0 ;
} @@ -210,7 +210,7 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
while ( * pattern ) {
unsigned char sha1 [ 20 ];
- if ( ! prefixcmp ( * pattern , "refs/" ) &&
+ if ( has_prefix ( * pattern , "refs/" ) &&
! read_ref ( * pattern , sha1 )) {
if ( ! quiet )
show_one ( * pattern , sha1 ); --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/symbolic-ref.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/symbolic-ref.c b/builtin/symbolic-ref.c
index f481959..868fab4 100644
--- a/builtin/symbolic-ref.c
+++ b/builtin/symbolic-ref.c @@ -65,7 +65,7 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
break ;
case 2 :
if ( ! strcmp ( argv [ 0 ], "HEAD" ) &&
- prefixcmp ( argv [ 1 ], "refs/" ))
+ ! has_prefix ( argv [ 1 ], "refs/" ))
die ( "Refusing to point HEAD outside of refs/" );
create_symref ( argv [ 0 ], argv [ 1 ], msg );
break ; --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/tag.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/tag.c b/builtin/tag.c
index ea55f1d..e7aaaa2 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c @@ -259,7 +259,7 @@ static int git_tag_config(const char *var, const char *value, void *cb)
int status = git_gpg_config ( var , value , cb );
if ( status )
return status ;
- if ( ! prefixcmp ( var , "column." ))
+ if ( has_prefix ( var , "column." ))
return git_column_config ( var , value , "tag" , & colopts );
return git_default_config ( var , value , cb );
} --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/unpack-objects.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 2217d7b..dc2dd77 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c @@ -523,7 +523,7 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
strict = 1 ;
continue ;
}
- if ( ! prefixcmp ( arg , "--pack_header=" )) {
+ if ( has_prefix ( arg , "--pack_header=" )) {
struct pack_header * hdr ;
char * c ;
--
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/tar-tree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/tar-tree.c b/builtin/tar-tree.c
index ba3ffe6..7f225cc 100644
--- a/builtin/tar-tree.c
+++ b/builtin/tar-tree.c @@ -34,7 +34,7 @@ int cmd_tar_tree(int argc, const char **argv, const char *prefix)
nargv [ nargc ++ ] = "archive" ;
nargv [ nargc ++ ] = "--format=tar" ;
- if ( 2 <= argc && ! prefixcmp ( argv [ 1 ], "--remote=" )) {
+ if ( 2 <= argc && has_prefix ( argv [ 1 ], "--remote=" )) {
nargv [ nargc ++ ] = argv [ 1 ];
argv ++ ;
argc -- ; --
1.8.4.1.566.geca833c
prefixcmp() is now useless as the previous commit replaced it
everywhere with has_prefix(). So let's now remove it.
Signed-off-by: Christian Couder <redacted>
---
git-compat-util.h | 1 -
strbuf.c | 9 ---------
2 files changed, 10 deletions(-)
diff --git a/git-compat-util.h b/git-compat-util.h
index 7930f49..c5505e6 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h @@ -350,7 +350,6 @@ extern void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_lis
extern void set_error_routine ( void ( * routine )( const char * err , va_list params ));
extern void set_die_is_recursing_routine ( int ( * routine )( void ));
- extern int prefixcmp ( const char * str , const char * prefix );
extern int has_prefix ( const char * str , const char * prefix );
extern int has_suffix ( const char * str , const char * suffix );
diff --git a/strbuf.c b/strbuf.c
index 748be6d..199533c 100644
--- a/strbuf.c
+++ b/strbuf.c @@ -1,15 +1,6 @@
#include "cache.h"
#include "refs.h"
- int prefixcmp ( const char * str , const char * prefix )
- {
- for (; ; str ++ , prefix ++ )
- if ( !* prefix )
- return 0 ;
- else if ( * str != * prefix )
- return ( unsigned char ) * prefix - ( unsigned char ) * str ;
- }
-
int has_prefix ( const char * str , const char * prefix )
{
for (; ; str ++ , prefix ++ ) --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/shortlog.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index c226f76..3f35682 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c @@ -65,7 +65,7 @@ static void insert_one_record(struct shortlog *log,
eol = strchr ( oneline , '\n' );
if ( ! eol )
eol = oneline + strlen ( oneline );
- if ( ! prefixcmp ( oneline , "[PATCH" )) {
+ if ( has_prefix ( oneline , "[PATCH" )) {
char * eob = strchr ( oneline , ']' );
if ( eob && ( ! eol || eob < eol ))
oneline = eob + 1 ; @@ -95,7 +95,7 @@ static void read_from_stdin(struct shortlog *log)
while ( fgets ( author , sizeof ( author ), stdin ) != NULL ) {
if ( ! ( author [ 0 ] == 'A' || author [ 0 ] == 'a' ) ||
- prefixcmp ( author + 1 , "uthor: " ))
+ ! has_prefix ( author + 1 , "uthor: " ))
continue ;
while ( fgets ( oneline , sizeof ( oneline ), stdin ) &&
oneline [ 0 ] != '\n' ) @@ -123,7 +123,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
else
eol ++ ;
- if ( ! prefixcmp ( buffer , "author " ))
+ if ( has_prefix ( buffer , "author " ))
author = buffer + 7 ;
buffer = eol ;
} --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/rev-parse.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index c76b89d..b6c92e0 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c @@ -508,7 +508,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
}
continue ;
}
- if ( ! prefixcmp ( arg , "-n" )) {
+ if ( has_prefix ( arg , "-n" )) {
if (( filter & DO_FLAGS ) && ( filter & DO_REVS ))
show ( arg );
continue ; @@ -560,7 +560,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
continue ;
}
if ( ! strcmp ( arg , "--short" ) ||
- ! prefixcmp ( arg , "--short=" )) {
+ has_prefix ( arg , "--short=" )) {
filter &= ~ ( DO_FLAGS | DO_NOREV );
verify = 1 ;
abbrev = DEFAULT_ABBREV ; @@ -588,7 +588,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
symbolic = SHOW_SYMBOLIC_FULL ;
continue ;
}
- if ( ! prefixcmp ( arg , "--abbrev-ref" ) &&
+ if ( has_prefix ( arg , "--abbrev-ref" ) &&
( ! arg [ 12 ] || arg [ 12 ] == '=' )) {
abbrev_ref = 1 ;
abbrev_ref_strict = warn_ambiguous_refs ; @@ -606,7 +606,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
for_each_ref ( show_reference , NULL );
continue ;
}
- if ( ! prefixcmp ( arg , "--disambiguate=" )) {
+ if ( has_prefix ( arg , "--disambiguate=" )) {
for_each_abbrev ( arg + 15 , show_abbrev , NULL );
continue ;
} @@ -615,7 +615,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
for_each_ref_in ( "refs/bisect/good" , anti_reference , NULL );
continue ;
}
- if ( ! prefixcmp ( arg , "--branches=" )) {
+ if ( has_prefix ( arg , "--branches=" )) {
for_each_glob_ref_in ( show_reference , arg + 11 ,
"refs/heads/" , NULL );
continue ; @@ -624,7 +624,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
for_each_branch_ref ( show_reference , NULL );
continue ;
}
- if ( ! prefixcmp ( arg , "--tags=" )) {
+ if ( has_prefix ( arg , "--tags=" )) {
for_each_glob_ref_in ( show_reference , arg + 7 ,
"refs/tags/" , NULL );
continue ; @@ -633,11 +633,11 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
for_each_tag_ref ( show_reference , NULL );
continue ;
}
- if ( ! prefixcmp ( arg , "--glob=" )) {
+ if ( has_prefix ( arg , "--glob=" )) {
for_each_glob_ref ( show_reference , arg + 7 , NULL );
continue ;
}
- if ( ! prefixcmp ( arg , "--remotes=" )) {
+ if ( has_prefix ( arg , "--remotes=" )) {
for_each_glob_ref_in ( show_reference , arg + 10 ,
"refs/remotes/" , NULL );
continue ; @@ -724,19 +724,19 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
: "false" );
continue ;
}
- if ( ! prefixcmp ( arg , "--since=" )) {
+ if ( has_prefix ( arg , "--since=" )) {
show_datestring ( "--max-age=" , arg + 8 );
continue ;
}
- if ( ! prefixcmp ( arg , "--after=" )) {
+ if ( has_prefix ( arg , "--after=" )) {
show_datestring ( "--max-age=" , arg + 8 );
continue ;
}
- if ( ! prefixcmp ( arg , "--before=" )) {
+ if ( has_prefix ( arg , "--before=" )) {
show_datestring ( "--min-age=" , arg + 9 );
continue ;
}
- if ( ! prefixcmp ( arg , "--until=" )) {
+ if ( has_prefix ( arg , "--until=" )) {
show_datestring ( "--min-age=" , arg + 8 );
continue ;
} --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/remote.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/builtin/remote.c b/builtin/remote.c
index b9a1024..e45358c 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c @@ -261,7 +261,7 @@ static const char *abbrev_ref(const char *name, const char *prefix)
static int config_read_branches ( const char * key , const char * value , void * cb )
{
- if ( ! prefixcmp ( key , "branch." )) {
+ if ( has_prefix ( key , "branch." )) {
const char * orig_key = key ;
char * name ;
struct string_list_item * item ; @@ -526,9 +526,9 @@ static int add_branch_for_removal(const char *refname,
}
/* don't delete non-remote-tracking refs */
- if ( prefixcmp ( refname , "refs/remotes/" )) {
+ if ( ! has_prefix ( refname , "refs/remotes/" )) {
/* advise user how to delete local branches */
- if ( ! prefixcmp ( refname , "refs/heads/" ))
+ if ( has_prefix ( refname , "refs/heads/" ))
string_list_append ( branches -> skipped ,
abbrev_branch ( refname ));
/* silently skip over other non-remote refs */ @@ -563,7 +563,7 @@ static int read_remote_branches(const char *refname,
const char * symref ;
strbuf_addf ( & buf , "refs/remotes/%s/" , rename -> old );
- if ( ! prefixcmp ( refname , buf . buf )) {
+ if ( has_prefix ( refname , buf . buf )) {
item = string_list_append ( rename -> remote_branches , xstrdup ( refname ));
symref = resolve_ref_unsafe ( refname , orig_sha1 , 1 , & flag );
if ( flag & REF_ISSYMREF ) --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/reflog.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/reflog.c b/builtin/reflog.c
index 6eb24c8..f1a2578 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c @@ -610,12 +610,12 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
const char * arg = argv [ i ];
if ( ! strcmp ( arg , "--dry-run" ) || ! strcmp ( arg , "-n" ))
cb . dry_run = 1 ;
- else if ( ! prefixcmp ( arg , "--expire=" )) {
+ else if ( has_prefix ( arg , "--expire=" )) {
if ( parse_expiry_date ( arg + 9 , & cb . expire_total ))
die ( _ ( "'%s' is not a valid timestamp" ), arg );
explicit_expiry |= EXPIRE_TOTAL ;
}
- else if ( ! prefixcmp ( arg , "--expire-unreachable=" )) {
+ else if ( has_prefix ( arg , "--expire-unreachable=" )) {
if ( parse_expiry_date ( arg + 21 , & cb . expire_unreachable ))
die ( _ ( "'%s' is not a valid timestamp" ), arg );
explicit_expiry |= EXPIRE_UNREACH ; --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/upload-archive.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c
index af2da35..298bc76 100644
--- a/builtin/upload-archive.c
+++ b/builtin/upload-archive.c @@ -37,7 +37,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)
if ( sent_argv . argc > MAX_ARGS )
die ( "Too many options (>%d)" , MAX_ARGS - 1 );
- if ( prefixcmp ( buf , arg_cmd ))
+ if ( ! has_prefix ( buf , arg_cmd ))
die ( "'argument' token or flush expected" );
argv_array_push ( & sent_argv , buf + strlen ( arg_cmd ));
} --
1.8.4.1.566.geca833c
Signed-off-by: Christian Couder <redacted>
---
builtin/show-branch.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 001f29c..dc0b406 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c @@ -285,7 +285,7 @@ static void show_one_commit(struct commit *commit, int no_name)
pp_commit_easy ( CMIT_FMT_ONELINE , commit , & pretty );
pretty_str = pretty . buf ;
}
- if ( ! prefixcmp ( pretty_str , "[PATCH] " ))
+ if ( has_prefix ( pretty_str , "[PATCH] " ))
pretty_str += 8 ;
if ( ! no_name ) { @@ -396,7 +396,7 @@ static int append_head_ref(const char *refname, const unsigned char *sha1, int f
{
unsigned char tmp [ 20 ];
int ofs = 11 ;
- if ( prefixcmp ( refname , "refs/heads/" ))
+ if ( ! has_prefix ( refname , "refs/heads/" ))
return 0 ;
/* If both heads/foo and tags/foo exists, get_sha1 would
* get confused . @@ -410,7 +410,7 @@ static int append_remote_ref(const char *refname, const unsigned char *sha1, int
{
unsigned char tmp [ 20 ];
int ofs = 13 ;
- if ( prefixcmp ( refname , "refs/remotes/" ))
+ if ( ! has_prefix ( refname , "refs/remotes/" ))
return 0 ;
/* If both heads/foo and tags/foo exists, get_sha1 would
* get confused . @@ -422,7 +422,7 @@ static int append_remote_ref(const char *refname, const unsigned char *sha1, int
static int append_tag_ref ( const char * refname , const unsigned char * sha1 , int flag , void * cb_data )
{
- if ( prefixcmp ( refname , "refs/tags/" ))
+ if ( ! has_prefix ( refname , "refs/tags/" ))
return 0 ;
return append_ref ( refname + 5 , sha1 , 0 );
} @@ -453,9 +453,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 ( has_prefix ( refname , "refs/heads/" ))
return append_head_ref ( refname , sha1 , flag , cb_data );
- if ( ! prefixcmp ( refname , "refs/tags/" ))
+ if ( has_prefix ( refname , "refs/tags/" ))
return append_tag_ref ( refname , sha1 , flag , cb_data );
return append_ref ( refname , sha1 , 0 );
} @@ -480,11 +480,11 @@ static int rev_is_head(char *head, int headlen, char *name,
if (( ! head [ 0 ]) ||
( head_sha1 && sha1 && hashcmp ( head_sha1 , sha1 )))
return 0 ;
- if ( ! prefixcmp ( head , "refs/heads/" ))
+ if ( has_prefix ( head , "refs/heads/" ))
head += 11 ;
- if ( ! prefixcmp ( name , "refs/heads/" ))
+ if ( has_prefix ( name , "refs/heads/" ))
name += 11 ;
- else if ( ! prefixcmp ( name , "heads/" ))
+ else if ( has_prefix ( name , "heads/" ))
name += 6 ;
return ! strcmp ( head , name );
} @@ -813,7 +813,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
has_head ++ ;
}
if ( ! has_head ) {
- int offset = ! prefixcmp ( head , "refs/heads/" ) ? 11 : 0 ;
+ int offset = has_prefix ( head , "refs/heads/" ) ? 11 : 0 ;
append_one_rev ( head + offset );
}
} --
1.8.4.1.566.geca833c