Skip to content

Commit 5d92e54

Browse files
committed
oid: is_zero instead of iszero
The only function that is named `issomething` (without underscore) was `git_oid_iszero`. Rename it to `git_oid_is_zero` for consistency with the rest of the library.
1 parent fef847a commit 5d92e54

File tree

20 files changed

+67
-49
lines changed

20 files changed

+67
-49
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/deprecated.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ GIT_EXTERN(void) giterr_set_oom(void);
271271
* There is no plan to remove these backward compatibility values at
272272
* this time.
273273
*/
274-
/**@{*/
275274

276275
typedef git_cred_sign_cb git_cred_sign_callback;
277276
typedef git_cred_ssh_interactive_cb git_cred_ssh_interactive_callback;
@@ -292,6 +291,20 @@ typedef git_trace_cb git_trace_callback;
292291

293292
/**@}*/
294293

294+
/** @name Deprecated Object ID Types
295+
*
296+
* These types are retained for backward compatibility. The newer
297+
* versions of these values should be preferred in all new code.
298+
*
299+
* There is no plan to remove these backward compatibility values at
300+
* this time.
301+
*/
302+
/**@{*/
303+
304+
GIT_EXTERN(int) git_oid_iszero(const git_oid *id);
305+
306+
/**@}*/
307+
295308
/** @name Deprecated Transfer Progress Types
296309
*
297310
* These types are retained for backward compatibility. The newer

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static int diff_file_content_load_blob(
232232
int error = 0;
233233
git_odb_object *odb_obj = NULL;
234234

235-
if (git_oid_iszero(&fc->file->id))
235+
if (git_oid_is_zero(&fc->file->id))
236236
return 0;
237237

238238
if (fc->file->mode == GIT_FILEMODE_COMMIT)

src/diff_generate.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ static int diff_delta__from_one(
179179

180180
delta->old_file.flags |= GIT_DIFF_FLAG_VALID_ID;
181181

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

185185
return diff_insert_delta(diff, delta, matched_pathspec);
@@ -240,7 +240,7 @@ static int diff_delta__from_two(
240240
delta->old_file.flags |= GIT_DIFF_FLAG_EXISTS;
241241
delta->new_file.flags |= GIT_DIFF_FLAG_EXISTS;
242242

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

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

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

878878
return diff_delta__from_two(
879879
diff, status, oitem, omode, nitem, nmode,
880-
git_oid_iszero(&noid) ? NULL : &noid, matched_pathspec);
880+
git_oid_is_zero(&noid) ? NULL : &noid, matched_pathspec);
881881
}
882882

883883
static bool entry_is_prefixed(

src/diff_print.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,10 @@ static int diff_delta_format_with_paths(
325325
const char *oldpath,
326326
const char *newpath)
327327
{
328-
if (git_oid_iszero(&delta->old_file.id))
328+
if (git_oid_is_zero(&delta->old_file.id))
329329
oldpath = "/dev/null";
330330

331-
if (git_oid_iszero(&delta->new_file.id))
331+
if (git_oid_is_zero(&delta->new_file.id))
332332
newpath = "/dev/null";
333333

334334
return git_buf_printf(out, template, oldpath, newpath);
@@ -381,8 +381,8 @@ int diff_delta_format_similarity_header(
381381

382382
static bool delta_is_unchanged(const git_diff_delta *delta)
383383
{
384-
if (git_oid_iszero(&delta->old_file.id) &&
385-
git_oid_iszero(&delta->new_file.id))
384+
if (git_oid_is_zero(&delta->old_file.id) &&
385+
git_oid_is_zero(&delta->new_file.id))
386386
return true;
387387

388388
if (delta->old_file.mode == GIT_FILEMODE_COMMIT ||

src/diff_tform.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,13 +560,13 @@ static int similarity_measure(
560560

561561
/* if exact match is requested, force calculation of missing OIDs now */
562562
if (exact_match) {
563-
if (git_oid_iszero(&a_file->id) &&
563+
if (git_oid_is_zero(&a_file->id) &&
564564
diff->old_src == GIT_ITERATOR_TYPE_WORKDIR &&
565565
!git_diff__oid_for_file(&a_file->id,
566566
diff, a_file->path, a_file->mode, a_file->size))
567567
a_file->flags |= GIT_DIFF_FLAG_VALID_ID;
568568

569-
if (git_oid_iszero(&b_file->id) &&
569+
if (git_oid_is_zero(&b_file->id) &&
570570
diff->new_src == GIT_ITERATOR_TYPE_WORKDIR &&
571571
!git_diff__oid_for_file(&b_file->id,
572572
diff, b_file->path, b_file->mode, b_file->size))

src/filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ uint16_t git_filter_source_filemode(const git_filter_source *src)
385385

386386
const git_oid *git_filter_source_id(const git_filter_source *src)
387387
{
388-
return git_oid_iszero(&src->oid) ? NULL : &src->oid;
388+
return git_oid_is_zero(&src->oid) ? NULL : &src->oid;
389389
}
390390

391391
git_filter_mode_t git_filter_source_mode(const git_filter_source *src)

0 commit comments

Comments
 (0)