Skip to content

Commit 718ccc9

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5f78a43 commit 718ccc9

File tree

3 files changed

+4
-25
lines changed

3 files changed

+4
-25
lines changed

reachable.c

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,6 @@ static void update_progress(struct connectivity_progress *cp)
2222
display_progress(cp->progress, cp->count);
2323
}
2424

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-
4125
static int add_one_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
4226
{
4327
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
4832
return 0;
4933
}
5034

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-
5735
static void add_one_tree(const unsigned char *sha1, struct rev_info *revs)
5836
{
5937
struct tree *tree = lookup_tree(sha1);
@@ -138,7 +116,7 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog,
138116

139117
/* Add all reflog info */
140118
if (mark_reflog)
141-
for_each_reflog(add_one_reflog, revs);
119+
add_reflogs_to_pending(revs, 0);
142120

143121
cp.progress = progress;
144122
cp.count = 0;

revision.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ static int handle_one_reflog(const char *path, const unsigned char *sha1, int fl
12751275
return 0;
12761276
}
12771277

1278-
static void handle_reflog(struct rev_info *revs, unsigned flags)
1278+
void add_reflogs_to_pending(struct rev_info *revs, unsigned flags)
12791279
{
12801280
struct all_refs_cb cb;
12811281
cb.all_revs = revs;
@@ -2061,7 +2061,7 @@ static int handle_revision_pseudo_opt(const char *submodule,
20612061
for_each_glob_ref_in(handle_one_ref, arg + 10, "refs/remotes/", &cb);
20622062
clear_ref_exclusion(&revs->ref_excludes);
20632063
} else if (!strcmp(arg, "--reflog")) {
2064-
handle_reflog(revs, *flags);
2064+
add_reflogs_to_pending(revs, *flags);
20652065
} else if (!strcmp(arg, "--not")) {
20662066
*flags ^= UNINTERESTING | BOTTOM;
20672067
} else if (!strcmp(arg, "--no-walk")) {

revision.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ extern void add_pending_sha1(struct rev_info *revs,
276276
unsigned int flags);
277277

278278
extern void add_head_to_pending(struct rev_info *);
279+
extern void add_reflogs_to_pending(struct rev_info *, unsigned int flags);
279280

280281
enum commit_action {
281282
commit_ignore,

0 commit comments

Comments
 (0)