deps/libgit2/src/libgit2/blob.c

filter: Statementstmt 38.2% 89 / 233 Branchbran 26.7% 31 / 116 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 34.3% 120 / 349 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« deps/libgit2/src/libgit2/transports/local.c ↑ Summary deps/libgit2/src/libgit2/odb_pack.c »
1 /*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7  
8 #include "blob.h"
9  
10 #include "git2/common.h"
11 #include "git2/object.h"
12 #include "git2/repository.h"
13 #include "git2/odb_backend.h"
14  
15 #include "buf.h"
16 #include "filebuf.h"
17 #include "filter.h"
18  
19 169 const void *git_blob_rawcontent(const git_blob *blob)
20 {
21 169 ▶ GIT_ASSERT_ARG_WITH_RETVAL(blob, NULL);
Branch: 1 branch
BranchTrueFalseTotal
GIT_ASSERT_ARG_WITH_RETVAL(blob, NULL); 0 169 169
22  
23 169 ▶ if (blob->raw)
Branch: 1 branch
BranchTrueFalseTotal
if (blob->raw) 0 169 169
24 0 return blob->data.raw.data;
25 else
26 169 return git_odb_object_data(blob->data.odb);
27 }
28  
29 176 git_object_size_t git_blob_rawsize(const git_blob *blob)
30 {
31 176 ▶ GIT_ASSERT_ARG(blob);
Branch: 1 branch
BranchTrueFalseTotal
GIT_ASSERT_ARG(blob); 0 176 176
32  
33 176 ▶ if (blob->raw)
Branch: 1 branch
BranchTrueFalseTotal
if (blob->raw) 0 176 176
34 0 return blob->data.raw.size;
35 else
36 176 return (git_object_size_t)git_odb_object_size(blob->data.odb);
37 }
38  
39 0 int git_blob__getbuf(git_str *buffer, git_blob *blob)
40 {
41 0 git_object_size_t size = git_blob_rawsize(blob);
42  
43 0 ▶ GIT_ERROR_CHECK_BLOBSIZE(size);
Branch: 1 branch
BranchTrueFalseTotal
GIT_ERROR_CHECK_BLOBSIZE(size); 0 0 0
44 0 return git_str_set(buffer, git_blob_rawcontent(blob), (size_t)size);
45 }
46  
47 190 void git_blob__free(void *_blob)
48 {
49 190 git_blob *blob = (git_blob *) _blob;
50 190 ▶ if (!blob->raw)
Branch: 1 branch
BranchTrueFalseTotal
if (!blob->raw) 190 0 190
51 190 git_odb_object_free(blob->data.odb);
52 190 git__free(blob);
53 190 }
54  
55 0 int git_blob__parse_raw(void *_blob, const char *data, size_t size)
56 {
57 0 git_blob *blob = (git_blob *) _blob;
58  
59 0 ▶ GIT_ASSERT_ARG(blob);
Branch: 1 branch
BranchTrueFalseTotal
GIT_ASSERT_ARG(blob); 0 0 0
60  
61 0 blob->raw = 1;
62 0 blob->data.raw.data = data;
63 0 blob->data.raw.size = size;
64 0 return 0;
65 }
66  
67 190 int git_blob__parse(void *_blob, git_odb_object *odb_obj)
68 {
69 190 git_blob *blob = (git_blob *) _blob;
70  
71 190 ▶ GIT_ASSERT_ARG(blob);
Branch: 1 branch
BranchTrueFalseTotal
GIT_ASSERT_ARG(blob); 0 190 190
72  
73 190 git_cached_obj_incref((git_cached_obj *)odb_obj);
74 190 blob->raw = 0;
75 190 blob->data.odb = odb_obj;
76 190 return 0;
77 }
78  
79 16 int git_blob_create_from_buffer(
80 git_oid *id, git_repository *repo, const void *buffer, size_t len)
81 {
82 int error;
83 git_odb *odb;
84 git_odb_stream *stream;
85  
86 16 ▶ GIT_ASSERT_ARG(id);
Branch: 1 branch
BranchTrueFalseTotal
GIT_ASSERT_ARG(id); 0 16 16
87 16 ▶ GIT_ASSERT_ARG(repo);
Branch: 1 branch
BranchTrueFalseTotal
GIT_ASSERT_ARG(repo); 0 16 16
88  
89 32 if ((error = git_repository_odb__weakptr(&odb, repo)) < 0 ||
90 16 (error = git_odb_open_wstream(&stream, odb, len, GIT_OBJECT_BLOB)) < 0)
91 0 return error;
92  
93 16 ▶ if ((error = git_odb_stream_write(stream, buffer, len)) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if ((error = git_odb_stream_write(stream, buffer, len)) == 0) 16 0 16
94 16 error = git_odb_stream_finalize_write(id, stream);
95  
96 16 git_odb_stream_free(stream);
97 16 return error;
98 }
99  
100 47 static int write_file_stream(
101 git_oid *id, git_odb *odb, const char *path, git_object_size_t file_size)
102 {
103 int fd, error;
104 char buffer[GIT_BUFSIZE_FILEIO];
105 47 git_odb_stream *stream = NULL;
106 47 ssize_t read_len = -1;
107 47 git_object_size_t written = 0;
108  
109 47 ▶ if ((error = git_odb_open_wstream(
Branch: 1 branch
BranchTrueFalseTotal
if ((error = git_odb_open_wstream( 0 47 47
110 &stream, odb, file_size, GIT_OBJECT_BLOB)) < 0)
111 0 return error;
112  
113 47 ▶ if ((fd = git_futils_open_ro(path)) < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ((fd = git_futils_open_ro(path)) < 0) { 0 47 47
114 0 git_odb_stream_free(stream);
115 0 return -1;
116 }
117  
118 93 ▶ while (!error && (read_len = p_read(fd, buffer, sizeof(buffer))) > 0) {
Branch: 2 branches
BranchTrueFalseTotal
while (!error && (read_len = p_read(fd, buffer, sizeof(buffer))) > 0) { 93 0 93
while (!error && (read_len = p_read(fd, buffer, sizeof(buffer))) > 0) { 46 47 93
119 46 error = git_odb_stream_write(stream, buffer, read_len);
120 46 written += read_len;
121 }
122  
123 47 p_close(fd);
124  
125 47 ▶ if (written != file_size || read_len < 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (written != file_size || read_len < 0) { 47 0 47
if (written != file_size || read_len < 0) { 0 47 47
126 0 git_error_set(GIT_ERROR_OS, "failed to read file into stream");
127 0 error = -1;
128 }
129  
130 47 ▶ if (!error)
Branch: 1 branch
BranchTrueFalseTotal
if (!error) 47 0 47
131 47 error = git_odb_stream_finalize_write(id, stream);
132  
133 47 git_odb_stream_free(stream);
134 47 return error;
135 }
136  
137 17 static int write_file_filtered(
138 git_oid *id,
139 git_object_size_t *size,
140 git_odb *odb,
141 const char *full_path,
142 git_filter_list *fl,
143 git_repository* repo)
144 {
145 int error;
146 17 git_str tgt = GIT_STR_INIT;
147  
148 17 error = git_filter_list__apply_to_file(&tgt, fl, repo, full_path);
149  
150 /* Write the file to disk if it was properly filtered */
151 17 ▶ if (!error) {
Branch: 1 branch
BranchTrueFalseTotal
if (!error) { 15 2 17
152 15 *size = tgt.size;
153  
154 15 error = git_odb_write(id, odb, tgt.ptr, tgt.size, GIT_OBJECT_BLOB);
155 }
156  
157 17 git_str_dispose(&tgt);
158 17 return error;
159 }
160  
161 0 static int write_symlink(
162 git_oid *id, git_odb *odb, const char *path, size_t link_size)
163 {
164 char *link_data;
165 ssize_t read_len;
166 int error;
167  
168 0 link_data = git__malloc(link_size);
169 0 ▶ GIT_ERROR_CHECK_ALLOC(link_data);
Branch: 1 branch
BranchTrueFalseTotal
GIT_ERROR_CHECK_ALLOC(link_data); 0 0 0
170  
171 0 read_len = p_readlink(path, link_data, link_size);
172 0 ▶ if (read_len != (ssize_t)link_size) {
Branch: 1 branch
BranchTrueFalseTotal
if (read_len != (ssize_t)link_size) { 0 0 0
173 0 git_error_set(GIT_ERROR_OS, "failed to create blob: cannot read symlink '%s'", path);
174 0 git__free(link_data);
175 0 return -1;
176 }
177  
178 0 error = git_odb_write(id, odb, (void *)link_data, link_size, GIT_OBJECT_BLOB);
179 0 git__free(link_data);
180 0 return error;
181 }
182  
183 64 int git_blob__create_from_paths(
184 git_oid *id,
185 struct stat *out_st,
186 git_repository *repo,
187 const char *content_path,
188 const char *hint_path,
189 mode_t hint_mode,
190 bool try_load_filters)
191 {
192 int error;
193 struct stat st;
194 64 git_odb *odb = NULL;
195 git_object_size_t size;
196 mode_t mode;
197 64 git_str path = GIT_STR_INIT;
198  
199 64 ▶ GIT_ASSERT_ARG(hint_path || !try_load_filters);
Branch: 2 branches
BranchTrueFalseTotal
GIT_ASSERT_ARG(hint_path || !try_load_filters); 0 64 64
GIT_ASSERT_ARG(hint_path || !try_load_filters); 0 0 0
200  
201 64 ▶ if (!content_path) {
Branch: 1 branch
BranchTrueFalseTotal
if (!content_path) { 64 0 64
202 64 ▶ if (git_repository_workdir_path(&path, repo, hint_path) < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (git_repository_workdir_path(&path, repo, hint_path) < 0) 0 64 64
203 0 return -1;
204  
205 64 content_path = path.ptr;
206 }
207  
208 128 if ((error = git_fs_path_lstat(content_path, &st)) < 0 ||
209 64 (error = git_repository_odb(&odb, repo)) < 0)
210 0 goto done;
211  
212 64 ▶ if (S_ISDIR(st.st_mode)) {
Branch: 1 branch
BranchTrueFalseTotal
if (S_ISDIR(st.st_mode)) { 0 64 64
213 0 git_error_set(GIT_ERROR_ODB, "cannot create blob from '%s': it is a directory", content_path);
214 0 error = GIT_EDIRECTORY;
215 0 goto done;
216 }
217  
218 64 ▶ if (out_st)
Branch: 1 branch
BranchTrueFalseTotal
if (out_st) 64 0 64
219 64 memcpy(out_st, &st, sizeof(st));
220  
221 64 size = st.st_size;
222 64 ▶ mode = hint_mode ? hint_mode : st.st_mode;
Branch: 1 branch
BranchTrueFalseTotal
mode = hint_mode ? hint_mode : st.st_mode; 64 0 64
223  
224 64 ▶ if (S_ISLNK(mode)) {
Branch: 1 branch
BranchTrueFalseTotal
if (S_ISLNK(mode)) { 0 64 64
225 0 error = write_symlink(id, odb, content_path, (size_t)size);
226 } else {
227 64 git_filter_list *fl = NULL;
228  
229 64 ▶ if (try_load_filters)
Branch: 1 branch
BranchTrueFalseTotal
if (try_load_filters) 64 0 64
230 /* Load the filters for writing this file to the ODB */
231 64 error = git_filter_list_load(
232 &fl, repo, NULL, hint_path,
233 GIT_FILTER_TO_ODB, GIT_FILTER_DEFAULT);
234  
235 64 ▶ if (error < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (error < 0) 64 0 64
236 /* well, that didn't work */;
237 64 ▶ else if (fl == NULL)
Branch: 1 branch
BranchTrueFalseTotal
else if (fl == NULL) 47 17 64
238 /* No filters need to be applied to the document: we can stream
239 * directly from disk */
240 47 error = write_file_stream(id, odb, content_path, size);
241 else {
242 /* We need to apply one or more filters */
243 17 error = write_file_filtered(id, &size, odb, content_path, fl, repo);
244  
245 17 git_filter_list_free(fl);
246 }
247  
248 /*
249 * TODO: eventually support streaming filtered files, for files
250 * which are bigger than a given threshold. This is not a priority
251 * because applying a filter in streaming mode changes the final
252 * size of the blob, and without knowing its final size, the blob
253 * cannot be written in stream mode to the ODB.
254 *
255 * The plan is to do streaming writes to a tempfile on disk and then
256 * opening streaming that file to the ODB, using
257 * `write_file_stream`.
258 *
259 * CAREFULLY DESIGNED APIS YO
260 */
261 }
262  
263 64 done:
264 64 git_odb_free(odb);
265 64 git_str_dispose(&path);
266  
267 64 return error;
268 }
269  
270 0 int git_blob_create_from_workdir(
271 git_oid *id, git_repository *repo, const char *path)
272 {
273 0 return git_blob__create_from_paths(id, NULL, repo, NULL, path, 0, true);
274 }
275  
276 0 int git_blob_create_from_disk(
277 git_oid *id, git_repository *repo, const char *path)
278 {
279 int error;
280 0 git_str full_path = GIT_STR_INIT;
281 0 const char *workdir, *hintpath = NULL;
282  
283 0 ▶ if ((error = git_fs_path_prettify(&full_path, path, NULL)) < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ((error = git_fs_path_prettify(&full_path, path, NULL)) < 0) { 0 0 0
284 0 git_str_dispose(&full_path);
285 0 return error;
286 }
287  
288 0 workdir = git_repository_workdir(repo);
289  
290 0 ▶ if (workdir && !git__prefixcmp(full_path.ptr, workdir))
Branch: 2 branches
BranchTrueFalseTotal
if (workdir && !git__prefixcmp(full_path.ptr, workdir)) 0 0 0
if (workdir && !git__prefixcmp(full_path.ptr, workdir)) 0 0 0
291 0 hintpath = full_path.ptr + strlen(workdir);
292  
293 0 error = git_blob__create_from_paths(
294 id, NULL, repo, git_str_cstr(&full_path), hintpath, 0, !!hintpath);
295  
296 0 git_str_dispose(&full_path);
297 0 return error;
298 }
299  
300 typedef struct {
301 git_writestream parent;
302 git_filebuf fbuf;
303 git_repository *repo;
304 char *hintpath;
305 } blob_writestream;
306  
307 0 static int blob_writestream_close(git_writestream *_stream)
308 {
309 0 blob_writestream *stream = (blob_writestream *) _stream;
310  
311 0 git_filebuf_cleanup(&stream->fbuf);
312 0 return 0;
313 }
314  
315 0 static void blob_writestream_free(git_writestream *_stream)
316 {
317 0 blob_writestream *stream = (blob_writestream *) _stream;
318  
319 0 git_filebuf_cleanup(&stream->fbuf);
320 0 git__free(stream->hintpath);
321 0 git__free(stream);
322 0 }
323  
324 0 static int blob_writestream_write(git_writestream *_stream, const char *buffer, size_t len)
325 {
326 0 blob_writestream *stream = (blob_writestream *) _stream;
327  
328 0 return git_filebuf_write(&stream->fbuf, buffer, len);
329 }
330  
331 0 int git_blob_create_from_stream(git_writestream **out, git_repository *repo, const char *hintpath)
332 {
333 int error;
334 0 git_str path = GIT_STR_INIT;
335 blob_writestream *stream;
336  
337 0 ▶ GIT_ASSERT_ARG(out);
Branch: 1 branch
BranchTrueFalseTotal
GIT_ASSERT_ARG(out); 0 0 0
338 0 ▶ GIT_ASSERT_ARG(repo);
Branch: 1 branch
BranchTrueFalseTotal
GIT_ASSERT_ARG(repo); 0 0 0
339  
340 0 stream = git__calloc(1, sizeof(blob_writestream));
341 0 ▶ GIT_ERROR_CHECK_ALLOC(stream);
Branch: 1 branch
BranchTrueFalseTotal
GIT_ERROR_CHECK_ALLOC(stream); 0 0 0
342  
343 0 ▶ if (hintpath) {
Branch: 1 branch
BranchTrueFalseTotal
if (hintpath) { 0 0 0
344 0 stream->hintpath = git__strdup(hintpath);
345 0 ▶ GIT_ERROR_CHECK_ALLOC(stream->hintpath);
Branch: 1 branch
BranchTrueFalseTotal
GIT_ERROR_CHECK_ALLOC(stream->hintpath); 0 0 0
346 }
347  
348 0 stream->repo = repo;
349 0 stream->parent.write = blob_writestream_write;
350 0 stream->parent.close = blob_writestream_close;
351 0 stream->parent.free = blob_writestream_free;
352  
353 0 ▶ if ((error = git_repository__item_path(&path, repo, GIT_REPOSITORY_ITEM_OBJECTS)) < 0
Branch: 1 branch
BranchTrueFalseTotal
if ((error = git_repository__item_path(&path, repo, GIT_REPOSITORY_ITEM_OBJECTS)) < 0 0 0 0
354 0 ▶ || (error = git_str_joinpath(&path, path.ptr, "streamed")) < 0)
Branch: 1 branch
BranchTrueFalseTotal
|| (error = git_str_joinpath(&path, path.ptr, "streamed")) < 0) 0 0 0
355 0 goto cleanup;
356  
357 0 ▶ if ((error = git_filebuf_open_withsize(&stream->fbuf, git_str_cstr(&path), GIT_FILEBUF_TEMPORARY,
Branch: 1 branch
BranchTrueFalseTotal
if ((error = git_filebuf_open_withsize(&stream->fbuf, git_str_cstr(&path), GIT_FILEBUF_TEMPORARY, 0 0 0
358 0666, 2 * 1024 * 1024)) < 0)
359 0 goto cleanup;
360  
361 0 *out = (git_writestream *) stream;
362  
363 0 cleanup:
364 0 ▶ if (error < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (error < 0) 0 0 0
365 0 blob_writestream_free((git_writestream *) stream);
366  
367 0 git_str_dispose(&path);
368 0 return error;
369 }
370  
371 0 int git_blob_create_from_stream_commit(git_oid *out, git_writestream *_stream)
372 {
373 int error;
374 0 blob_writestream *stream = (blob_writestream *) _stream;
375  
376 /*
377 * We can make this more officient by avoiding writing to
378 * disk, but for now let's re-use the helper functions we
379 * have.
380 */
381 0 ▶ if ((error = git_filebuf_flush(&stream->fbuf)) < 0)
Branch: 1 branch
BranchTrueFalseTotal
if ((error = git_filebuf_flush(&stream->fbuf)) < 0) 0 0 0
382 0 goto cleanup;
383  
384 0 error = git_blob__create_from_paths(out, NULL, stream->repo, stream->fbuf.path_lock,
385 0 stream->hintpath, 0, !!stream->hintpath);
386  
387 0 cleanup:
388 0 blob_writestream_free(_stream);
389 0 return error;
390  
391 }
392  
393 10 int git_blob_is_binary(const git_blob *blob)
394 {
395 10 git_str content = GIT_STR_INIT;
396 git_object_size_t size;
397  
398 10 ▶ GIT_ASSERT_ARG(blob);
Branch: 1 branch
BranchTrueFalseTotal
GIT_ASSERT_ARG(blob); 0 10 10
399  
400 10 size = git_blob_rawsize(blob);
401  
402 10 git_str_attach_notowned(&content, git_blob_rawcontent(blob),
403 10 (size_t)min(size, GIT_FILTER_BYTES_TO_CHECK_NUL));
404 10 return git_str_is_binary(&content);
405 }
406  
407 0 int git_blob_data_is_binary(const char *str, size_t len)
408 {
409 0 git_str content = GIT_STR_INIT;
410  
411 0 git_str_attach_notowned(&content, str, len);
412  
413 0 return git_str_is_binary(&content);
414 }
415  
416 0 int git_blob_filter_options_init(
417 git_blob_filter_options *opts,
418 unsigned int version)
419 {
420 0 ▶ GIT_INIT_STRUCTURE_FROM_TEMPLATE(opts, version,
Branch: 1 branch
BranchTrueFalseTotal
GIT_INIT_STRUCTURE_FROM_TEMPLATE(opts, version, 0 0 0
421 git_blob_filter_options, GIT_BLOB_FILTER_OPTIONS_INIT);
422 0 return 0;
423 }
424  
425 0 int git_blob_filter(
426 git_buf *out,
427 git_blob *blob,
428 const char *path,
429 git_blob_filter_options *given_opts)
430 {
431 0 git_blob_filter_options opts = GIT_BLOB_FILTER_OPTIONS_INIT;
432 0 git_filter_options filter_opts = GIT_FILTER_OPTIONS_INIT;
433 0 git_filter_list *fl = NULL;
434 0 int error = 0;
435  
436 0 ▶ GIT_ASSERT_ARG(blob);
Branch: 1 branch
BranchTrueFalseTotal
GIT_ASSERT_ARG(blob); 0 0 0
437 0 ▶ GIT_ASSERT_ARG(path);
Branch: 1 branch
BranchTrueFalseTotal
GIT_ASSERT_ARG(path); 0 0 0
438 0 ▶ GIT_ASSERT_ARG(out);
Branch: 1 branch
BranchTrueFalseTotal
GIT_ASSERT_ARG(out); 0 0 0
439  
440 0 ▶ GIT_ERROR_CHECK_VERSION(
Branch: 1 branch
BranchTrueFalseTotal
GIT_ERROR_CHECK_VERSION( 0 0 0
441 given_opts, GIT_BLOB_FILTER_OPTIONS_VERSION, "git_blob_filter_options");
442  
443 0 ▶ if (given_opts != NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (given_opts != NULL) 0 0 0
444 0 memcpy(&opts, given_opts, sizeof(git_blob_filter_options));
445  
446 0 if ((opts.flags & GIT_BLOB_FILTER_CHECK_FOR_BINARY) != 0 &&
447 0 git_blob_is_binary(blob))
448 0 return 0;
449  
450 0 ▶ if ((opts.flags & GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES) != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ((opts.flags & GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES) != 0) 0 0 0
451 0 filter_opts.flags |= GIT_FILTER_NO_SYSTEM_ATTRIBUTES;
452  
453 0 ▶ if ((opts.flags & GIT_BLOB_FILTER_ATTRIBUTES_FROM_HEAD) != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ((opts.flags & GIT_BLOB_FILTER_ATTRIBUTES_FROM_HEAD) != 0) 0 0 0
454 0 filter_opts.flags |= GIT_FILTER_ATTRIBUTES_FROM_HEAD;
455  
456 0 ▶ if ((opts.flags & GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT) != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ((opts.flags & GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT) != 0) { 0 0 0
457 0 filter_opts.flags |= GIT_FILTER_ATTRIBUTES_FROM_COMMIT;
458  
459 #ifndef GIT_DEPRECATE_HARD
460 0 ▶ if (opts.commit_id)
Branch: 1 branch
BranchTrueFalseTotal
if (opts.commit_id) 0 0 0
461 0 git_oid_cpy(&filter_opts.attr_commit_id, opts.commit_id);
462 else
463 #endif
464 0 git_oid_cpy(&filter_opts.attr_commit_id, &opts.attr_commit_id);
465 }
466  
467 0 ▶ if (!(error = git_filter_list_load_ext(
Branch: 1 branch
BranchTrueFalseTotal
if (!(error = git_filter_list_load_ext( 0 0 0
468 &fl, git_blob_owner(blob), blob, path,
469 GIT_FILTER_TO_WORKTREE, &filter_opts))) {
470  
471 0 error = git_filter_list_apply_to_blob(out, fl, blob);
472  
473 0 git_filter_list_free(fl);
474 }
475  
476 0 return error;
477 }
478  
479 /* Deprecated functions */
480  
481 #ifndef GIT_DEPRECATE_HARD
482 5 int git_blob_create_frombuffer(
483 git_oid *id, git_repository *repo, const void *buffer, size_t len)
484 {
485 5 return git_blob_create_from_buffer(id, repo, buffer, len);
486 }
487  
488 0 int git_blob_create_fromworkdir(git_oid *id, git_repository *repo, const char *relative_path)
489 {
490 0 return git_blob_create_from_workdir(id, repo, relative_path);
491 }
492  
493 0 int git_blob_create_fromdisk(git_oid *id, git_repository *repo, const char *path)
494 {
495 0 return git_blob_create_from_disk(id, repo, path);
496 }
497  
498 0 int git_blob_create_fromstream(
499 git_writestream **out,
500 git_repository *repo,
501 const char *hintpath)
502 {
503 0 return git_blob_create_from_stream(out, repo, hintpath);
504 }
505  
506 0 int git_blob_create_fromstream_commit(
507 git_oid *out,
508 git_writestream *stream)
509 {
510 0 return git_blob_create_from_stream_commit(out, stream);
511 }
512  
513 0 int git_blob_filtered_content(
514 git_buf *out,
515 git_blob *blob,
516 const char *path,
517 int check_for_binary_data)
518 {
519 0 git_blob_filter_options opts = GIT_BLOB_FILTER_OPTIONS_INIT;
520  
521 0 ▶ if (check_for_binary_data)
Branch: 1 branch
BranchTrueFalseTotal
if (check_for_binary_data) 0 0 0
522 0 opts.flags |= GIT_BLOB_FILTER_CHECK_FOR_BINARY;
523 else
524 0 opts.flags &= ~GIT_BLOB_FILTER_CHECK_FOR_BINARY;
525  
526 0 return git_blob_filter(out, blob, path, &opts);
527 }
528 #endif
« deps/libgit2/src/libgit2/transports/local.c ↑ Summary deps/libgit2/src/libgit2/odb_pack.c »