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
209f9b67
Commit
209f9b67
authored
Sep 08, 2013
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
odb: Teach loose backend to return EAMBIGUOUS
parent
d0cd6c42
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
2 deletions
+37
-2
src/odb_loose.c
+6
-2
tests-clar/refs/revparse.c
+31
-0
No files found.
src/odb_loose.c
View file @
209f9b67
...
...
@@ -499,7 +499,7 @@ static int fn_locate_object_short_oid(void *state, git_buf *pathbuf) {
}
if
(
sstate
->
found
>
1
)
return
git_odb__error_ambiguous
(
"multiple matches in loose objects"
)
;
return
GIT_EAMBIGUOUS
;
return
0
;
}
...
...
@@ -545,12 +545,16 @@ static int locate_object_short_oid(
/* Explore directory to find a unique object matching short_oid */
error
=
git_path_direach
(
object_location
,
fn_locate_object_short_oid
,
&
state
);
if
(
error
)
if
(
error
&&
error
!=
GIT_EUSER
)
return
error
;
if
(
!
state
.
found
)
return
git_odb__error_notfound
(
"no matching loose object for prefix"
,
short_oid
);
if
(
state
.
found
>
1
)
return
git_odb__error_ambiguous
(
"multiple matches in loose objects"
);
/* Convert obtained hex formatted oid to raw */
error
=
git_oid_fromstr
(
res_oid
,
(
char
*
)
state
.
res_oid
);
if
(
error
)
...
...
tests-clar/refs/revparse.c
View file @
209f9b67
...
...
@@ -544,6 +544,37 @@ void test_refs_revparse__a_too_short_objectid_returns_EAMBIGUOUS(void)
GIT_EAMBIGUOUS
,
git_revparse_single
(
&
g_obj
,
g_repo
,
"e90"
));
}
/*
* $ echo "aabqhq" | git hash-object -t blob --stdin
* dea509d0b3cb8ee0650f6ca210bc83f4678851ba
*
* $ echo "aaazvc" | git hash-object -t blob --stdin
* dea509d097ce692e167dfc6a48a7a280cc5e877e
*/
void
test_refs_revparse__a_not_precise_enough_objectid_returns_EAMBIGUOUS
(
void
)
{
git_repository
*
repo
;
git_index
*
index
;
git_object
*
obj
;
repo
=
cl_git_sandbox_init
(
"testrepo"
);
cl_git_mkfile
(
"testrepo/one.txt"
,
"aabqhq
\n
"
);
cl_git_mkfile
(
"testrepo/two.txt"
,
"aaazvc
\n
"
);
cl_git_pass
(
git_repository_index
(
&
index
,
repo
));
cl_git_pass
(
git_index_add_bypath
(
index
,
"one.txt"
));
cl_git_pass
(
git_index_add_bypath
(
index
,
"two.txt"
));
cl_git_fail_with
(
git_revparse_single
(
&
obj
,
repo
,
"dea509d0"
),
GIT_EAMBIGUOUS
);
cl_git_pass
(
git_revparse_single
(
&
obj
,
repo
,
"dea509d09"
));
git_object_free
(
obj
);
git_index_free
(
index
);
cl_git_sandbox_cleanup
();
}
void
test_refs_revparse__issue_994
(
void
)
{
git_repository
*
repo
;
...
...
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