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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
diff --git a/include/git2/blob.h b/include/git2/blob.h
index ff1a481..072522d 100644
--- a/include/git2/blob.h
+++ b/include/git2/blob.h
@@ -136,7 +136,7 @@ GIT_EXTERN(int) git_blob_filtered_content(
* relative to the repository's working dir
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_blob_create_fromworkdir(git_oid *id, git_repository *repo, const char *relative_path);
+GIT_EXTERN(int) git_blob_create_from_workdir(git_oid *id, git_repository *repo, const char *relative_path);
/**
* Read a file from the filesystem and write its content
@@ -148,7 +148,7 @@ GIT_EXTERN(int) git_blob_create_fromworkdir(git_oid *id, git_repository *repo, c
* @param path file from which the blob will be created
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *id, git_repository *repo, const char *path);
+GIT_EXTERN(int) git_blob_create_from_disk(git_oid *id, git_repository *repo, const char *path);
/**
* Create a stream to write a new blob into the object db
@@ -156,12 +156,12 @@ GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *id, git_repository *repo, cons
* This function may need to buffer the data on disk and will in
* general not be the right choice if you know the size of the data
* to write. If you have data in memory, use
- * `git_blob_create_frombuffer()`. If you do not, but know the size of
+ * `git_blob_create_from_buffer()`. If you do not, but know the size of
* the contents (and don't want/need to perform filtering), use
* `git_odb_open_wstream()`.
*
* Don't close this stream yourself but pass it to
- * `git_blob_create_fromstream_commit()` to commit the write to the
+ * `git_blob_create_from_stream_commit()` to commit the write to the
* object db and get the object id.
*
* 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
* to apply onto the content of the blob to be created.
* @return 0 or error code
*/
-GIT_EXTERN(int) git_blob_create_fromstream(
+GIT_EXTERN(int) git_blob_create_from_stream(
git_writestream **out,
git_repository *repo,
const char *hintpath);
@@ -189,7 +189,7 @@ GIT_EXTERN(int) git_blob_create_fromstream(
* @param stream the stream to close
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_blob_create_fromstream_commit(
+GIT_EXTERN(int) git_blob_create_from_stream_commit(
git_oid *out,
git_writestream *stream);
@@ -202,7 +202,7 @@ GIT_EXTERN(int) git_blob_create_fromstream_commit(
* @param len length of the data
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_blob_create_frombuffer(
+GIT_EXTERN(int) git_blob_create_from_buffer(
git_oid *id, git_repository *repo, const void *buffer, size_t len);
/**
diff --git a/include/git2/deprecated.h b/include/git2/deprecated.h
index 108d422..7c0a6e4 100644
--- a/include/git2/deprecated.h
+++ b/include/git2/deprecated.h
@@ -45,6 +45,30 @@
*/
GIT_BEGIN_DECL
+/** @name Deprecated Blob Functions
+ *
+ * These functions are retained for backward compatibility. The newer
+ * versions of these functions should be preferred in all new code.
+ *
+ * There is no plan to remove these backward compatibility values at
+ * this time.
+ */
+/**@{*/
+
+GIT_EXTERN(int) git_blob_create_fromworkdir(git_oid *id, git_repository *repo, const char *relative_path);
+GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *id, git_repository *repo, const char *path);
+GIT_EXTERN(int) git_blob_create_fromstream(
+ git_writestream **out,
+ git_repository *repo,
+ const char *hintpath);
+GIT_EXTERN(int) git_blob_create_fromstream_commit(
+ git_oid *out,
+ git_writestream *stream);
+GIT_EXTERN(int) git_blob_create_frombuffer(
+ git_oid *id, git_repository *repo, const void *buffer, size_t len);
+
+/**@}*/
+
/** @name Deprecated Buffer Functions
*
* These functions and enumeration values are retained for backward
diff --git a/src/apply.c b/src/apply.c
index fdafa66..f876e43 100644
--- a/src/apply.c
+++ b/src/apply.c
@@ -532,7 +532,7 @@ static int apply_one(
if (delta->status != GIT_DELTA_DELETED) {
if ((error = git_apply__patch(&post_contents, &filename, &mode,
pre_contents.ptr, pre_contents.size, patch, opts)) < 0 ||
- (error = git_blob_create_frombuffer(&post_id, repo,
+ (error = git_blob_create_from_buffer(&post_id, repo,
post_contents.ptr, post_contents.size)) < 0)
goto done;
diff --git a/src/blob.c b/src/blob.c
index 566d24b..31e6ccf 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -70,7 +70,7 @@ int git_blob__parse(void *_blob, git_odb_object *odb_obj)
return 0;
}
-int git_blob_create_frombuffer(
+int git_blob_create_from_buffer(
git_oid *id, git_repository *repo, const void *buffer, size_t len)
{
int error;
@@ -263,13 +263,13 @@ done:
return error;
}
-int git_blob_create_fromworkdir(
+int git_blob_create_from_workdir(
git_oid *id, git_repository *repo, const char *path)
{
return git_blob__create_from_paths(id, NULL, repo, NULL, path, 0, true);
}
-int git_blob_create_fromdisk(
+int git_blob_create_from_disk(
git_oid *id, git_repository *repo, const char *path)
{
int error;
@@ -325,7 +325,7 @@ static int blob_writestream_write(git_writestream *_stream, const char *buffer,
return git_filebuf_write(&stream->fbuf, buffer, len);
}
-int git_blob_create_fromstream(git_writestream **out, git_repository *repo, const char *hintpath)
+int git_blob_create_from_stream(git_writestream **out, git_repository *repo, const char *hintpath)
{
int error;
git_buf path = GIT_BUF_INIT;
@@ -364,7 +364,7 @@ cleanup:
return error;
}
-int git_blob_create_fromstream_commit(git_oid *out, git_writestream *_stream)
+int git_blob_create_from_stream_commit(git_oid *out, git_writestream *_stream)
{
int error;
blob_writestream *stream = (blob_writestream *) _stream;
@@ -427,3 +427,36 @@ int git_blob_filtered_content(
return error;
}
+
+/* Deprecated functions */
+
+int git_blob_create_frombuffer(
+ git_oid *id, git_repository *repo, const void *buffer, size_t len)
+{
+ return git_blob_create_from_buffer(id, repo, buffer, len);
+}
+
+int git_blob_create_fromworkdir(git_oid *id, git_repository *repo, const char *relative_path)
+{
+ return git_blob_create_from_workdir(id, repo, relative_path);
+}
+
+int git_blob_create_fromdisk(git_oid *id, git_repository *repo, const char *path)
+{
+ return git_blob_create_from_disk(id, repo, path);
+}
+
+int git_blob_create_fromstream(
+ git_writestream **out,
+ git_repository *repo,
+ const char *hintpath)
+{
+ return git_blob_create_from_stream(out, repo, hintpath);
+}
+
+int git_blob_create_fromstream_commit(
+ git_oid *out,
+ git_writestream *stream)
+{
+ return git_blob_create_from_stream_commit(out, stream);
+}
diff --git a/src/index.c b/src/index.c
index ee8dfd5..ec43433 100644
--- a/src/index.c
+++ b/src/index.c
@@ -1477,7 +1477,7 @@ int git_index_add_frombuffer(
if (index_entry_dup(&entry, index, source_entry) < 0)
return -1;
- error = git_blob_create_frombuffer(&id, INDEX_OWNER(index), buffer, len);
+ error = git_blob_create_from_buffer(&id, INDEX_OWNER(index), buffer, len);
if (error < 0) {
index_entry_free(entry);
return error;
diff --git a/src/notes.c b/src/notes.c
index 8e622c6..5028107 100644
--- a/src/notes.c
+++ b/src/notes.c
@@ -288,7 +288,7 @@ static int note_write(
/* TODO: should we apply filters? */
/* create note object */
- if ((error = git_blob_create_frombuffer(&oid, repo, note, strlen(note))) < 0)
+ if ((error = git_blob_create_from_buffer(&oid, repo, note, strlen(note))) < 0)
goto cleanup;
if ((error = manipulate_note_in_tree_r(
diff --git a/tests/filter/blob.c b/tests/filter/blob.c
index 6e30e20..22f3503 100644
--- a/tests/filter/blob.c
+++ b/tests/filter/blob.c
@@ -87,14 +87,14 @@ void test_filter_blob__ident(void)
git_buf buf = { 0 };
cl_git_mkfile("crlf/test.ident", "Some text\n$Id$\nGoes there\n");
- cl_git_pass(git_blob_create_fromworkdir(&id, g_repo, "test.ident"));
+ cl_git_pass(git_blob_create_from_workdir(&id, g_repo, "test.ident"));
cl_git_pass(git_blob_lookup(&blob, g_repo, &id));
cl_assert_equal_s(
"Some text\n$Id$\nGoes there\n", git_blob_rawcontent(blob));
git_blob_free(blob);
cl_git_mkfile("crlf/test.ident", "Some text\n$Id: Any old just you want$\nGoes there\n");
- cl_git_pass(git_blob_create_fromworkdir(&id, g_repo, "test.ident"));
+ cl_git_pass(git_blob_create_from_workdir(&id, g_repo, "test.ident"));
cl_git_pass(git_blob_lookup(&blob, g_repo, &id));
cl_assert_equal_s(
"Some text\n$Id$\nGoes there\n", git_blob_rawcontent(blob));
diff --git a/tests/filter/ident.c b/tests/filter/ident.c
index cee0cc2..ed2e467 100644
--- a/tests/filter/ident.c
+++ b/tests/filter/ident.c
@@ -23,7 +23,7 @@ static void add_blob_and_filter(
git_buf out = { 0 };
cl_git_mkfile("crlf/identtest", data);
- cl_git_pass(git_blob_create_fromworkdir(&id, g_repo, "identtest"));
+ cl_git_pass(git_blob_create_from_workdir(&id, g_repo, "identtest"));
cl_git_pass(git_blob_lookup(&blob, g_repo, &id));
cl_git_pass(git_filter_list_apply_to_blob(&out, fl, blob));
diff --git a/tests/merge/merge_helpers.c b/tests/merge/merge_helpers.c
index 1b68bdc..cddb411 100644
--- a/tests/merge/merge_helpers.c
+++ b/tests/merge/merge_helpers.c
@@ -352,7 +352,7 @@ int merge_test_workdir(git_repository *repo, const struct merge_index_entry expe
return 0;
for (i = 0; i < expected_len; i++) {
- git_blob_create_fromworkdir(&actual_oid, repo, expected[i].path);
+ git_blob_create_from_workdir(&actual_oid, repo, expected[i].path);
git_oid_fromstr(&expected_oid, expected[i].oid_str);
if (git_oid_cmp(&actual_oid, &expected_oid) != 0)
diff --git a/tests/object/blob/filter.c b/tests/object/blob/filter.c
index 002177c..45dbc92 100644
--- a/tests/object/blob/filter.c
+++ b/tests/object/blob/filter.c
@@ -59,7 +59,7 @@ void test_object_blob_filter__initialize(void)
if (g_crlf_raw_len[i] < 0)
g_crlf_raw_len[i] = strlen(g_crlf_raw[i]);
- cl_git_pass(git_blob_create_frombuffer(
+ cl_git_pass(git_blob_create_from_buffer(
&g_crlf_oids[i], g_repo, g_crlf_raw[i], (size_t)g_crlf_raw_len[i]));
}
}
diff --git a/tests/object/blob/fromstream.c b/tests/object/blob/fromstream.c
index 60090b6..416b452 100644
--- a/tests/object/blob/fromstream.c
+++ b/tests/object/blob/fromstream.c
@@ -29,12 +29,12 @@ void test_object_blob_fromstream__multiple_write(void)
cl_git_fail_with(GIT_ENOTFOUND,
git_object_lookup(&blob, repo, &expected_id, GIT_OBJECT_ANY));
- cl_git_pass(git_blob_create_fromstream(&stream, repo, NULL));
+ cl_git_pass(git_blob_create_from_stream(&stream, repo, NULL));
for (i = 0; i < howmany; i++)
cl_git_pass(stream->write(stream, textual_content, strlen(textual_content)));
- cl_git_pass(git_blob_create_fromstream_commit(&id, stream));
+ cl_git_pass(git_blob_create_from_stream_commit(&id, stream));
cl_assert_equal_oid(&expected_id, &id);
cl_git_pass(git_object_lookup(&blob, repo, &expected_id, GIT_OBJECT_BLOB));
@@ -67,12 +67,12 @@ static void assert_named_chunked_blob(const char *expected_sha, const char *fake
cl_git_pass(git_oid_fromstr(&expected_id, expected_sha));
- cl_git_pass(git_blob_create_fromstream(&stream, repo, fake_name));
+ cl_git_pass(git_blob_create_from_stream(&stream, repo, fake_name));
for (i = 0; i < howmany; i++)
cl_git_pass(stream->write(stream, textual_content, strlen(textual_content)));
- cl_git_pass(git_blob_create_fromstream_commit(&id, stream));
+ cl_git_pass(git_blob_create_from_stream_commit(&id, stream));
cl_assert_equal_oid(&expected_id, &id);
}
diff --git a/tests/object/blob/write.c b/tests/object/blob/write.c
index 4cf5a66..e6b67fb 100644
--- a/tests/object/blob/write.c
+++ b/tests/object/blob/write.c
@@ -33,7 +33,7 @@ void test_object_blob_write__can_create_a_blob_in_a_standard_repo_from_a_file_lo
{
repo = cl_git_sandbox_init(WORKDIR);
- assert_blob_creation(WORKDIR "/test.txt", "test.txt", &git_blob_create_fromworkdir);
+ assert_blob_creation(WORKDIR "/test.txt", "test.txt", &git_blob_create_from_workdir);
}
void test_object_blob_write__can_create_a_blob_in_a_standard_repo_from_a_absolute_filepath_pointing_outside_of_the_working_directory(void)
@@ -46,7 +46,7 @@ void test_object_blob_write__can_create_a_blob_in_a_standard_repo_from_a_absolut
cl_must_pass(git_path_prettify_dir(&full_path, ELSEWHERE, NULL));
cl_must_pass(git_buf_puts(&full_path, "test.txt"));
- assert_blob_creation(ELSEWHERE "/test.txt", git_buf_cstr(&full_path), &git_blob_create_fromdisk);
+ assert_blob_creation(ELSEWHERE "/test.txt", git_buf_cstr(&full_path), &git_blob_create_from_disk);
git_buf_dispose(&full_path);
cl_must_pass(git_futils_rmdir_r(ELSEWHERE, NULL, GIT_RMDIR_REMOVE_FILES));
@@ -62,7 +62,7 @@ void test_object_blob_write__can_create_a_blob_in_a_bare_repo_from_a_absolute_fi
cl_must_pass(git_path_prettify_dir(&full_path, ELSEWHERE, NULL));
cl_must_pass(git_buf_puts(&full_path, "test.txt"));
- assert_blob_creation(ELSEWHERE "/test.txt", git_buf_cstr(&full_path), &git_blob_create_fromdisk);
+ assert_blob_creation(ELSEWHERE "/test.txt", git_buf_cstr(&full_path), &git_blob_create_from_disk);
git_buf_dispose(&full_path);
cl_must_pass(git_futils_rmdir_r(ELSEWHERE, NULL, GIT_RMDIR_REMOVE_FILES));
diff --git a/tests/odb/backend/mempack.c b/tests/odb/backend/mempack.c
index 55cd69f..2eeed51 100644
--- a/tests/odb/backend/mempack.c
+++ b/tests/odb/backend/mempack.c
@@ -51,10 +51,10 @@ void test_odb_backend_mempack__exists_with_existing_objects_succeeds(void)
cl_assert(git_odb_exists(_odb, &_oid) == 1);
}
-void test_odb_backend_mempack__blob_create_frombuffer_succeeds(void)
+void test_odb_backend_mempack__blob_create_from_buffer_succeeds(void)
{
const char *data = "data";
- cl_git_pass(git_blob_create_frombuffer(&_oid, _repo, data, strlen(data) + 1));
+ cl_git_pass(git_blob_create_from_buffer(&_oid, _repo, data, strlen(data) + 1));
cl_assert(git_odb_exists(_odb, &_oid) == 1);
}
diff --git a/tests/odb/freshen.c b/tests/odb/freshen.c
index 1fe6430..1ecd92a 100644
--- a/tests/odb/freshen.c
+++ b/tests/odb/freshen.c
@@ -47,7 +47,7 @@ void test_odb_freshen__loose_blob(void)
set_time_wayback(&before, LOOSE_BLOB_FN);
/* make sure we freshen a blob */
- cl_git_pass(git_blob_create_frombuffer(&id, repo, LOOSE_STR, CONST_STRLEN(LOOSE_STR)));
+ cl_git_pass(git_blob_create_from_buffer(&id, repo, LOOSE_STR, CONST_STRLEN(LOOSE_STR)));
cl_assert_equal_oid(&expected_id, &id);
cl_must_pass(p_lstat("testrepo.git/objects/" LOOSE_BLOB_FN, &after));
@@ -66,13 +66,13 @@ void test_odb_freshen__readonly_object(void)
cl_git_pass(git_oid_fromstr(&expected_id, UNIQUE_BLOB_ID));
- cl_git_pass(git_blob_create_frombuffer(&id, repo, UNIQUE_STR, CONST_STRLEN(UNIQUE_STR)));
+ cl_git_pass(git_blob_create_from_buffer(&id, repo, UNIQUE_STR, CONST_STRLEN(UNIQUE_STR)));
cl_assert_equal_oid(&expected_id, &id);
set_time_wayback(&before, UNIQUE_BLOB_FN);
cl_assert((before.st_mode & S_IWUSR) == 0);
- cl_git_pass(git_blob_create_frombuffer(&id, repo, UNIQUE_STR, CONST_STRLEN(UNIQUE_STR)));
+ cl_git_pass(git_blob_create_from_buffer(&id, repo, UNIQUE_STR, CONST_STRLEN(UNIQUE_STR)));
cl_assert_equal_oid(&expected_id, &id);
cl_must_pass(p_lstat("testrepo.git/objects/" UNIQUE_BLOB_FN, &after));