refs: convert read_ref_at to struct object_id
Convert the callers and internals, including struct read_ref_at_cb, of read_ref_at to use struct object_id. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Oct 15, 2017 at 22:07 UTC
8eb36d9422a04a30ecc54fd69b4f836eafd10637
4 files changed
+21
-21
builtin/show-branch.c
+2
-2
@@ -731,7 +731,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
731
/* Ah, that is a date spec... */
732
timestamp_t at;
733
at = approxidate(reflog_base);
734
- read_ref_at(ref, flags, at, -1, oid.hash, NULL,
734
+ read_ref_at(ref, flags, at, -1, &oid, NULL,
735
NULL, NULL, &base);
736
}
737
}
@@ -743,7 +743,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
743
timestamp_t timestamp;
744
int tz;
745
746
- if (read_ref_at(ref, flags, 0, base+i, oid.hash, &logmsg,
746
+ if (read_ref_at(ref, flags, 0, base + i, &oid, &logmsg,
747
×tamp, &tz, NULL)) {
748
reflog = i;
749
break;
refs.c
+17
-17
@@ -738,11 +738,11 @@ struct read_ref_at_cb {
738
timestamp_t at_time;
739
int cnt;
740
int reccnt;
741
- unsigned char *sha1;
741
+ struct object_id *oid;
742
int found_it;
743
744
- unsigned char osha1[20];
745
- unsigned char nsha1[20];
744
+ struct object_id ooid;
745
+ struct object_id noid;
746
int tz;
747
timestamp_t date;
748
char **msg;
@@ -774,25 +774,25 @@ static int read_ref_at_ent(struct object_id *ooid, struct object_id *noid,
774
* we have not yet updated cb->[n|o]sha1 so they still
775
* hold the values for the previous record.
776
*/
777
- if (!is_null_sha1(cb->osha1)) {
778
- hashcpy(cb->sha1, noid->hash);
779
- if (hashcmp(cb->osha1, noid->hash))
777
+ if (!is_null_oid(&cb->ooid)) {
778
+ oidcpy(cb->oid, noid);
779
+ if (oidcmp(&cb->ooid, noid))
780
warning("Log for ref %s has gap after %s.",
781
cb->refname, show_date(cb->date, cb->tz, DATE_MODE(RFC2822)));
782
}
783
else if (cb->date == cb->at_time)
784
- hashcpy(cb->sha1, noid->hash);
785
- else if (hashcmp(noid->hash, cb->sha1))
784
+ oidcpy(cb->oid, noid);
785
+ else if (oidcmp(noid, cb->oid))
786
warning("Log for ref %s unexpectedly ended on %s.",
787
cb->refname, show_date(cb->date, cb->tz,
788
DATE_MODE(RFC2822)));
789
- hashcpy(cb->osha1, ooid->hash);
790
- hashcpy(cb->nsha1, noid->hash);
789
+ oidcpy(&cb->ooid, ooid);
790
+ oidcpy(&cb->noid, noid);
791
cb->found_it = 1;
792
return 1;
793
}
794
- hashcpy(cb->osha1, ooid->hash);
795
- hashcpy(cb->nsha1, noid->hash);
794
+ oidcpy(&cb->ooid, ooid);
795
+ oidcpy(&cb->noid, noid);
796
if (cb->cnt > 0)
797
cb->cnt--;
798
return 0;
@@ -812,15 +812,15 @@ static int read_ref_at_ent_oldest(struct object_id *ooid, struct object_id *noid
812
*cb->cutoff_tz = tz;
813
if (cb->cutoff_cnt)
814
*cb->cutoff_cnt = cb->reccnt;
815
- hashcpy(cb->sha1, ooid->hash);
816
- if (is_null_sha1(cb->sha1))
817
- hashcpy(cb->sha1, noid->hash);
815
+ oidcpy(cb->oid, ooid);
816
+ if (is_null_oid(cb->oid))
817
+ oidcpy(cb->oid, noid);
818
/* We just want the first entry */
819
return 1;
820
}
821
822
int read_ref_at(const char *refname, unsigned int flags, timestamp_t at_time, int cnt,
823
- unsigned char *sha1, char **msg,
823
+ struct object_id *oid, char **msg,
824
timestamp_t *cutoff_time, int *cutoff_tz, int *cutoff_cnt)
825
{
826
struct read_ref_at_cb cb;
@@ -833,7 +833,7 @@ int read_ref_at(const char *refname, unsigned int flags, timestamp_t at_time, in
833
cb.cutoff_time = cutoff_time;
834
cb.cutoff_tz = cutoff_tz;
835
cb.cutoff_cnt = cutoff_cnt;
836
- cb.sha1 = sha1;
836
+ cb.oid = oid;
837
838
for_each_reflog_ent_reverse(refname, read_ref_at_ent, &cb);
839
refs.h
+1
-1
@@ -363,7 +363,7 @@ int safe_create_reflog(const char *refname, int force_create, struct strbuf *err
363
/** Reads log for the value of ref during at_time. **/
364
int read_ref_at(const char *refname, unsigned int flags,
365
timestamp_t at_time, int cnt,
366
- unsigned char *sha1, char **msg,
366
+ struct object_id *oid, char **msg,
367
timestamp_t *cutoff_time, int *cutoff_tz, int *cutoff_cnt);
368
369
/** Check if a particular reflog exists */
sha1_name.c
+1
-1
@@ -697,7 +697,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
697
return -1;
698
}
699
}
700
- if (read_ref_at(real_ref, flags, at_time, nth, oid->hash, NULL,
700
+ if (read_ref_at(real_ref, flags, at_time, nth, oid, NULL,
701
&co_time, &co_tz, &co_cnt)) {
702
if (!len) {
703
if (starts_with(real_ref, "refs/heads/")) {