@matheusbsbs / matheus-bagliano / commits / ca4f293fb4
Fork 0

builtin-prune: separate ref walking from reflog walking.

This is necessary for the next step, because the reason I am making the connectivity walker into a library is because I want to use it for cleaning up stale reflog entries. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Jan 6, 2007 at 02:16 UTC ca4f293fb492efdd2b984b992796b075c30e230d
1 file changed +9 -2
builtin-prune.c
+9 -2
@@ -203,8 +203,12 @@ static int add_one_ref(const char *path, const unsigned char *sha1, int flag, vo
203 die("bad object ref: %s:%s", path, sha1_to_hex(sha1));
204 add_pending_object(revs, object, "");
205
206 - for_each_reflog_ent(path, add_one_reflog_ent, cb_data);
206 + return 0;
207 +}
208
209 +static int add_one_reflog(const char *path, const unsigned char *sha1, int flag, void *cb_data)
210 +{
211 + for_each_reflog_ent(path, add_one_reflog_ent, cb_data);
212 return 0;
213 }
214
@@ -267,12 +271,15 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
271 revs.blob_objects = 1;
272 revs.tree_objects = 1;
273
270 - /* Add all external refs, along with its reflog info */
274 + /* Add all external refs */
275 for_each_ref(add_one_ref, &revs);
276
277 /* Add all refs from the index file */
278 add_cache_refs(&revs);
279
280 + /* Add all reflog info from refs */
281 + for_each_ref(add_one_reflog, &revs);
282 +
283 /*
284 * Set up the revision walk - this will move all commits
285 * from the pending list to the commit walking list.