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
5572d2b8
Commit
5572d2b8
authored
Jan 28, 2014
by
Russell Belfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some missing oid to id renames
parent
0316d80a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
21 deletions
+25
-21
include/git2/blob.h
+3
-2
src/blob.c
+22
-19
No files found.
include/git2/blob.h
View file @
5572d2b8
...
...
@@ -196,13 +196,14 @@ GIT_EXTERN(int) git_blob_create_fromchunks(
/**
* Write an in-memory buffer to the ODB as a blob
*
* @param
oid return the o
id of the written blob
* @param
id return the
id of the written blob
* @param repo repository where to blob will be written
* @param buffer data to be written into the blob
* @param len length of the data
* @return 0 or an error code
*/
GIT_EXTERN
(
int
)
git_blob_create_frombuffer
(
git_oid
*
oid
,
git_repository
*
repo
,
const
void
*
buffer
,
size_t
len
);
GIT_EXTERN
(
int
)
git_blob_create_frombuffer
(
git_oid
*
id
,
git_repository
*
repo
,
const
void
*
buffer
,
size_t
len
);
/**
* Determine if the blob content is most certainly binary or not.
...
...
src/blob.c
View file @
5572d2b8
...
...
@@ -50,25 +50,28 @@ int git_blob__parse(void *blob, git_odb_object *odb_obj)
return
0
;
}
int
git_blob_create_frombuffer
(
git_oid
*
oid
,
git_repository
*
repo
,
const
void
*
buffer
,
size_t
len
)
int
git_blob_create_frombuffer
(
git_oid
*
id
,
git_repository
*
repo
,
const
void
*
buffer
,
size_t
len
)
{
int
error
;
git_odb
*
odb
;
git_odb_stream
*
stream
;
assert
(
id
&&
repo
);
if
((
error
=
git_repository_odb__weakptr
(
&
odb
,
repo
))
<
0
||
(
error
=
git_odb_open_wstream
(
&
stream
,
odb
,
len
,
GIT_OBJ_BLOB
))
<
0
)
return
error
;
if
((
error
=
git_odb_stream_write
(
stream
,
buffer
,
len
))
==
0
)
error
=
git_odb_stream_finalize_write
(
o
id
,
stream
);
error
=
git_odb_stream_finalize_write
(
id
,
stream
);
git_odb_stream_free
(
stream
);
return
error
;
}
static
int
write_file_stream
(
git_oid
*
o
id
,
git_odb
*
odb
,
const
char
*
path
,
git_off_t
file_size
)
git_oid
*
id
,
git_odb
*
odb
,
const
char
*
path
,
git_off_t
file_size
)
{
int
fd
,
error
;
char
buffer
[
4096
];
...
...
@@ -97,14 +100,14 @@ static int write_file_stream(
}
if
(
!
error
)
error
=
git_odb_stream_finalize_write
(
o
id
,
stream
);
error
=
git_odb_stream_finalize_write
(
id
,
stream
);
git_odb_stream_free
(
stream
);
return
error
;
}
static
int
write_file_filtered
(
git_oid
*
o
id
,
git_oid
*
id
,
git_off_t
*
size
,
git_odb
*
odb
,
const
char
*
full_path
,
...
...
@@ -119,7 +122,7 @@ static int write_file_filtered(
if
(
!
error
)
{
*
size
=
tgt
.
size
;
error
=
git_odb_write
(
o
id
,
odb
,
tgt
.
ptr
,
tgt
.
size
,
GIT_OBJ_BLOB
);
error
=
git_odb_write
(
id
,
odb
,
tgt
.
ptr
,
tgt
.
size
,
GIT_OBJ_BLOB
);
}
git_buf_free
(
&
tgt
);
...
...
@@ -127,7 +130,7 @@ static int write_file_filtered(
}
static
int
write_symlink
(
git_oid
*
o
id
,
git_odb
*
odb
,
const
char
*
path
,
size_t
link_size
)
git_oid
*
id
,
git_odb
*
odb
,
const
char
*
path
,
size_t
link_size
)
{
char
*
link_data
;
ssize_t
read_len
;
...
...
@@ -143,13 +146,13 @@ static int write_symlink(
return
-
1
;
}
error
=
git_odb_write
(
o
id
,
odb
,
(
void
*
)
link_data
,
link_size
,
GIT_OBJ_BLOB
);
error
=
git_odb_write
(
id
,
odb
,
(
void
*
)
link_data
,
link_size
,
GIT_OBJ_BLOB
);
git__free
(
link_data
);
return
error
;
}
int
git_blob__create_from_paths
(
git_oid
*
o
id
,
git_oid
*
id
,
struct
stat
*
out_st
,
git_repository
*
repo
,
const
char
*
content_path
,
...
...
@@ -188,7 +191,7 @@ int git_blob__create_from_paths(
mode
=
hint_mode
?
hint_mode
:
st
.
st_mode
;
if
(
S_ISLNK
(
mode
))
{
error
=
write_symlink
(
o
id
,
odb
,
content_path
,
(
size_t
)
size
);
error
=
write_symlink
(
id
,
odb
,
content_path
,
(
size_t
)
size
);
}
else
{
git_filter_list
*
fl
=
NULL
;
...
...
@@ -202,10 +205,10 @@ int git_blob__create_from_paths(
else
if
(
fl
==
NULL
)
/* No filters need to be applied to the document: we can stream
* directly from disk */
error
=
write_file_stream
(
o
id
,
odb
,
content_path
,
size
);
error
=
write_file_stream
(
id
,
odb
,
content_path
,
size
);
else
{
/* We need to apply one or more filters */
error
=
write_file_filtered
(
o
id
,
&
size
,
odb
,
content_path
,
fl
);
error
=
write_file_filtered
(
id
,
&
size
,
odb
,
content_path
,
fl
);
git_filter_list_free
(
fl
);
}
...
...
@@ -233,13 +236,13 @@ done:
}
int
git_blob_create_fromworkdir
(
git_oid
*
o
id
,
git_repository
*
repo
,
const
char
*
path
)
git_oid
*
id
,
git_repository
*
repo
,
const
char
*
path
)
{
return
git_blob__create_from_paths
(
o
id
,
NULL
,
repo
,
NULL
,
path
,
0
,
true
);
return
git_blob__create_from_paths
(
id
,
NULL
,
repo
,
NULL
,
path
,
0
,
true
);
}
int
git_blob_create_fromdisk
(
git_oid
*
o
id
,
git_repository
*
repo
,
const
char
*
path
)
git_oid
*
id
,
git_repository
*
repo
,
const
char
*
path
)
{
int
error
;
git_buf
full_path
=
GIT_BUF_INIT
;
...
...
@@ -257,7 +260,7 @@ int git_blob_create_fromdisk(
hintpath
+=
strlen
(
workdir
);
error
=
git_blob__create_from_paths
(
o
id
,
NULL
,
repo
,
git_buf_cstr
(
&
full_path
),
hintpath
,
0
,
true
);
id
,
NULL
,
repo
,
git_buf_cstr
(
&
full_path
),
hintpath
,
0
,
true
);
git_buf_free
(
&
full_path
);
return
error
;
...
...
@@ -266,7 +269,7 @@ int git_blob_create_fromdisk(
#define BUFFER_SIZE 4096
int
git_blob_create_fromchunks
(
git_oid
*
o
id
,
git_oid
*
id
,
git_repository
*
repo
,
const
char
*
hintpath
,
int
(
*
source_cb
)(
char
*
content
,
size_t
max_length
,
void
*
payload
),
...
...
@@ -277,7 +280,7 @@ int git_blob_create_fromchunks(
git_filebuf
file
=
GIT_FILEBUF_INIT
;
git_buf
path
=
GIT_BUF_INIT
;
assert
(
o
id
&&
repo
&&
source_cb
);
assert
(
id
&&
repo
&&
source_cb
);
if
((
error
=
git_buf_joinpath
(
&
path
,
git_repository_path
(
repo
),
GIT_OBJECTS_DIR
"streamed"
))
<
0
)
...
...
@@ -313,7 +316,7 @@ int git_blob_create_fromchunks(
goto
cleanup
;
error
=
git_blob__create_from_paths
(
o
id
,
NULL
,
repo
,
file
.
path_lock
,
hintpath
,
0
,
hintpath
!=
NULL
);
id
,
NULL
,
repo
,
file
.
path_lock
,
hintpath
,
0
,
hintpath
!=
NULL
);
cleanup:
git_buf_free
(
&
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