@matheusbsbs / matheus-bagliano / commits / 9bbaa6cc68
Fork 0

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>

Junio C Hamano committed Jan 11, 2007 at 19:56 UTC 9bbaa6cc6848b68b8bef681c2a22b57bbec3e914
1 file changed +12 -6
builtin-reflog.c
+12 -6
@@ -173,7 +173,6 @@ static int keep_entry(struct commit **it, unsigned char *sha1)
173 {
174 struct commit *commit;
175
176 - *it = NULL;
176 if (is_null_sha1(sha1))
177 return 1;
178 commit = lookup_commit_reference_gently(sha1, 1);
@@ -204,15 +203,22 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
203 if (timestamp < cb->cmd->expire_total)
204 goto prune;
205
206 + old = new = NULL;
207 if (cb->cmd->stalefix &&
208 (!keep_entry(&old, osha1) || !keep_entry(&new, nsha1)))
209 goto prune;
210
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 + }
222
223 if (cb->newlog) {
224 char sign = (tz < 0) ? '-' : '+';