reachable: reuse revision.c "add all reflogs" code

We want to add all reflog entries as tips for finding reachable objects. The revision machinery can already do this (to support "rev-list --reflog"); we can reuse that code. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Oct 15, 2014 at 18:38 UTC 718ccc9731c4e98b123436c22c1cccf2beed5e29
3 files changed +4 -25
reachable.c
+1 -23
@@ -22,22 +22,6 @@ static void update_progress(struct connectivity_progress *cp)
22 display_progress(cp->progress, cp->count);
23 }
24
25 -static int add_one_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
26 - const char *email, unsigned long timestamp, int tz,
27 - const char *message, void *cb_data)
28 -{
29 - struct object *object;
30 - struct rev_info *revs = (struct rev_info *)cb_data;
31 -
32 - object = parse_object(osha1);
33 - if (object)
34 - add_pending_object(revs, object, "");
35 - object = parse_object(nsha1);
36 - if (object)
37 - add_pending_object(revs, object, "");
38 - return 0;
39 -}
40 -
25 static int add_one_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
26 {
27 struct object *object = parse_object_or_die(sha1, path);
@@ -48,12 +32,6 @@ static int add_one_ref(const char *path, const unsigned char *sha1, int flag, vo
32 return 0;
33 }
34
51 -static int add_one_reflog(const char *path, const unsigned char *sha1, int flag, void *cb_data)
52 -{
53 - for_each_reflog_ent(path, add_one_reflog_ent, cb_data);
54 - return 0;
55 -}
56 -
35 static void add_one_tree(const unsigned char *sha1, struct rev_info *revs)
36 {
37 struct tree *tree = lookup_tree(sha1);
@@ -138,7 +116,7 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog,
116
117 /* Add all reflog info */
118 if (mark_reflog)
141 - for_each_reflog(add_one_reflog, revs);
119 + add_reflogs_to_pending(revs, 0);
120
121 cp.progress = progress;
122 cp.count = 0;
revision.c
+2 -2
@@ -1275,7 +1275,7 @@ static int handle_one_reflog(const char *path, const unsigned char *sha1, int fl
1275 return 0;
1276 }
1277
1278 -static void handle_reflog(struct rev_info *revs, unsigned flags)
1278 +void add_reflogs_to_pending(struct rev_info *revs, unsigned flags)
1279 {
1280 struct all_refs_cb cb;
1281 cb.all_revs = revs;
@@ -2061,7 +2061,7 @@ static int handle_revision_pseudo_opt(const char *submodule,
2061 for_each_glob_ref_in(handle_one_ref, arg + 10, "refs/remotes/", &cb);
2062 clear_ref_exclusion(&revs->ref_excludes);
2063 } else if (!strcmp(arg, "--reflog")) {
2064 - handle_reflog(revs, *flags);
2064 + add_reflogs_to_pending(revs, *flags);
2065 } else if (!strcmp(arg, "--not")) {
2066 *flags ^= UNINTERESTING | BOTTOM;
2067 } else if (!strcmp(arg, "--no-walk")) {
revision.h
+1
@@ -276,6 +276,7 @@ extern void add_pending_sha1(struct rev_info *revs,
276 unsigned int flags);
277
278 extern void add_head_to_pending(struct rev_info *);
279 +extern void add_reflogs_to_pending(struct rev_info *, unsigned int flags);
280
281 enum commit_action {
282 commit_ignore,