Skip to content

Commit 82a645a

Browse files
mhaggergitster
authored andcommitted
Move newlog and last_kept_sha1 to "struct expire_reflog_cb"
These members are not needed by the policy functions. Signed-off-by: Michael Haggerty <[email protected]> Reviewed-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 553daf1 commit 82a645a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

builtin/reflog.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ struct cmd_reflog_expire_cb {
3636
};
3737

3838
struct expire_reflog_policy_cb {
39-
FILE *newlog;
4039
enum {
4140
UE_NORMAL,
4241
UE_ALWAYS,
@@ -45,14 +44,15 @@ struct expire_reflog_policy_cb {
4544
struct commit_list *mark_list;
4645
unsigned long mark_limit;
4746
struct cmd_reflog_expire_cb *cmd;
48-
unsigned char last_kept_sha1[20];
4947
struct commit *tip_commit;
5048
struct commit_list *tips;
5149
};
5250

5351
struct expire_reflog_cb {
5452
unsigned int flags;
5553
void *policy_cb;
54+
FILE *newlog;
55+
unsigned char last_kept_sha1[20];
5656
};
5757

5858
struct collected_reflog {
@@ -338,23 +338,23 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
338338
struct expire_reflog_policy_cb *policy_cb = cb->policy_cb;
339339

340340
if (cb->flags & EXPIRE_REFLOGS_REWRITE)
341-
osha1 = policy_cb->last_kept_sha1;
341+
osha1 = cb->last_kept_sha1;
342342

343343
if (should_expire_reflog_ent(osha1, nsha1, email, timestamp, tz,
344344
message, policy_cb)) {
345-
if (!policy_cb->newlog)
345+
if (!cb->newlog)
346346
printf("would prune %s", message);
347347
else if (cb->flags & EXPIRE_REFLOGS_VERBOSE)
348348
printf("prune %s", message);
349349
} else {
350-
if (policy_cb->newlog) {
350+
if (cb->newlog) {
351351
char sign = (tz < 0) ? '-' : '+';
352352
int zone = (tz < 0) ? (-tz) : tz;
353-
fprintf(policy_cb->newlog, "%s %s %s %lu %c%04d\t%s",
353+
fprintf(cb->newlog, "%s %s %s %lu %c%04d\t%s",
354354
sha1_to_hex(osha1), sha1_to_hex(nsha1),
355355
email, timestamp, sign, zone,
356356
message);
357-
hashcpy(policy_cb->last_kept_sha1, nsha1);
357+
hashcpy(cb->last_kept_sha1, nsha1);
358358
}
359359
if (cb->flags & EXPIRE_REFLOGS_VERBOSE)
360360
printf("keep %s", message);
@@ -468,8 +468,8 @@ static int expire_reflog(const char *refname, const unsigned char *sha1,
468468
strbuf_release(&err);
469469
goto failure;
470470
}
471-
policy_cb.newlog = fdopen_lock_file(&reflog_lock, "w");
472-
if (!policy_cb.newlog) {
471+
cb.newlog = fdopen_lock_file(&reflog_lock, "w");
472+
if (!cb.newlog) {
473473
error("cannot fdopen %s (%s)",
474474
reflog_lock.filename.buf, strerror(errno));
475475
goto failure;
@@ -488,7 +488,7 @@ static int expire_reflog(const char *refname, const unsigned char *sha1,
488488
strerror(errno));
489489
} else if ((flags & EXPIRE_REFLOGS_UPDATE_REF) &&
490490
(write_in_full(lock->lock_fd,
491-
sha1_to_hex(policy_cb.last_kept_sha1), 40) != 40 ||
491+
sha1_to_hex(cb.last_kept_sha1), 40) != 40 ||
492492
write_str_in_full(lock->lock_fd, "\n") != 1 ||
493493
close_ref(lock) < 0)) {
494494
status |= error("couldn't write %s",

0 commit comments

Comments
 (0)