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
602ee38b
Commit
602ee38b
authored
Jun 04, 2011
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
repository: Export all internal paths
parent
793545ef
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
20 deletions
+39
-20
include/git2/repository.h
+18
-9
src/repository.c
+17
-7
tests/t12-repo.c
+4
-4
No files found.
include/git2/repository.h
View file @
602ee38b
...
...
@@ -231,22 +231,31 @@ GIT_EXTERN(int) git_repository_init(git_repository **repo_out, const char *path,
GIT_EXTERN
(
int
)
git_repository_is_empty
(
git_repository
*
repo
);
/**
* Get the normalized path to the git repository.
*
* @param repo a repository object
* @return absolute path to the git directory
* Internal path identifiers for a repository
*/
GIT_EXTERN
(
const
char
*
)
git_repository_path
(
git_repository
*
repo
);
typedef
enum
{
GIT_REPO_PATH
,
GIT_REPO_PATH_INDEX
,
GIT_REPO_PATH_ODB
,
GIT_REPO_PATH_WORKDIR
}
git_repository_pathid
;
/**
* Get the normalized path to the working directory of the repository.
* Get one of the paths to the repository
*
* Possible values for `id`:
*
* If the repository is bare, there is no working directory and NULL we be returned.
* GIT_REPO_PATH: return the path to the repository
* GIT_REPO_PATH_INDEX: return the path to the index
* GIT_REPO_PATH_ODB: return the path to the ODB
* GIT_REPO_PATH_WORKDIR: return the path to the working
* directory
*
* @param repo a repository object
* @return NULL if the repository is bare; absolute path to the working directory otherwise.
* @param id The ID of the path to return
* @return absolute path of the requested id
*/
GIT_EXTERN
(
const
char
*
)
git_repository_
workdir
(
git_repository
*
repo
);
GIT_EXTERN
(
const
char
*
)
git_repository_
path
(
git_repository
*
repo
,
git_repository_pathid
id
);
/**
* Check if a repository is bare
...
...
src/repository.c
View file @
602ee38b
...
...
@@ -721,16 +721,26 @@ int git_repository_is_empty(git_repository *repo)
return
git_reference_resolve
(
&
branch
,
head
)
==
GIT_SUCCESS
?
0
:
1
;
}
const
char
*
git_repository_path
(
git_repository
*
repo
)
const
char
*
git_repository_path
(
git_repository
*
repo
,
git_repository_pathid
id
)
{
assert
(
repo
);
return
repo
->
path_repository
;
}
const
char
*
git_repository_workdir
(
git_repository
*
repo
)
{
assert
(
repo
);
return
repo
->
path_workdir
;
switch
(
id
)
{
case
GIT_REPO_PATH
:
return
repo
->
path_repository
;
case
GIT_REPO_PATH_INDEX
:
return
repo
->
path_index
;
case
GIT_REPO_PATH_ODB
:
return
repo
->
path_odb
;
case
GIT_REPO_PATH_WORKDIR
:
return
repo
->
path_workdir
;
default:
return
NULL
;
}
}
int
git_repository_is_bare
(
git_repository
*
repo
)
...
...
tests/t12-repo.c
View file @
602ee38b
...
...
@@ -201,8 +201,8 @@ BEGIN_TEST(open0, "Open a bare repository that has just been initialized by git"
must_pass
(
remove_placeholders
(
TEMP_REPO_FOLDER
,
"dummy-marker.txt"
));
must_pass
(
git_repository_open
(
&
repo
,
TEMP_REPO_FOLDER
));
must_be_true
(
git_repository_path
(
repo
)
!=
NULL
);
must_be_true
(
git_repository_
workdir
(
repo
)
==
NULL
);
must_be_true
(
git_repository_path
(
repo
,
GIT_REPO_PATH
)
!=
NULL
);
must_be_true
(
git_repository_
path
(
repo
,
GIT_REPO_PATH_WORKDIR
)
==
NULL
);
git_repository_free
(
repo
);
must_pass
(
rmdir_recurs
(
TEMP_REPO_FOLDER
));
...
...
@@ -220,8 +220,8 @@ BEGIN_TEST(open1, "Open a standard repository that has just been initialized by
must_pass
(
remove_placeholders
(
DEST_REPOSITORY_FOLDER
,
"dummy-marker.txt"
));
must_pass
(
git_repository_open
(
&
repo
,
DEST_REPOSITORY_FOLDER
));
must_be_true
(
git_repository_path
(
repo
)
!=
NULL
);
must_be_true
(
git_repository_
workdir
(
repo
)
!=
NULL
);
must_be_true
(
git_repository_path
(
repo
,
GIT_REPO_PATH
)
!=
NULL
);
must_be_true
(
git_repository_
path
(
repo
,
GIT_REPO_PATH_WORKDIR
)
!=
NULL
);
git_repository_free
(
repo
);
must_pass
(
rmdir_recurs
(
TEMP_REPO_FOLDER
));
...
...
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