Skip to content

Commit

Permalink
sha1_name: refactor upstream_mark
Browse files Browse the repository at this point in the history
We will be adding new mark types in the future, so separate
the suffix data from the logic.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed May 22, 2015
1 parent e291c75 commit a1ad0eb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions sha1_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,12 +415,12 @@ static int ambiguous_path(const char *path, int len)
return slash;
}

static inline int upstream_mark(const char *string, int len)
static inline int at_mark(const char *string, int len,
const char **suffix, int nr)
{
const char *suffix[] = { "@{upstream}", "@{u}" };
int i;

for (i = 0; i < ARRAY_SIZE(suffix); i++) {
for (i = 0; i < nr; i++) {
int suffix_len = strlen(suffix[i]);
if (suffix_len <= len
&& !memcmp(string, suffix[i], suffix_len))
Expand All @@ -429,6 +429,12 @@ static inline int upstream_mark(const char *string, int len)
return 0;
}

static inline int upstream_mark(const char *string, int len)
{
const char *suffix[] = { "@{upstream}", "@{u}" };
return at_mark(string, len, suffix, ARRAY_SIZE(suffix));
}

static int get_sha1_1(const char *name, int len, unsigned char *sha1, unsigned lookup_flags);
static int interpret_nth_prior_checkout(const char *name, int namelen, struct strbuf *buf);

Expand Down

0 comments on commit a1ad0eb

Please sign in to comment.