Skip to content

Commit 9bbaa6c

Browse files
author
Junio C Hamano
committed
reflog-expire: brown paper bag fix.
When --stale-fix is not passed, the code did not initialize the two commit objects properly. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent ba70de0 commit 9bbaa6c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

builtin-reflog.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ static int keep_entry(struct commit **it, unsigned char *sha1)
173173
{
174174
struct commit *commit;
175175

176-
*it = NULL;
177176
if (is_null_sha1(sha1))
178177
return 1;
179178
commit = lookup_commit_reference_gently(sha1, 1);
@@ -204,15 +203,22 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
204203
if (timestamp < cb->cmd->expire_total)
205204
goto prune;
206205

206+
old = new = NULL;
207207
if (cb->cmd->stalefix &&
208208
(!keep_entry(&old, osha1) || !keep_entry(&new, nsha1)))
209209
goto prune;
210210

211-
if ((timestamp < cb->cmd->expire_unreachable) &&
212-
(!cb->ref_commit ||
213-
(old && !in_merge_bases(old, cb->ref_commit)) ||
214-
(new && !in_merge_bases(new, cb->ref_commit))))
215-
goto prune;
211+
if (timestamp < cb->cmd->expire_unreachable) {
212+
if (!cb->ref_commit)
213+
goto prune;
214+
if (!old && !is_null_sha1(osha1))
215+
old = lookup_commit_reference_gently(osha1, 1);
216+
if (!new && !is_null_sha1(nsha1))
217+
new = lookup_commit_reference_gently(nsha1, 1);
218+
if ((old && !in_merge_bases(old, cb->ref_commit)) ||
219+
(new && !in_merge_bases(new, cb->ref_commit)))
220+
goto prune;
221+
}
216222

217223
if (cb->newlog) {
218224
char sign = (tz < 0) ? '-' : '+';

0 commit comments

Comments
 (0)