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
8212e2d7
Commit
8212e2d7
authored
Feb 07, 2011
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix detection of working dir on repositories
Signed-off-by: Vicent Marti <tanoku@gmail.com>
parent
9d1dcca2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
4 deletions
+30
-4
src/repository.c
+30
-4
No files found.
src/repository.c
View file @
8212e2d7
...
@@ -111,6 +111,8 @@ static int assign_repository_DIRs(git_repository *repo,
...
@@ -111,6 +111,8 @@ static int assign_repository_DIRs(git_repository *repo,
/* store GIT_DIR */
/* store GIT_DIR */
repo
->
path_repository
=
git__strdup
(
path_aux
);
repo
->
path_repository
=
git__strdup
(
path_aux
);
if
(
repo
->
path_repository
==
NULL
)
return
GIT_ENOMEM
;
/* store GIT_OBJECT_DIRECTORY */
/* store GIT_OBJECT_DIRECTORY */
if
(
git_object_directory
==
NULL
)
if
(
git_object_directory
==
NULL
)
...
@@ -125,7 +127,8 @@ static int assign_repository_DIRs(git_repository *repo,
...
@@ -125,7 +127,8 @@ static int assign_repository_DIRs(git_repository *repo,
return
GIT_ENOTFOUND
;
return
GIT_ENOTFOUND
;
repo
->
path_odb
=
git__strdup
(
path_aux
);
repo
->
path_odb
=
git__strdup
(
path_aux
);
if
(
repo
->
path_odb
==
NULL
)
return
GIT_ENOMEM
;
/* store GIT_INDEX_FILE */
/* store GIT_INDEX_FILE */
if
(
git_index_file
==
NULL
)
if
(
git_index_file
==
NULL
)
...
@@ -140,7 +143,8 @@ static int assign_repository_DIRs(git_repository *repo,
...
@@ -140,7 +143,8 @@ static int assign_repository_DIRs(git_repository *repo,
return
GIT_ENOTFOUND
;
return
GIT_ENOTFOUND
;
repo
->
path_index
=
git__strdup
(
path_aux
);
repo
->
path_index
=
git__strdup
(
path_aux
);
if
(
repo
->
path_index
==
NULL
)
return
GIT_ENOMEM
;
/* store GIT_WORK_TREE */
/* store GIT_WORK_TREE */
if
(
git_work_tree
==
NULL
)
if
(
git_work_tree
==
NULL
)
...
@@ -150,6 +154,8 @@ static int assign_repository_DIRs(git_repository *repo,
...
@@ -150,6 +154,8 @@ static int assign_repository_DIRs(git_repository *repo,
if
(
error
<
GIT_SUCCESS
)
if
(
error
<
GIT_SUCCESS
)
return
error
;
return
error
;
repo
->
path_workdir
=
git__strdup
(
path_aux
);
repo
->
path_workdir
=
git__strdup
(
path_aux
);
if
(
repo
->
path_workdir
==
NULL
)
return
GIT_ENOMEM
;
}
}
return
GIT_SUCCESS
;
return
GIT_SUCCESS
;
...
@@ -173,12 +179,16 @@ static int guess_repository_DIRs(git_repository *repo, const char *repository_pa
...
@@ -173,12 +179,16 @@ static int guess_repository_DIRs(git_repository *repo, const char *repository_pa
path_len
=
strlen
(
path_aux
);
path_len
=
strlen
(
path_aux
);
repo
->
path_repository
=
git__strdup
(
path_aux
);
repo
->
path_repository
=
git__strdup
(
path_aux
);
if
(
repo
->
path_repository
==
NULL
)
return
GIT_ENOMEM
;
/* objects database */
/* objects database */
strcpy
(
path_aux
+
path_len
,
GIT_OBJECTS_DIR
);
strcpy
(
path_aux
+
path_len
,
GIT_OBJECTS_DIR
);
if
(
gitfo_isdir
(
path_aux
)
<
GIT_SUCCESS
)
if
(
gitfo_isdir
(
path_aux
)
<
GIT_SUCCESS
)
return
GIT_ENOTAREPO
;
return
GIT_ENOTAREPO
;
repo
->
path_odb
=
git__strdup
(
path_aux
);
repo
->
path_odb
=
git__strdup
(
path_aux
);
if
(
repo
->
path_odb
==
NULL
)
return
GIT_ENOMEM
;
/* HEAD file */
/* HEAD file */
strcpy
(
path_aux
+
path_len
,
GIT_HEAD_FILE
);
strcpy
(
path_aux
+
path_len
,
GIT_HEAD_FILE
);
...
@@ -191,17 +201,31 @@ static int guess_repository_DIRs(git_repository *repo, const char *repository_pa
...
@@ -191,17 +201,31 @@ static int guess_repository_DIRs(git_repository *repo, const char *repository_pa
return
GIT_EINVALIDPATH
;
return
GIT_EINVALIDPATH
;
if
(
strcmp
(
topdir
,
GIT_DIR
)
==
0
)
{
if
(
strcmp
(
topdir
,
GIT_DIR
)
==
0
)
{
int
workdir_len
;
repo
->
is_bare
=
0
;
repo
->
is_bare
=
0
;
/* index file */
/* index file */
strcpy
(
path_aux
+
path_len
,
GIT_INDEX_FILE
);
strcpy
(
path_aux
+
path_len
,
GIT_INDEX_FILE
);
repo
->
path_index
=
git__strdup
(
path_aux
);
repo
->
path_index
=
git__strdup
(
path_aux
);
if
(
repo
->
path_index
==
NULL
)
return
GIT_ENOMEM
;
/* working dir */
/* working dir */
repo
->
path_workdir
=
git__dirname
(
path_aux
);
path_aux
[
path_len
]
=
0
;
if
(
repo
->
path_workdir
==
NULL
)
workdir_len
=
git__dirname_r
(
path_aux
,
GIT_PATH_MAX
,
path_aux
);
if
(
workdir_len
<
0
)
return
GIT_EINVALIDPATH
;
return
GIT_EINVALIDPATH
;
if
(
path_aux
[
workdir_len
-
1
]
!=
'/'
)
{
path_aux
[
workdir_len
]
=
'/'
;
path_aux
[
workdir_len
+
1
]
=
'\0'
;
}
repo
->
path_workdir
=
git__strdup
(
path_aux
);
if
(
repo
->
path_workdir
==
NULL
)
return
GIT_ENOMEM
;
}
else
{
}
else
{
repo
->
is_bare
=
1
;
repo
->
is_bare
=
1
;
repo
->
path_workdir
=
NULL
;
repo
->
path_workdir
=
NULL
;
...
@@ -611,6 +635,8 @@ static int repo_init_find_dir(repo_init *results, const char* path)
...
@@ -611,6 +635,8 @@ static int repo_init_find_dir(repo_init *results, const char* path)
return
GIT_ENOTAREPO
;
return
GIT_ENOTAREPO
;
results
->
path_repository
=
git__strdup
(
temp_path
);
results
->
path_repository
=
git__strdup
(
temp_path
);
if
(
results
->
path_repository
==
NULL
)
return
GIT_ENOMEM
;
return
GIT_SUCCESS
;
return
GIT_SUCCESS
;
}
}
...
...
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