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
34dfea27
Commit
34dfea27
authored
Jun 24, 2011
by
Jason Penny
Committed by
Vicent Marti
Jul 09, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
status: handle subdirs for git_status_file
parent
6b251490
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
8 deletions
+41
-8
src/status.c
+30
-7
tests/t18-status.c
+11
-1
No files found.
src/status.c
View file @
34dfea27
...
@@ -152,6 +152,35 @@ static void recurse_tree_entries(git_tree *tree, git_vector *entries, char *path
...
@@ -152,6 +152,35 @@ static void recurse_tree_entries(git_tree *tree, git_vector *entries, char *path
git_tree_close
(
tree
);
git_tree_close
(
tree
);
}
}
static
void
recurse_tree_entry
(
git_tree
*
tree
,
struct
status_entry
*
e
,
const
char
*
path
)
{
char
*
dir_sep
;
char
buffer
[
GIT_PATH_MAX
];
const
git_tree_entry
*
tree_entry
;
git_tree
*
subtree
;
strcpy
(
buffer
,
path
);
dir_sep
=
strchr
(
buffer
,
'/'
);
if
(
dir_sep
)
{
*
dir_sep
=
'\0'
;
tree_entry
=
git_tree_entry_byname
(
tree
,
buffer
);
if
(
tree_entry
!=
NULL
)
{
if
(
git_tree_lookup
(
&
subtree
,
tree
->
object
.
repo
,
&
tree_entry
->
oid
)
==
GIT_SUCCESS
)
{
recurse_tree_entry
(
subtree
,
e
,
dir_sep
+
1
);
return
;
}
}
}
tree_entry
=
git_tree_entry_byname
(
tree
,
path
);
if
(
tree_entry
!=
NULL
)
{
git_oid_cpy
(
&
e
->
head_oid
,
&
tree_entry
->
oid
);
}
git_tree_close
(
tree
);
}
static
int
workdir_path_len
;
static
int
workdir_path_len
;
static
int
dirent_cb
(
void
*
state
,
char
*
full_path
)
static
int
dirent_cb
(
void
*
state
,
char
*
full_path
)
{
{
...
@@ -320,7 +349,6 @@ int git_status_file(unsigned int *status_flags, git_repository *repo, const char
...
@@ -320,7 +349,6 @@ int git_status_file(unsigned int *status_flags, git_repository *repo, const char
git_tree
*
tree
;
git_tree
*
tree
;
git_reference
*
head_ref
,
*
resolved_head_ref
;
git_reference
*
head_ref
,
*
resolved_head_ref
;
git_commit
*
head_commit
;
git_commit
*
head_commit
;
const
git_tree_entry
*
tree_entry
;
assert
(
status_flags
);
assert
(
status_flags
);
...
@@ -342,12 +370,7 @@ int git_status_file(unsigned int *status_flags, git_repository *repo, const char
...
@@ -342,12 +370,7 @@ int git_status_file(unsigned int *status_flags, git_repository *repo, const char
git_commit_lookup
(
&
head_commit
,
repo
,
git_reference_oid
(
resolved_head_ref
));
git_commit_lookup
(
&
head_commit
,
repo
,
git_reference_oid
(
resolved_head_ref
));
git_commit_tree
(
&
tree
,
head_commit
);
git_commit_tree
(
&
tree
,
head_commit
);
// TODO: handle subdirectories by walking into subtrees
recurse_tree_entry
(
tree
,
e
,
path
);
tree_entry
=
git_tree_entry_byname
(
tree
,
path
);
if
(
tree_entry
!=
NULL
)
{
git_oid_cpy
(
&
e
->
head_oid
,
&
tree_entry
->
oid
);
}
git_tree_close
(
tree
);
// Find file in Workdir
// Find file in Workdir
workdir_path_len
=
strlen
(
repo
->
path_workdir
);
workdir_path_len
=
strlen
(
repo
->
path_workdir
);
...
...
tests/t18-status.c
View file @
34dfea27
...
@@ -68,6 +68,11 @@ static const char *entry_paths[] = {
...
@@ -68,6 +68,11 @@ static const char *entry_paths[] = {
"staged_new_file"
,
"staged_new_file"
,
"staged_new_file_deleted_file"
,
"staged_new_file_deleted_file"
,
"staged_new_file_modified_file"
,
"staged_new_file_modified_file"
,
"subdir/current_file"
,
"subdir/deleted_file"
,
"subdir/modified_file"
,
"subdir/new_file"
,
};
};
static
const
unsigned
int
entry_statuses
[]
=
{
static
const
unsigned
int
entry_statuses
[]
=
{
GIT_STATUS_CURRENT
,
GIT_STATUS_CURRENT
,
...
@@ -82,8 +87,13 @@ static const unsigned int entry_statuses[] = {
...
@@ -82,8 +87,13 @@ static const unsigned int entry_statuses[] = {
GIT_STATUS_INDEX_NEW
,
GIT_STATUS_INDEX_NEW
,
GIT_STATUS_INDEX_NEW
|
GIT_STATUS_WT_DELETED
,
GIT_STATUS_INDEX_NEW
|
GIT_STATUS_WT_DELETED
,
GIT_STATUS_INDEX_NEW
|
GIT_STATUS_WT_MODIFIED
,
GIT_STATUS_INDEX_NEW
|
GIT_STATUS_WT_MODIFIED
,
GIT_STATUS_CURRENT
,
GIT_STATUS_WT_DELETED
,
GIT_STATUS_WT_MODIFIED
,
GIT_STATUS_WT_NEW
,
};
};
#define ENTRY_COUNT 1
2
#define ENTRY_COUNT 1
6
static
unsigned
int
get_expected_entry_status
(
const
char
*
path
)
static
unsigned
int
get_expected_entry_status
(
const
char
*
path
)
{
{
...
...
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