Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
b78fb64d
Commit
b78fb64d
authored
Apr 10, 2012
by
nulltoken
Committed by
Vicent Martí
Apr 11, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
repository: make git_repository_set_workdir() prettify the path it is being passed
parent
dcfdb958
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
3 deletions
+40
-3
src/repository.c
+6
-3
tests-clar/repo/setters.c
+34
-0
No files found.
src/repository.c
View file @
b78fb64d
...
...
@@ -871,13 +871,16 @@ const char *git_repository_workdir(git_repository *repo)
int
git_repository_set_workdir
(
git_repository
*
repo
,
const
char
*
workdir
)
{
git_buf
path
=
GIT_BUF_INIT
;
assert
(
repo
&&
workdir
);
free
(
repo
->
workdir
);
if
(
git_path_prettify_dir
(
&
path
,
workdir
,
NULL
)
<
0
)
return
-
1
;
repo
->
workdir
=
git__strdup
(
workdir
);
GITERR_CHECK_ALLOC
(
repo
->
workdir
);
free
(
repo
->
workdir
);
repo
->
workdir
=
git_buf_detach
(
&
path
);
repo
->
is_bare
=
0
;
return
0
;
}
...
...
tests-clar/repo/setters.c
0 → 100644
View file @
b78fb64d
#include "clar_libgit2.h"
#include "buffer.h"
static
git_repository
*
repo
;
void
test_repo_setters__initialize
(
void
)
{
cl_fixture_sandbox
(
"testrepo.git"
);
cl_git_pass
(
git_repository_open
(
&
repo
,
"testrepo.git"
));
}
void
test_repo_setters__cleanup
(
void
)
{
git_repository_free
(
repo
);
cl_fixture_cleanup
(
"testrepo.git"
);
}
void
test_repo_setters__setting_a_workdir_turns_a_bare_repository_into_a_standard_one
(
void
)
{
cl_assert
(
git_repository_is_bare
(
repo
)
==
1
);
cl_assert
(
git_repository_workdir
(
repo
)
==
NULL
);
cl_git_pass
(
git_repository_set_workdir
(
repo
,
"./new_workdir"
));
cl_assert
(
git_repository_workdir
(
repo
)
!=
NULL
);
cl_assert
(
git_repository_is_bare
(
repo
)
==
0
);
}
void
test_repo_setters__setting_a_workdir_prettifies_its_path
(
void
)
{
cl_git_pass
(
git_repository_set_workdir
(
repo
,
"./new_workdir"
));
cl_assert
(
git__suffixcmp
(
git_repository_workdir
(
repo
),
"/"
)
==
0
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment