Skip to content

Commit 08f3920

Browse files
committed
blob: add underscore to from functions
The majority of functions are named `from_something` (with an underscore) instead of `fromsomething`. Update the blob functions for consistency with the rest of the library.
1 parent 5d92e54 commit 08f3920

File tree

14 files changed

+89
-32
lines changed

14 files changed

+89
-32
lines changed

include/git2/blob.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ GIT_EXTERN(int) git_blob_filtered_content(
136136
* relative to the repository's working dir
137137
* @return 0 or an error code
138138
*/
139-
GIT_EXTERN(int) git_blob_create_fromworkdir(git_oid *id, git_repository *repo, const char *relative_path);
139+
GIT_EXTERN(int) git_blob_create_from_workdir(git_oid *id, git_repository *repo, const char *relative_path);
140140

141141
/**
142142
* Read a file from the filesystem and write its content
@@ -148,20 +148,20 @@ GIT_EXTERN(int) git_blob_create_fromworkdir(git_oid *id, git_repository *repo, c
148148
* @param path file from which the blob will be created
149149
* @return 0 or an error code
150150
*/
151-
GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *id, git_repository *repo, const char *path);
151+
GIT_EXTERN(int) git_blob_create_from_disk(git_oid *id, git_repository *repo, const char *path);
152152

153153
/**
154154
* Create a stream to write a new blob into the object db
155155
*
156156
* This function may need to buffer the data on disk and will in
157157
* general not be the right choice if you know the size of the data
158158
* to write. If you have data in memory, use
159-
* `git_blob_create_frombuffer()`. If you do not, but know the size of
159+
* `git_blob_create_from_buffer()`. If you do not, but know the size of
160160
* the contents (and don't want/need to perform filtering), use
161161
* `git_odb_open_wstream()`.
162162
*
163163
* Don't close this stream yourself but pass it to
164-
* `git_blob_create_fromstream_commit()` to commit the write to the
164+
* `git_blob_create_from_stream_commit()` to commit the write to the
165165
* object db and get the object id.
166166
*
167167
* If the `hintpath` parameter is filled, it will be used to determine
@@ -175,7 +175,7 @@ GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *id, git_repository *repo, cons
175175
* to apply onto the content of the blob to be created.
176176
* @return 0 or error code
177177
*/
178-
GIT_EXTERN(int) git_blob_create_fromstream(
178+
GIT_EXTERN(int) git_blob_create_from_stream(
179179
git_writestream **out,
180180
git_repository *repo,
181181
const char *hintpath);
@@ -189,7 +189,7 @@ GIT_EXTERN(int) git_blob_create_fromstream(
189189
* @param stream the stream to close
190190
* @return 0 or an error code
191191
*/
192-
GIT_EXTERN(int) git_blob_create_fromstream_commit(
192+
GIT_EXTERN(int) git_blob_create_from_stream_commit(
193193
git_oid *out,
194194
git_writestream *stream);
195195

@@ -202,7 +202,7 @@ GIT_EXTERN(int) git_blob_create_fromstream_commit(
202202
* @param len length of the data
203203
* @return 0 or an error code
204204
*/
205-
GIT_EXTERN(int) git_blob_create_frombuffer(
205+
GIT_EXTERN(int) git_blob_create_from_buffer(
206206
git_oid *id, git_repository *repo, const void *buffer, size_t len);
207207

208208
/**

include/git2/deprecated.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,30 @@
4545
*/
4646
GIT_BEGIN_DECL
4747

48+
/** @name Deprecated Blob Functions
49+
*
50+
* These functions are retained for backward compatibility. The newer
51+
* versions of these functions should be preferred in all new code.
52+
*
53+
* There is no plan to remove these backward compatibility values at
54+
* this time.
55+
*/
56+
/**@{*/
57+
58+
GIT_EXTERN(int) git_blob_create_fromworkdir(git_oid *id, git_repository *repo, const char *relative_path);
59+
GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *id, git_repository *repo, const char *path);
60+
GIT_EXTERN(int) git_blob_create_fromstream(
61+
git_writestream **out,
62+
git_repository *repo,
63+
const char *hintpath);
64+
GIT_EXTERN(int) git_blob_create_fromstream_commit(
65+
git_oid *out,
66+
git_writestream *stream);
67+
GIT_EXTERN(int) git_blob_create_frombuffer(
68+
git_oid *id, git_repository *repo, const void *buffer, size_t len);
69+
70+
/**@}*/
71+
4872
/** @name Deprecated Buffer Functions
4973
*
5074
* These functions and enumeration values are retained for backward

src/apply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ static int apply_one(
532532
if (delta->status != GIT_DELTA_DELETED) {
533533
if ((error = git_apply__patch(&post_contents, &filename, &mode,
534534
pre_contents.ptr, pre_contents.size, patch, opts)) < 0 ||
535-
(error = git_blob_create_frombuffer(&post_id, repo,
535+
(error = git_blob_create_from_buffer(&post_id, repo,
536536
post_contents.ptr, post_contents.size)) < 0)
537537
goto done;
538538

src/blob.c

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ int git_blob__parse(void *_blob, git_odb_object *odb_obj)
7070
return 0;
7171
}
7272

73-
int git_blob_create_frombuffer(
73+
int git_blob_create_from_buffer(
7474
git_oid *id, git_repository *repo, const void *buffer, size_t len)
7575
{
7676
int error;
@@ -263,13 +263,13 @@ int git_blob__create_from_paths(
263263
return error;
264264
}
265265

266-
int git_blob_create_fromworkdir(
266+
int git_blob_create_from_workdir(
267267
git_oid *id, git_repository *repo, const char *path)
268268
{
269269
return git_blob__create_from_paths(id, NULL, repo, NULL, path, 0, true);
270270
}
271271

272-
int git_blob_create_fromdisk(
272+
int git_blob_create_from_disk(
273273
git_oid *id, git_repository *repo, const char *path)
274274
{
275275
int error;
@@ -325,7 +325,7 @@ static int blob_writestream_write(git_writestream *_stream, const char *buffer,
325325
return git_filebuf_write(&stream->fbuf, buffer, len);
326326
}
327327

328-
int git_blob_create_fromstream(git_writestream **out, git_repository *repo, const char *hintpath)
328+
int git_blob_create_from_stream(git_writestream **out, git_repository *repo, const char *hintpath)
329329
{
330330
int error;
331331
git_buf path = GIT_BUF_INIT;
@@ -364,7 +364,7 @@ int git_blob_create_fromstream(git_writestream **out, git_repository *repo, cons
364364
return error;
365365
}
366366

367-
int git_blob_create_fromstream_commit(git_oid *out, git_writestream *_stream)
367+
int git_blob_create_from_stream_commit(git_oid *out, git_writestream *_stream)
368368
{
369369
int error;
370370
blob_writestream *stream = (blob_writestream *) _stream;
@@ -427,3 +427,36 @@ int git_blob_filtered_content(
427427

428428
return error;
429429
}
430+
431+
/* Deprecated functions */
432+
433+
int git_blob_create_frombuffer(
434+
git_oid *id, git_repository *repo, const void *buffer, size_t len)
435+
{
436+
return git_blob_create_from_buffer(id, repo, buffer, len);
437+
}
438+
439+
int git_blob_create_fromworkdir(git_oid *id, git_repository *repo, const char *relative_path)
440+
{
441+
return git_blob_create_from_workdir(id, repo, relative_path);
442+
}
443+
444+
int git_blob_create_fromdisk(git_oid *id, git_repository *repo, const char *path)
445+
{
446+
return git_blob_create_from_disk(id, repo, path);
447+
}
448+
449+
int git_blob_create_fromstream(
450+
git_writestream **out,
451+
git_repository *repo,
452+
const char *hintpath)
453+
{
454+
return git_blob_create_from_stream(out, repo, hintpath);
455+
}
456+
457+
int git_blob_create_fromstream_commit(
458+
git_oid *out,
459+
git_writestream *stream)
460+
{
461+
return git_blob_create_from_stream_commit(out, stream);
462+
}

src/index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,7 @@ int git_index_add_frombuffer(
14771477
if (index_entry_dup(&entry, index, source_entry) < 0)
14781478
return -1;
14791479

1480-
error = git_blob_create_frombuffer(&id, INDEX_OWNER(index), buffer, len);
1480+
error = git_blob_create_from_buffer(&id, INDEX_OWNER(index), buffer, len);
14811481
if (error < 0) {
14821482
index_entry_free(entry);
14831483
return error;

src/notes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ static int note_write(
288288

289289
/* TODO: should we apply filters? */
290290
/* create note object */
291-
if ((error = git_blob_create_frombuffer(&oid, repo, note, strlen(note))) < 0)
291+
if ((error = git_blob_create_from_buffer(&oid, repo, note, strlen(note))) < 0)
292292
goto cleanup;
293293

294294
if ((error = manipulate_note_in_tree_r(

tests/filter/blob.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ void test_filter_blob__ident(void)
8787
git_buf buf = { 0 };
8888

8989
cl_git_mkfile("crlf/test.ident", "Some text\n$Id$\nGoes there\n");
90-
cl_git_pass(git_blob_create_fromworkdir(&id, g_repo, "test.ident"));
90+
cl_git_pass(git_blob_create_from_workdir(&id, g_repo, "test.ident"));
9191
cl_git_pass(git_blob_lookup(&blob, g_repo, &id));
9292
cl_assert_equal_s(
9393
"Some text\n$Id$\nGoes there\n", git_blob_rawcontent(blob));
9494
git_blob_free(blob);
9595

9696
cl_git_mkfile("crlf/test.ident", "Some text\n$Id: Any old just you want$\nGoes there\n");
97-
cl_git_pass(git_blob_create_fromworkdir(&id, g_repo, "test.ident"));
97+
cl_git_pass(git_blob_create_from_workdir(&id, g_repo, "test.ident"));
9898
cl_git_pass(git_blob_lookup(&blob, g_repo, &id));
9999
cl_assert_equal_s(
100100
"Some text\n$Id$\nGoes there\n", git_blob_rawcontent(blob));

tests/filter/ident.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static void add_blob_and_filter(
2323
git_buf out = { 0 };
2424

2525
cl_git_mkfile("crlf/identtest", data);
26-
cl_git_pass(git_blob_create_fromworkdir(&id, g_repo, "identtest"));
26+
cl_git_pass(git_blob_create_from_workdir(&id, g_repo, "identtest"));
2727
cl_git_pass(git_blob_lookup(&blob, g_repo, &id));
2828

2929
cl_git_pass(git_filter_list_apply_to_blob(&out, fl, blob));

tests/merge/merge_helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ int merge_test_workdir(git_repository *repo, const struct merge_index_entry expe
352352
return 0;
353353

354354
for (i = 0; i < expected_len; i++) {
355-
git_blob_create_fromworkdir(&actual_oid, repo, expected[i].path);
355+
git_blob_create_from_workdir(&actual_oid, repo, expected[i].path);
356356
git_oid_fromstr(&expected_oid, expected[i].oid_str);
357357

358358
if (git_oid_cmp(&actual_oid, &expected_oid) != 0)

tests/object/blob/filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void test_object_blob_filter__initialize(void)
5959
if (g_crlf_raw_len[i] < 0)
6060
g_crlf_raw_len[i] = strlen(g_crlf_raw[i]);
6161

62-
cl_git_pass(git_blob_create_frombuffer(
62+
cl_git_pass(git_blob_create_from_buffer(
6363
&g_crlf_oids[i], g_repo, g_crlf_raw[i], (size_t)g_crlf_raw_len[i]));
6464
}
6565
}

0 commit comments

Comments
 (0)