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
ae833178
Commit
ae833178
authored
Jul 21, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reflog: prevent git_reflog_read() from chocking when no log exists yet
parent
bd72425d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
9 deletions
+20
-9
include/git2/reflog.h
+4
-0
src/reflog.c
+16
-9
No files found.
include/git2/reflog.h
View file @
ae833178
...
...
@@ -23,6 +23,10 @@ GIT_BEGIN_DECL
/**
* Read the reflog for the given reference
*
* If there is no reflog file for the given
* reference yet, an empty reflog object will
* be returned.
*
* The reflog must be freed manually by using
* git_reflog_free().
*
...
...
src/reflog.c
View file @
ae833178
...
...
@@ -217,22 +217,29 @@ int git_reflog_read(git_reflog **reflog, git_reference *ref)
*
reflog
=
NULL
;
assert
(
reflog
&&
ref
);
if
(
reflog_init
(
&
log
,
ref
)
<
0
)
return
-
1
;
error
=
retrieve_reflog_path
(
&
log_path
,
ref
);
if
(
retrieve_reflog_path
(
&
log_path
,
ref
)
<
0
)
goto
cleanup
;
error
=
git_futils_readbuffer
(
&
log_file
,
git_buf_cstr
(
&
log_path
));
if
(
error
<
0
&&
error
!=
GIT_ENOTFOUND
)
goto
cleanup
;
if
(
!
error
)
error
=
git_futils_readbuffer
(
&
log_file
,
log_path
.
ptr
);
if
((
error
=
reflog_parse
(
log
,
git_buf_cstr
(
&
log_file
),
git_buf_len
(
&
log_file
)))
<
0
)
goto
cleanup
;
if
(
!
error
)
error
=
reflog_parse
(
log
,
log_file
.
ptr
,
log_file
.
size
)
;
*
reflog
=
log
;
goto
success
;
if
(
!
error
)
*
reflog
=
log
;
else
git_reflog_free
(
log
);
cleanup:
git_reflog_free
(
log
);
success:
git_buf_free
(
&
log_file
);
git_buf_free
(
&
log_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