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
75261421
Commit
75261421
authored
Jul 04, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refs: add git_reference_has_log()
parent
b6bfd96f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
0 deletions
+44
-0
include/git2/refs.h
+10
-0
src/refs.c
+17
-0
tests-clar/refs/reflog.c
+17
-0
No files found.
include/git2/refs.h
View file @
75261421
...
@@ -353,6 +353,16 @@ GIT_EXTERN(int) git_reference_foreach_glob(
...
@@ -353,6 +353,16 @@ GIT_EXTERN(int) git_reference_foreach_glob(
void
*
payload
void
*
payload
);
);
/**
* Check if a reflog exists for the specified reference.
*
* @param ref A git reference
*
* @return 0 when no reflog can be found, 1 when it exists;
* otherwise an error code.
*/
GIT_EXTERN
(
int
)
git_reference_has_log
(
git_reference
*
ref
);
/** @} */
/** @} */
GIT_END_DECL
GIT_END_DECL
#endif
#endif
src/refs.c
View file @
75261421
...
@@ -1802,3 +1802,20 @@ int git_reference_foreach_glob(
...
@@ -1802,3 +1802,20 @@ int git_reference_foreach_glob(
return
git_reference_foreach
(
return
git_reference_foreach
(
repo
,
list_flags
,
fromglob_cb
,
&
data
);
repo
,
list_flags
,
fromglob_cb
,
&
data
);
}
}
int
git_reference_has_log
(
git_reference
*
ref
)
{
git_buf
path
=
GIT_BUF_INIT
;
int
result
;
assert
(
ref
);
if
(
git_buf_join_n
(
&
path
,
'/'
,
3
,
ref
->
owner
->
path_repository
,
GIT_REFLOG_DIR
,
ref
->
name
)
<
0
)
return
-
1
;
result
=
git_path_isfile
(
git_buf_cstr
(
&
path
));
git_buf_free
(
&
path
);
return
result
;
}
tests-clar/refs/reflog.c
View file @
75261421
...
@@ -145,3 +145,20 @@ void test_refs_reflog__renaming_the_reference_moves_the_reflog(void)
...
@@ -145,3 +145,20 @@ void test_refs_reflog__renaming_the_reference_moves_the_reflog(void)
git_buf_free
(
&
moved_log_path
);
git_buf_free
(
&
moved_log_path
);
git_buf_free
(
&
master_log_path
);
git_buf_free
(
&
master_log_path
);
}
}
static
void
assert_has_reflog
(
bool
expected_result
,
const
char
*
name
)
{
git_reference
*
ref
;
cl_git_pass
(
git_reference_lookup
(
&
ref
,
g_repo
,
name
));
cl_assert_equal_i
(
expected_result
,
git_reference_has_log
(
ref
));
git_reference_free
(
ref
);
}
void
test_refs_reflog__reference_has_reflog
(
void
)
{
assert_has_reflog
(
true
,
"HEAD"
);
assert_has_reflog
(
true
,
"refs/heads/master"
);
assert_has_reflog
(
false
,
"refs/heads/subtrees"
);
}
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