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 <mhagger@alum.mit.edu> Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Dec 12, 2014 at 09:56 UTC 82a645a73f07b19c0d70861929ebd6178e80e3e9
1 file changed +10 -10
builtin/reflog.c
+10 -10
@@ -36,7 +36,6 @@ struct cmd_reflog_expire_cb {
36 };
37
38 struct expire_reflog_policy_cb {
39 - FILE *newlog;
39 enum {
40 UE_NORMAL,
41 UE_ALWAYS,
@@ -45,7 +44,6 @@ struct expire_reflog_policy_cb {
44 struct commit_list *mark_list;
45 unsigned long mark_limit;
46 struct cmd_reflog_expire_cb *cmd;
48 - unsigned char last_kept_sha1[20];
47 struct commit *tip_commit;
48 struct commit_list *tips;
49 };
@@ -53,6 +51,8 @@ struct expire_reflog_policy_cb {
51 struct expire_reflog_cb {
52 unsigned int flags;
53 void *policy_cb;
54 + FILE *newlog;
55 + unsigned char last_kept_sha1[20];
56 };
57
58 struct collected_reflog {
@@ -338,23 +338,23 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
338 struct expire_reflog_policy_cb *policy_cb = cb->policy_cb;
339
340 if (cb->flags & EXPIRE_REFLOGS_REWRITE)
341 - osha1 = policy_cb->last_kept_sha1;
341 + osha1 = cb->last_kept_sha1;
342
343 if (should_expire_reflog_ent(osha1, nsha1, email, timestamp, tz,
344 message, policy_cb)) {
345 - if (!policy_cb->newlog)
345 + if (!cb->newlog)
346 printf("would prune %s", message);
347 else if (cb->flags & EXPIRE_REFLOGS_VERBOSE)
348 printf("prune %s", message);
349 } else {
350 - if (policy_cb->newlog) {
350 + if (cb->newlog) {
351 char sign = (tz < 0) ? '-' : '+';
352 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",
354 sha1_to_hex(osha1), sha1_to_hex(nsha1),
355 email, timestamp, sign, zone,
356 message);
357 - hashcpy(policy_cb->last_kept_sha1, nsha1);
357 + hashcpy(cb->last_kept_sha1, nsha1);
358 }
359 if (cb->flags & EXPIRE_REFLOGS_VERBOSE)
360 printf("keep %s", message);
@@ -468,8 +468,8 @@ static int expire_reflog(const char *refname, const unsigned char *sha1,
468 strbuf_release(&err);
469 goto failure;
470 }
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) {
473 error("cannot fdopen %s (%s)",
474 reflog_lock.filename.buf, strerror(errno));
475 goto failure;
@@ -488,7 +488,7 @@ static int expire_reflog(const char *refname, const unsigned char *sha1,
488 strerror(errno));
489 } else if ((flags & EXPIRE_REFLOGS_UPDATE_REF) &&
490 (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 ||
492 write_str_in_full(lock->lock_fd, "\n") != 1 ||
493 close_ref(lock) < 0)) {
494 status |= error("couldn't write %s",