summaryrefslogtreecommitdiff
path: root/wt-status.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-12-17 19:47:35 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-12-17 20:02:44 (GMT)
commitad7044857660af7ffaaf8fbbccc77b817d1b938f (patch)
treeb77a7390dbbc1901e13d74c1738f327e5fa8154d /wt-status.c
parent14a9c5f261bcc436b80700076257f02af0beec68 (diff)
parent59556548230e617b837343c2c07e357e688e2ca4 (diff)
downloadgit-ad7044857660af7ffaaf8fbbccc77b817d1b938f.zip
git-ad7044857660af7ffaaf8fbbccc77b817d1b938f.tar.gz
git-ad7044857660af7ffaaf8fbbccc77b817d1b938f.tar.bz2
Merge branch 'cc/starts-n-ends-with'
Remove a few duplicate implementations of prefix/suffix comparison functions, and rename them to starts_with and ends_with. * cc/starts-n-ends-with: replace {pre,suf}fixcmp() with {starts,ends}_with() strbuf: introduce starts_with() and ends_with() builtin/remote: remove postfixcmp() and use suffixcmp() instead environment: normalize use of prefixcmp() by removing " != 0"
Diffstat (limited to 'wt-status.c')
-rw-r--r--wt-status.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/wt-status.c b/wt-status.c
index cd7d706..4e55810 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -854,7 +854,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 (!starts_with(s->branch, "refs/heads/"))
return;
branch = branch_get(s->branch + 11);
if (!format_tracking_info(branch, &sb))
@@ -1113,9 +1113,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 (starts_with(sb.buf, "refs/heads/"))
strbuf_remove(&sb,0, strlen("refs/heads/"));
- else if (!prefixcmp(sb.buf, "refs/"))
+ else if (starts_with(sb.buf, "refs/"))
;
else if (!get_sha1_hex(sb.buf, sha1)) {
const char *abbrev;
@@ -1145,7 +1145,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 (!starts_with(message, "checkout: moving from "))
return 0;
message += strlen("checkout: moving from ");
target = strstr(message, " to ");
@@ -1180,9 +1180,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 (starts_with(ref, "refs/tags/"))
ofs = strlen("refs/tags/");
- else if (!prefixcmp(ref, "refs/remotes/"))
+ else if (starts_with(ref, "refs/remotes/"))
ofs = strlen("refs/remotes/");
else
ofs = 0;
@@ -1271,7 +1271,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 (starts_with(branch_name, "refs/heads/"))
branch_name += 11;
else if (!strcmp(branch_name, "HEAD")) {
branch_status_color = color(WT_STATUS_NOBRANCH, s);
@@ -1472,7 +1472,7 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
return;
branch_name = s->branch;
- if (!prefixcmp(branch_name, "refs/heads/"))
+ if (starts_with(branch_name, "refs/heads/"))
branch_name += 11;
else if (!strcmp(branch_name, "HEAD")) {
branch_name = _("HEAD (no branch)");