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
1e71354e
Commit
1e71354e
authored
Sep 05, 2014
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reflog: Error handling on empty reflog
parent
0972443c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
18 deletions
+15
-18
src/revparse.c
+15
-18
No files found.
src/revparse.c
View file @
1e71354e
...
...
@@ -205,7 +205,6 @@ cleanup:
static
int
retrieve_oid_from_reflog
(
git_oid
*
oid
,
git_reference
*
ref
,
size_t
identifier
)
{
git_reflog
*
reflog
;
int
error
=
-
1
;
size_t
numentries
;
const
git_reflog_entry
*
entry
;
bool
search_by_pos
=
(
identifier
<=
100000000
);
...
...
@@ -216,21 +215,11 @@ static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, size_t ide
numentries
=
git_reflog_entrycount
(
reflog
);
if
(
search_by_pos
)
{
if
(
numentries
<
identifier
+
1
)
{
giterr_set
(
GITERR_REFERENCE
,
"Reflog for '%s' has only %"
PRIuZ
" entries, asked for %"
PRIuZ
,
git_reference_name
(
ref
),
numentries
,
identifier
);
error
=
GIT_ENOTFOUND
;
goto
cleanup
;
}
if
(
numentries
<
identifier
+
1
)
goto
notfound
;
entry
=
git_reflog_entry_byindex
(
reflog
,
identifier
);
git_oid_cpy
(
oid
,
git_reflog_entry_id_new
(
entry
));
error
=
0
;
goto
cleanup
;
}
else
{
size_t
i
;
git_time
commit_time
;
...
...
@@ -243,16 +232,24 @@ static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, size_t ide
continue
;
git_oid_cpy
(
oid
,
git_reflog_entry_id_new
(
entry
));
error
=
0
;
goto
cleanup
;
break
;
}
error
=
GIT_ENOTFOUND
;
if
(
i
==
numentries
)
goto
notfound
;
}
cleanup:
git_reflog_free
(
reflog
);
return
error
;
return
0
;
notfound:
giterr_set
(
GITERR_REFERENCE
,
"Reflog for '%s' has only %"
PRIuZ
" entries, asked for %"
PRIuZ
,
git_reference_name
(
ref
),
numentries
,
identifier
);
git_reflog_free
(
reflog
);
return
GIT_ENOTFOUND
;
}
static
int
retrieve_revobject_from_reflog
(
git_object
**
out
,
git_reference
**
base_ref
,
git_repository
*
repo
,
const
char
*
identifier
,
size_t
position
)
...
...
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