Skip to content

Commit a1ad0eb

Browse files
peffgitster
authored andcommitted
sha1_name: refactor upstream_mark
We will be adding new mark types in the future, so separate the suffix data from the logic. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e291c75 commit a1ad0eb

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

sha1_name.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,12 +415,12 @@ static int ambiguous_path(const char *path, int len)
415415
return slash;
416416
}
417417

418-
static inline int upstream_mark(const char *string, int len)
418+
static inline int at_mark(const char *string, int len,
419+
const char **suffix, int nr)
419420
{
420-
const char *suffix[] = { "@{upstream}", "@{u}" };
421421
int i;
422422

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

432+
static inline int upstream_mark(const char *string, int len)
433+
{
434+
const char *suffix[] = { "@{upstream}", "@{u}" };
435+
return at_mark(string, len, suffix, ARRAY_SIZE(suffix));
436+
}
437+
432438
static int get_sha1_1(const char *name, int len, unsigned char *sha1, unsigned lookup_flags);
433439
static int interpret_nth_prior_checkout(const char *name, int namelen, struct strbuf *buf);
434440

0 commit comments

Comments
 (0)