summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c13
-rw-r--r--src/buffer.h2
-rw-r--r--src/pathspec.c2
3 files changed, 9 insertions, 8 deletions
diff --git a/src/buffer.c b/src/buffer.c
index a57df1284..fe087ea11 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1201,25 +1201,26 @@ int git_buf_lf_to_crlf(git_buf *tgt, const git_buf *src)
return git_buf_put(tgt, scan, end - scan);
}
-int git_buf_common_prefix(git_buf *buf, const git_strarray *strings)
+int git_buf_common_prefix(git_buf *buf, char *const *const strings, size_t count)
{
size_t i;
const char *str, *pfx;
git_buf_clear(buf);
- if (!strings || !strings->count)
+ if (!strings || !count)
return 0;
/* initialize common prefix to first string */
- if (git_buf_sets(buf, strings->strings[0]) < 0)
+ if (git_buf_sets(buf, strings[0]) < 0)
return -1;
/* go through the rest of the strings, truncating to shared prefix */
- for (i = 1; i < strings->count; ++i) {
+ for (i = 1; i < count; ++i) {
- for (str = strings->strings[i], pfx = buf->ptr;
- *str && *str == *pfx; str++, pfx++)
+ for (str = strings[i], pfx = buf->ptr;
+ *str && *str == *pfx;
+ str++, pfx++)
/* scanning */;
git_buf_truncate(buf, pfx - buf->ptr);
diff --git a/src/buffer.h b/src/buffer.h
index a356bebea..75930e209 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -324,7 +324,7 @@ extern int git_buf_lf_to_crlf(git_buf *tgt, const git_buf *src);
*
* Buffer will be set to empty if there is no common prefix
*/
-extern int git_buf_common_prefix(git_buf *buf, const git_strarray *strs);
+extern int git_buf_common_prefix(git_buf *buf, char *const *const strings, size_t count);
/**
* Check if a buffer begins with a UTF BOM
diff --git a/src/pathspec.c b/src/pathspec.c
index 8f1bdf0fa..c6ad16571 100644
--- a/src/pathspec.c
+++ b/src/pathspec.c
@@ -24,7 +24,7 @@ char *git_pathspec_prefix(const git_strarray *pathspec)
const char *scan;
if (!pathspec || !pathspec->count ||
- git_buf_common_prefix(&prefix, pathspec) < 0)
+ git_buf_common_prefix(&prefix, pathspec->strings, pathspec->count) < 0)
return NULL;
/* diff prefix will only be leading non-wildcards */