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
2052e3c0
Commit
2052e3c0
authored
Dec 21, 2012
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1163 from barrbrain/check-exists-before-write
odb: check if object exists before writing
parents
4c10d1af
4d185dd9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
2 deletions
+8
-2
include/git2/odb_backend.h
+4
-0
src/odb.c
+4
-0
src/odb_loose.c
+0
-2
No files found.
include/git2/odb_backend.h
View file @
2052e3c0
...
...
@@ -63,6 +63,10 @@ struct git_odb_backend {
struct
git_odb_backend
*
,
const
git_oid
*
);
/* The writer may assume that the object
* has already been hashed and is passed
* in the first parameter.
*/
int
(
*
write
)(
git_oid
*
,
struct
git_odb_backend
*
,
...
...
src/odb.c
View file @
2052e3c0
...
...
@@ -713,6 +713,10 @@ int git_odb_write(
assert
(
oid
&&
db
);
git_odb_hash
(
oid
,
data
,
len
,
type
);
if
(
git_odb_exists
(
db
,
oid
))
return
0
;
for
(
i
=
0
;
i
<
db
->
backends
.
length
&&
error
<
0
;
++
i
)
{
backend_internal
*
internal
=
git_vector_get
(
&
db
->
backends
,
i
);
git_odb_backend
*
b
=
internal
->
backend
;
...
...
src/odb_loose.c
View file @
2052e3c0
...
...
@@ -870,7 +870,6 @@ static int loose_backend__write(git_oid *oid, git_odb_backend *_backend, const v
if
(
git_buf_joinpath
(
&
final_path
,
backend
->
objects_dir
,
"tmp_object"
)
<
0
||
git_filebuf_open
(
&
fbuf
,
final_path
.
ptr
,
GIT_FILEBUF_HASH_CONTENTS
|
GIT_FILEBUF_TEMPORARY
|
(
backend
->
object_zlib_level
<<
GIT_FILEBUF_DEFLATE_SHIFT
))
<
0
)
{
...
...
@@ -880,7 +879,6 @@ static int loose_backend__write(git_oid *oid, git_odb_backend *_backend, const v
git_filebuf_write
(
&
fbuf
,
header
,
header_len
);
git_filebuf_write
(
&
fbuf
,
data
,
len
);
git_filebuf_hash
(
oid
,
&
fbuf
);
if
(
object_file_name
(
&
final_path
,
backend
->
objects_dir
,
oid
)
<
0
||
git_futils_mkpath2file
(
final_path
.
ptr
,
GIT_OBJECT_DIR_MODE
)
<
0
||
...
...
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