Skip to content

Commit c3bbbcf

Browse files
authored
Merge pull request libgit2#5117 from libgit2/ethomson/to_from
Change API instances of `fromnoun` to `from_noun` (with an underscore)
2 parents 2bdb617 + e45350f commit c3bbbcf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+209
-106
lines changed

examples/blame.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ int lg2_blame(git_repository *repo, int argc, char *argv[])
7272
* Get the raw data inside the blob for output. We use the
7373
* `commitish:path/to/file.txt` format to find it.
7474
*/
75-
if (git_oid_iszero(&blameopts.newest_commit))
75+
if (git_oid_is_zero(&blameopts.newest_commit))
7676
strcpy(spec, "HEAD");
7777
else
7878
git_oid_tostr(spec, sizeof(spec), &blameopts.newest_commit);
@@ -101,7 +101,7 @@ int lg2_blame(git_repository *repo, int argc, char *argv[])
101101
if (hunk) {
102102
char sig[128] = {0};
103103
break_on_null_hunk = 1;
104-
104+
105105
git_oid_tostr(oid, 10, &hunk->final_commit_id);
106106
snprintf(sig, 30, "%s <%s>", hunk->final_signature->name, hunk->final_signature->email);
107107

examples/fetch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static int update_cb(const char *refname, const git_oid *a, const git_oid *b, vo
2121
git_oid_fmt(b_str, b);
2222
b_str[GIT_OID_HEXSZ] = '\0';
2323

24-
if (git_oid_iszero(a)) {
24+
if (git_oid_is_zero(a)) {
2525
printf("[new] %.20s %s\n", b_str, refname);
2626
} else {
2727
git_oid_fmt(a_str, a);

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: 53 additions & 4 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
@@ -167,10 +191,11 @@ GIT_EXTERN(void) giterr_set_oom(void);
167191

168192
/**@}*/
169193

170-
/** @name Deprecated Index Constants
194+
/** @name Deprecated Index Functions and Constants
171195
*
172-
* These enumeration values are retained for backward compatibility.
173-
* The newer versions of these values should be preferred in all new code.
196+
* These functions and enumeration values are retained for backward
197+
* compatibility. The newer versions of these values should be
198+
* preferred in all new code.
174199
*
175200
* There is no plan to remove these backward compatibility values at
176201
* this time.
@@ -210,6 +235,11 @@ GIT_EXTERN(void) giterr_set_oom(void);
210235
#define GIT_INDEXCAP_NO_SYMLINKS GIT_INDEX_CAPABILITY_NO_SYMLINKS
211236
#define GIT_INDEXCAP_FROM_OWNER GIT_INDEX_CAPABILITY_FROM_OWNER
212237

238+
GIT_EXTERN(int) git_index_add_frombuffer(
239+
git_index *index,
240+
const git_index_entry *entry,
241+
const void *buffer, size_t len);
242+
213243
/**@}*/
214244

215245
/** @name Deprecated Object Constants
@@ -263,6 +293,12 @@ GIT_EXTERN(size_t) git_object__size(git_object_t type);
263293
#define GIT_REF_FORMAT_REFSPEC_PATTERN GIT_REFERENCE_FORMAT_REFSPEC_PATTERN
264294
#define GIT_REF_FORMAT_REFSPEC_SHORTHAND GIT_REFERENCE_FORMAT_REFSPEC_SHORTHAND
265295

296+
GIT_EXTERN(int) git_tag_create_frombuffer(
297+
git_oid *oid,
298+
git_repository *repo,
299+
const char *buffer,
300+
int force);
301+
266302
/**@}*/
267303

268304
/** @name Deprecated Credential Callback Types
@@ -273,7 +309,6 @@ GIT_EXTERN(size_t) git_object__size(git_object_t type);
273309
* There is no plan to remove these backward compatibility values at
274310
* this time.
275311
*/
276-
/**@{*/
277312

278313
typedef git_cred_sign_cb git_cred_sign_callback;
279314
typedef git_cred_ssh_interactive_cb git_cred_ssh_interactive_callback;
@@ -294,6 +329,20 @@ typedef git_trace_cb git_trace_callback;
294329

295330
/**@}*/
296331

332+
/** @name Deprecated Object ID Types
333+
*
334+
* These types are retained for backward compatibility. The newer
335+
* versions of these values should be preferred in all new code.
336+
*
337+
* There is no plan to remove these backward compatibility values at
338+
* this time.
339+
*/
340+
/**@{*/
341+
342+
GIT_EXTERN(int) git_oid_iszero(const git_oid *id);
343+
344+
/**@}*/
345+
297346
/** @name Deprecated Transfer Progress Types
298347
*
299348
* These types are retained for backward compatibility. The newer

include/git2/index.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ GIT_EXTERN(int) git_index_add_bypath(git_index *index, const char *path);
572572
* @param len length of the data
573573
* @return 0 or an error code
574574
*/
575-
GIT_EXTERN(int) git_index_add_frombuffer(
575+
GIT_EXTERN(int) git_index_add_from_buffer(
576576
git_index *index,
577577
const git_index_entry *entry,
578578
const void *buffer, size_t len);

include/git2/oid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ GIT_EXTERN(int) git_oid_strcmp(const git_oid *id, const char *str);
207207
*
208208
* @return 1 if all zeros, 0 otherwise.
209209
*/
210-
GIT_EXTERN(int) git_oid_iszero(const git_oid *id);
210+
GIT_EXTERN(int) git_oid_is_zero(const git_oid *id);
211211

212212
/**
213213
* OID Shortener object

include/git2/tag.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ GIT_EXTERN(int) git_tag_annotation_create(
217217
* @param force Overwrite existing tags
218218
* @return 0 on success; error code otherwise
219219
*/
220-
GIT_EXTERN(int) git_tag_create_frombuffer(
220+
GIT_EXTERN(int) git_tag_create_from_buffer(
221221
git_oid *oid,
222222
git_repository *repo,
223223
const char *buffer,

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/blame.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static int normalize_options(
204204
memcpy(out, in, sizeof(git_blame_options));
205205

206206
/* No newest_commit => HEAD */
207-
if (git_oid_iszero(&out->newest_commit)) {
207+
if (git_oid_is_zero(&out->newest_commit)) {
208208
if (git_reference_name_to_id(&out->newest_commit, repo, "HEAD") < 0) {
209209
return -1;
210210
}
@@ -408,7 +408,7 @@ int git_blame_file(
408408

409409
static bool hunk_is_bufferblame(git_blame_hunk *hunk)
410410
{
411-
return git_oid_iszero(&hunk->final_commit_id);
411+
return git_oid_is_zero(&hunk->final_commit_id);
412412
}
413413

414414
static int buffer_hunk_cb(

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+
}

0 commit comments

Comments
 (0)