refs: add expand_ref()
This is basically dwim_ref() without @{} support. To be used on the
server side where we want to expand abbreviated to full ref names and
nothing else. The first user is "git clone/fetch --shallow-exclude".
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
6d43a0cefd
commit
41da7111f2
8
refs.c
8
refs.c
@ -392,6 +392,13 @@ static char *substitute_branch_name(const char **string, int *len)
|
||||
int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)
|
||||
{
|
||||
char *last_branch = substitute_branch_name(&str, &len);
|
||||
int refs_found = expand_ref(str, len, sha1, ref);
|
||||
free(last_branch);
|
||||
return refs_found;
|
||||
}
|
||||
|
||||
int expand_ref(const char *str, int len, unsigned char *sha1, char **ref)
|
||||
{
|
||||
const char **p, *r;
|
||||
int refs_found = 0;
|
||||
|
||||
@ -417,7 +424,6 @@ int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)
|
||||
warning("ignoring broken ref %s.", fullref);
|
||||
}
|
||||
}
|
||||
free(last_branch);
|
||||
return refs_found;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user