Merge branch 'bc/object-id'
"uchar [40]" to "struct object_id" conversion continues. * bc/object-id: wt-status: convert to struct object_id builtin/merge-base: convert to struct object_id Convert object iteration callbacks to struct object_id sha1_file: introduce an nth_packed_object_oid function refs: simplify parsing of reflog entries refs: convert each_reflog_ent_fn to struct object_id reflog-walk: convert struct reflog_info to struct object_id builtin/replace: convert to struct object_id Convert remaining callers of resolve_refdup to object_id builtin/merge: convert to struct object_id builtin/clone: convert to struct object_id builtin/branch: convert to struct object_id builtin/grep: convert to struct object_id builtin/fmt-merge-message: convert to struct object_id builtin/fast-export: convert to struct object_id builtin/describe: convert to struct object_id builtin/diff-tree: convert to struct object_id builtin/commit: convert to struct object_id hex: introduce parse_oid_hex
This commit is contained in:
@ -3102,16 +3102,17 @@ static int files_delete_reflog(struct ref_store *ref_store,
|
||||
|
||||
static int show_one_reflog_ent(struct strbuf *sb, each_reflog_ent_fn fn, void *cb_data)
|
||||
{
|
||||
unsigned char osha1[20], nsha1[20];
|
||||
struct object_id ooid, noid;
|
||||
char *email_end, *message;
|
||||
unsigned long timestamp;
|
||||
int tz;
|
||||
const char *p = sb->buf;
|
||||
|
||||
/* old SP new SP name <email> SP time TAB msg LF */
|
||||
if (sb->len < 83 || sb->buf[sb->len - 1] != '\n' ||
|
||||
get_sha1_hex(sb->buf, osha1) || sb->buf[40] != ' ' ||
|
||||
get_sha1_hex(sb->buf + 41, nsha1) || sb->buf[81] != ' ' ||
|
||||
!(email_end = strchr(sb->buf + 82, '>')) ||
|
||||
if (!sb->len || sb->buf[sb->len - 1] != '\n' ||
|
||||
parse_oid_hex(p, &ooid, &p) || *p++ != ' ' ||
|
||||
parse_oid_hex(p, &noid, &p) || *p++ != ' ' ||
|
||||
!(email_end = strchr(p, '>')) ||
|
||||
email_end[1] != ' ' ||
|
||||
!(timestamp = strtoul(email_end + 2, &message, 10)) ||
|
||||
!message || message[0] != ' ' ||
|
||||
@ -3125,7 +3126,7 @@ static int show_one_reflog_ent(struct strbuf *sb, each_reflog_ent_fn fn, void *c
|
||||
message += 6;
|
||||
else
|
||||
message += 7;
|
||||
return fn(osha1, nsha1, sb->buf + 82, timestamp, tz, message, cb_data);
|
||||
return fn(&ooid, &noid, p, timestamp, tz, message, cb_data);
|
||||
}
|
||||
|
||||
static char *find_beginning_of_line(char *bob, char *scan)
|
||||
@ -3954,10 +3955,10 @@ struct expire_reflog_cb {
|
||||
reflog_expiry_should_prune_fn *should_prune_fn;
|
||||
void *policy_cb;
|
||||
FILE *newlog;
|
||||
unsigned char last_kept_sha1[20];
|
||||
struct object_id last_kept_oid;
|
||||
};
|
||||
|
||||
static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
|
||||
static int expire_reflog_ent(struct object_id *ooid, struct object_id *noid,
|
||||
const char *email, unsigned long timestamp, int tz,
|
||||
const char *message, void *cb_data)
|
||||
{
|
||||
@ -3965,9 +3966,9 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
|
||||
struct expire_reflog_policy_cb *policy_cb = cb->policy_cb;
|
||||
|
||||
if (cb->flags & EXPIRE_REFLOGS_REWRITE)
|
||||
osha1 = cb->last_kept_sha1;
|
||||
ooid = &cb->last_kept_oid;
|
||||
|
||||
if ((*cb->should_prune_fn)(osha1, nsha1, email, timestamp, tz,
|
||||
if ((*cb->should_prune_fn)(ooid->hash, noid->hash, email, timestamp, tz,
|
||||
message, policy_cb)) {
|
||||
if (!cb->newlog)
|
||||
printf("would prune %s", message);
|
||||
@ -3976,9 +3977,9 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
|
||||
} else {
|
||||
if (cb->newlog) {
|
||||
fprintf(cb->newlog, "%s %s %s %lu %+05d\t%s",
|
||||
sha1_to_hex(osha1), sha1_to_hex(nsha1),
|
||||
oid_to_hex(ooid), oid_to_hex(noid),
|
||||
email, timestamp, tz, message);
|
||||
hashcpy(cb->last_kept_sha1, nsha1);
|
||||
oidcpy(&cb->last_kept_oid, noid);
|
||||
}
|
||||
if (cb->flags & EXPIRE_REFLOGS_VERBOSE)
|
||||
printf("keep %s", message);
|
||||
@ -4065,14 +4066,14 @@ static int files_reflog_expire(struct ref_store *ref_store,
|
||||
*/
|
||||
int update = (flags & EXPIRE_REFLOGS_UPDATE_REF) &&
|
||||
!(type & REF_ISSYMREF) &&
|
||||
!is_null_sha1(cb.last_kept_sha1);
|
||||
!is_null_oid(&cb.last_kept_oid);
|
||||
|
||||
if (close_lock_file(&reflog_lock)) {
|
||||
status |= error("couldn't write %s: %s", log_file,
|
||||
strerror(errno));
|
||||
} else if (update &&
|
||||
(write_in_full(get_lock_file_fd(lock->lk),
|
||||
sha1_to_hex(cb.last_kept_sha1), 40) != 40 ||
|
||||
oid_to_hex(&cb.last_kept_oid), GIT_SHA1_HEXSZ) != GIT_SHA1_HEXSZ ||
|
||||
write_str_in_full(get_lock_file_fd(lock->lk), "\n") != 1 ||
|
||||
close_ref(lock) < 0)) {
|
||||
status |= error("couldn't write %s",
|
||||
|
Reference in New Issue
Block a user