mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 20:42:23 +00:00
Document git_buf_common_prefix
This function fills in a git_buf with the common prefix of an array of strings, but let's make that a little more clear.
This commit is contained in:
parent
58ffeb9cde
commit
2c83391728
@ -426,10 +426,13 @@ int git_buf_common_prefix(git_buf *buf, const git_strarray *strings)
|
|||||||
if (!strings || !strings->count)
|
if (!strings || !strings->count)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
/* initialize common prefix to first string */
|
||||||
if (git_buf_sets(buf, strings->strings[0]) < 0)
|
if (git_buf_sets(buf, strings->strings[0]) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
/* go through the rest of the strings, truncating to shared prefix */
|
||||||
for (i = 1; i < strings->count; ++i) {
|
for (i = 1; i < strings->count; ++i) {
|
||||||
|
|
||||||
for (str = strings->strings[i], pfx = buf->ptr;
|
for (str = strings->strings[i], pfx = buf->ptr;
|
||||||
*str && *str == *pfx; str++, pfx++)
|
*str && *str == *pfx; str++, pfx++)
|
||||||
/* scanning */;
|
/* scanning */;
|
||||||
|
@ -122,6 +122,7 @@ void git_buf_rtrim(git_buf *buf);
|
|||||||
|
|
||||||
int git_buf_cmp(const git_buf *a, const git_buf *b);
|
int git_buf_cmp(const git_buf *a, const git_buf *b);
|
||||||
|
|
||||||
|
/* Fill buf with the common prefix of a array of strings */
|
||||||
int git_buf_common_prefix(git_buf *buf, const git_strarray *strings);
|
int git_buf_common_prefix(git_buf *buf, const git_strarray *strings);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user