Skip to content

Commit

Permalink
Merge pull request #5117 from libgit2/ethomson/to_from
Browse files Browse the repository at this point in the history
Change API instances of `fromnoun` to `from_noun` (with an underscore)
  • Loading branch information
pks-t committed Jun 16, 2019
2 parents 2bdb617 + e45350f commit c3bbbcf
Show file tree
Hide file tree
Showing 41 changed files with 209 additions and 106 deletions.
4 changes: 2 additions & 2 deletions examples/blame.c
Expand Up @@ -72,7 +72,7 @@ int lg2_blame(git_repository *repo, int argc, char *argv[])
* Get the raw data inside the blob for output. We use the
* `commitish:path/to/file.txt` format to find it.
*/
if (git_oid_iszero(&blameopts.newest_commit))
if (git_oid_is_zero(&blameopts.newest_commit))
strcpy(spec, "HEAD");
else
git_oid_tostr(spec, sizeof(spec), &blameopts.newest_commit);
Expand Down Expand Up @@ -101,7 +101,7 @@ int lg2_blame(git_repository *repo, int argc, char *argv[])
if (hunk) {
char sig[128] = {0};
break_on_null_hunk = 1;

git_oid_tostr(oid, 10, &hunk->final_commit_id);
snprintf(sig, 30, "%s <%s>", hunk->final_signature->name, hunk->final_signature->email);

Expand Down
2 changes: 1 addition & 1 deletion examples/fetch.c
Expand Up @@ -21,7 +21,7 @@ static int update_cb(const char *refname, const git_oid *a, const git_oid *b, vo
git_oid_fmt(b_str, b);
b_str[GIT_OID_HEXSZ] = '\0';

if (git_oid_iszero(a)) {
if (git_oid_is_zero(a)) {
printf("[new] %.20s %s\n", b_str, refname);
} else {
git_oid_fmt(a_str, a);
Expand Down
14 changes: 7 additions & 7 deletions include/git2/blob.h
Expand Up @@ -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
Expand All @@ -148,20 +148,20 @@ 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
*
* 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
Expand All @@ -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);
Expand All @@ -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);

Expand All @@ -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);

/**
Expand Down
57 changes: 53 additions & 4 deletions include/git2/deprecated.h
Expand Up @@ -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
Expand Down Expand Up @@ -167,10 +191,11 @@ GIT_EXTERN(void) giterr_set_oom(void);

/**@}*/

/** @name Deprecated Index Constants
/** @name Deprecated Index Functions and Constants
*
* These enumeration values are retained for backward compatibility.
* The newer versions of these values should be preferred in all new code.
* These functions and enumeration values are retained for backward
* compatibility. The newer versions of these values should be
* preferred in all new code.
*
* There is no plan to remove these backward compatibility values at
* this time.
Expand Down Expand Up @@ -210,6 +235,11 @@ GIT_EXTERN(void) giterr_set_oom(void);
#define GIT_INDEXCAP_NO_SYMLINKS GIT_INDEX_CAPABILITY_NO_SYMLINKS
#define GIT_INDEXCAP_FROM_OWNER GIT_INDEX_CAPABILITY_FROM_OWNER

GIT_EXTERN(int) git_index_add_frombuffer(
git_index *index,
const git_index_entry *entry,
const void *buffer, size_t len);

/**@}*/

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

GIT_EXTERN(int) git_tag_create_frombuffer(
git_oid *oid,
git_repository *repo,
const char *buffer,
int force);

/**@}*/

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

typedef git_cred_sign_cb git_cred_sign_callback;
typedef git_cred_ssh_interactive_cb git_cred_ssh_interactive_callback;
Expand All @@ -294,6 +329,20 @@ typedef git_trace_cb git_trace_callback;

/**@}*/

/** @name Deprecated Object ID Types
*
* These types are retained for backward compatibility. The newer
* versions of these values should be preferred in all new code.
*
* There is no plan to remove these backward compatibility values at
* this time.
*/
/**@{*/

GIT_EXTERN(int) git_oid_iszero(const git_oid *id);

/**@}*/

/** @name Deprecated Transfer Progress Types
*
* These types are retained for backward compatibility. The newer
Expand Down
2 changes: 1 addition & 1 deletion include/git2/index.h
Expand Up @@ -572,7 +572,7 @@ GIT_EXTERN(int) git_index_add_bypath(git_index *index, const char *path);
* @param len length of the data
* @return 0 or an error code
*/
GIT_EXTERN(int) git_index_add_frombuffer(
GIT_EXTERN(int) git_index_add_from_buffer(
git_index *index,
const git_index_entry *entry,
const void *buffer, size_t len);
Expand Down
2 changes: 1 addition & 1 deletion include/git2/oid.h
Expand Up @@ -207,7 +207,7 @@ GIT_EXTERN(int) git_oid_strcmp(const git_oid *id, const char *str);
*
* @return 1 if all zeros, 0 otherwise.
*/
GIT_EXTERN(int) git_oid_iszero(const git_oid *id);
GIT_EXTERN(int) git_oid_is_zero(const git_oid *id);

/**
* OID Shortener object
Expand Down
2 changes: 1 addition & 1 deletion include/git2/tag.h
Expand Up @@ -217,7 +217,7 @@ GIT_EXTERN(int) git_tag_annotation_create(
* @param force Overwrite existing tags
* @return 0 on success; error code otherwise
*/
GIT_EXTERN(int) git_tag_create_frombuffer(
GIT_EXTERN(int) git_tag_create_from_buffer(
git_oid *oid,
git_repository *repo,
const char *buffer,
Expand Down
2 changes: 1 addition & 1 deletion src/apply.c
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/blame.c
Expand Up @@ -204,7 +204,7 @@ static int normalize_options(
memcpy(out, in, sizeof(git_blame_options));

/* No newest_commit => HEAD */
if (git_oid_iszero(&out->newest_commit)) {
if (git_oid_is_zero(&out->newest_commit)) {
if (git_reference_name_to_id(&out->newest_commit, repo, "HEAD") < 0) {
return -1;
}
Expand Down Expand Up @@ -408,7 +408,7 @@ int git_blame_file(

static bool hunk_is_bufferblame(git_blame_hunk *hunk)
{
return git_oid_iszero(&hunk->final_commit_id);
return git_oid_is_zero(&hunk->final_commit_id);
}

static int buffer_hunk_cb(
Expand Down
43 changes: 38 additions & 5 deletions src/blob.c
Expand Up @@ -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;
Expand Down Expand Up @@ -263,13 +263,13 @@ int git_blob__create_from_paths(
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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -364,7 +364,7 @@ int git_blob_create_fromstream(git_writestream **out, git_repository *repo, cons
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;
Expand Down Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion src/diff_file.c
Expand Up @@ -232,7 +232,7 @@ static int diff_file_content_load_blob(
int error = 0;
git_odb_object *odb_obj = NULL;

if (git_oid_iszero(&fc->file->id))
if (git_oid_is_zero(&fc->file->id))
return 0;

if (fc->file->mode == GIT_FILEMODE_COMMIT)
Expand Down
12 changes: 6 additions & 6 deletions src/diff_generate.c
Expand Up @@ -179,7 +179,7 @@ static int diff_delta__from_one(

delta->old_file.flags |= GIT_DIFF_FLAG_VALID_ID;

if (has_old || !git_oid_iszero(&delta->new_file.id))
if (has_old || !git_oid_is_zero(&delta->new_file.id))
delta->new_file.flags |= GIT_DIFF_FLAG_VALID_ID;

return diff_insert_delta(diff, delta, matched_pathspec);
Expand Down Expand Up @@ -240,7 +240,7 @@ static int diff_delta__from_two(
delta->old_file.flags |= GIT_DIFF_FLAG_EXISTS;
delta->new_file.flags |= GIT_DIFF_FLAG_EXISTS;

if (!git_oid_iszero(&new_entry->id))
if (!git_oid_is_zero(&new_entry->id))
delta->new_file.flags |= GIT_DIFF_FLAG_VALID_ID;
}

Expand Down Expand Up @@ -797,13 +797,13 @@ static int maybe_modified(
/* if oids and modes match (and are valid), then file is unmodified */
} else if (git_oid_equal(&oitem->id, &nitem->id) &&
omode == nmode &&
!git_oid_iszero(&oitem->id)) {
!git_oid_is_zero(&oitem->id)) {
status = GIT_DELTA_UNMODIFIED;

/* if we have an unknown OID and a workdir iterator, then check some
* circumstances that can accelerate things or need special handling
*/
} else if (git_oid_iszero(&nitem->id) && new_is_workdir) {
} else if (git_oid_is_zero(&nitem->id) && new_is_workdir) {
bool use_ctime =
((diff->diffcaps & GIT_DIFFCAPS_TRUST_CTIME) != 0);
git_index *index = git_iterator_index(info->new_iter);
Expand Down Expand Up @@ -843,7 +843,7 @@ static int maybe_modified(
/* if we got here and decided that the files are modified, but we
* haven't calculated the OID of the new item, then calculate it now
*/
if (modified_uncertain && git_oid_iszero(&nitem->id)) {
if (modified_uncertain && git_oid_is_zero(&nitem->id)) {
const git_oid *update_check =
DIFF_FLAG_IS_SET(diff, GIT_DIFF_UPDATE_INDEX) && omode == nmode ?
&oitem->id : NULL;
Expand Down Expand Up @@ -877,7 +877,7 @@ static int maybe_modified(

return diff_delta__from_two(
diff, status, oitem, omode, nitem, nmode,
git_oid_iszero(&noid) ? NULL : &noid, matched_pathspec);
git_oid_is_zero(&noid) ? NULL : &noid, matched_pathspec);
}

static bool entry_is_prefixed(
Expand Down

0 comments on commit c3bbbcf

Please sign in to comment.