Skip to content

Commit 8eb36d9

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b420d90 commit 8eb36d9

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

builtin/show-branch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
731731
/* Ah, that is a date spec... */
732732
timestamp_t at;
733733
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,
735735
NULL, NULL, &base);
736736
}
737737
}
@@ -743,7 +743,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
743743
timestamp_t timestamp;
744744
int tz;
745745

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,
747747
&timestamp, &tz, NULL)) {
748748
reflog = i;
749749
break;

refs.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -738,11 +738,11 @@ struct read_ref_at_cb {
738738
timestamp_t at_time;
739739
int cnt;
740740
int reccnt;
741-
unsigned char *sha1;
741+
struct object_id *oid;
742742
int found_it;
743743

744-
unsigned char osha1[20];
745-
unsigned char nsha1[20];
744+
struct object_id ooid;
745+
struct object_id noid;
746746
int tz;
747747
timestamp_t date;
748748
char **msg;
@@ -774,25 +774,25 @@ static int read_ref_at_ent(struct object_id *ooid, struct object_id *noid,
774774
* we have not yet updated cb->[n|o]sha1 so they still
775775
* hold the values for the previous record.
776776
*/
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))
780780
warning("Log for ref %s has gap after %s.",
781781
cb->refname, show_date(cb->date, cb->tz, DATE_MODE(RFC2822)));
782782
}
783783
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))
786786
warning("Log for ref %s unexpectedly ended on %s.",
787787
cb->refname, show_date(cb->date, cb->tz,
788788
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);
791791
cb->found_it = 1;
792792
return 1;
793793
}
794-
hashcpy(cb->osha1, ooid->hash);
795-
hashcpy(cb->nsha1, noid->hash);
794+
oidcpy(&cb->ooid, ooid);
795+
oidcpy(&cb->noid, noid);
796796
if (cb->cnt > 0)
797797
cb->cnt--;
798798
return 0;
@@ -812,15 +812,15 @@ static int read_ref_at_ent_oldest(struct object_id *ooid, struct object_id *noid
812812
*cb->cutoff_tz = tz;
813813
if (cb->cutoff_cnt)
814814
*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);
818818
/* We just want the first entry */
819819
return 1;
820820
}
821821

822822
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,
824824
timestamp_t *cutoff_time, int *cutoff_tz, int *cutoff_cnt)
825825
{
826826
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
833833
cb.cutoff_time = cutoff_time;
834834
cb.cutoff_tz = cutoff_tz;
835835
cb.cutoff_cnt = cutoff_cnt;
836-
cb.sha1 = sha1;
836+
cb.oid = oid;
837837

838838
for_each_reflog_ent_reverse(refname, read_ref_at_ent, &cb);
839839

refs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ int safe_create_reflog(const char *refname, int force_create, struct strbuf *err
363363
/** Reads log for the value of ref during at_time. **/
364364
int read_ref_at(const char *refname, unsigned int flags,
365365
timestamp_t at_time, int cnt,
366-
unsigned char *sha1, char **msg,
366+
struct object_id *oid, char **msg,
367367
timestamp_t *cutoff_time, int *cutoff_tz, int *cutoff_cnt);
368368

369369
/** Check if a particular reflog exists */

sha1_name.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
697697
return -1;
698698
}
699699
}
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,
701701
&co_time, &co_tz, &co_cnt)) {
702702
if (!len) {
703703
if (starts_with(real_ref, "refs/heads/")) {

0 commit comments

Comments
 (0)