Skip to content

Commit 2cfa31c

Browse files
committed
path: remove unused git_path_topdir
1 parent 1a72462 commit 2cfa31c

File tree

3 files changed

+1
-47
lines changed

3 files changed

+1
-47
lines changed

src/path.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -274,24 +274,6 @@ size_t git_path_basename_offset(git_buf *buffer)
274274
return 0;
275275
}
276276

277-
const char *git_path_topdir(const char *path)
278-
{
279-
size_t len;
280-
ssize_t i;
281-
282-
assert(path);
283-
len = strlen(path);
284-
285-
if (!len || path[len - 1] != '/')
286-
return NULL;
287-
288-
for (i = (ssize_t)len - 2; i >= 0; --i)
289-
if (path[i] == '/')
290-
break;
291-
292-
return &path[i + 1];
293-
}
294-
295277
int git_path_root(const char *path)
296278
{
297279
int offset = 0, prefix_len;

src/path.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ extern int git_path_basename_r(git_buf *buffer, const char *path);
6767
*/
6868
extern size_t git_path_basename_offset(git_buf *buffer);
6969

70-
extern const char *git_path_topdir(const char *path);
71-
7270
/**
7371
* Find offset to root of path if path has one.
7472
*

tests/core/path.c

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@ check_basename(const char *A, const char *B)
3131
git__free(base2);
3232
}
3333

34-
static void
35-
check_topdir(const char *A, const char *B)
36-
{
37-
const char *dir;
38-
39-
cl_assert((dir = git_path_topdir(A)) != NULL);
40-
cl_assert_equal_s(B, dir);
41-
}
42-
4334
static void
4435
check_joinpath(const char *path_a, const char *path_b, const char *expected_path)
4536
{
@@ -119,23 +110,6 @@ void test_core_path__01_basename(void)
119110
check_basename(REP1024("/abc"), "abc");
120111
}
121112

122-
/* get the latest component in a path */
123-
void test_core_path__02_topdir(void)
124-
{
125-
check_topdir(".git/", ".git/");
126-
check_topdir("/.git/", ".git/");
127-
check_topdir("usr/local/.git/", ".git/");
128-
check_topdir("./.git/", ".git/");
129-
check_topdir("/usr/.git/", ".git/");
130-
check_topdir("/", "/");
131-
check_topdir("a/", "a/");
132-
133-
cl_assert(git_path_topdir("/usr/.git") == NULL);
134-
cl_assert(git_path_topdir(".") == NULL);
135-
cl_assert(git_path_topdir("") == NULL);
136-
cl_assert(git_path_topdir("a") == NULL);
137-
}
138-
139113
/* properly join path components */
140114
void test_core_path__05_joins(void)
141115
{
@@ -285,7 +259,7 @@ void test_core_path__08_self_join(void)
285259
cl_git_pass(git_buf_joinpath(&path, path.ptr + 4, "somethinglongenoughtorealloc"));
286260
cl_assert_equal_s(path.ptr, "/baz/somethinglongenoughtorealloc");
287261
cl_assert(asize < path.asize);
288-
262+
289263
git_buf_dispose(&path);
290264
}
291265

0 commit comments

Comments
 (0)