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