Skip to content

Commit

Permalink
reachable: reuse revision.c "add all reflogs" code
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Oct 16, 2014
1 parent 5f78a43 commit 718ccc9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 25 deletions.
24 changes: 1 addition & 23 deletions reachable.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,6 @@ static void update_progress(struct connectivity_progress *cp)
display_progress(cp->progress, cp->count);
}

static int add_one_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
const char *email, unsigned long timestamp, int tz,
const char *message, void *cb_data)
{
struct object *object;
struct rev_info *revs = (struct rev_info *)cb_data;

object = parse_object(osha1);
if (object)
add_pending_object(revs, object, "");
object = parse_object(nsha1);
if (object)
add_pending_object(revs, object, "");
return 0;
}

static int add_one_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
{
struct object *object = parse_object_or_die(sha1, path);
Expand All @@ -48,12 +32,6 @@ static int add_one_ref(const char *path, const unsigned char *sha1, int flag, vo
return 0;
}

static int add_one_reflog(const char *path, const unsigned char *sha1, int flag, void *cb_data)
{
for_each_reflog_ent(path, add_one_reflog_ent, cb_data);
return 0;
}

static void add_one_tree(const unsigned char *sha1, struct rev_info *revs)
{
struct tree *tree = lookup_tree(sha1);
Expand Down Expand Up @@ -138,7 +116,7 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog,

/* Add all reflog info */
if (mark_reflog)
for_each_reflog(add_one_reflog, revs);
add_reflogs_to_pending(revs, 0);

cp.progress = progress;
cp.count = 0;
Expand Down
4 changes: 2 additions & 2 deletions revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ static int handle_one_reflog(const char *path, const unsigned char *sha1, int fl
return 0;
}

static void handle_reflog(struct rev_info *revs, unsigned flags)
void add_reflogs_to_pending(struct rev_info *revs, unsigned flags)
{
struct all_refs_cb cb;
cb.all_revs = revs;
Expand Down Expand Up @@ -2061,7 +2061,7 @@ static int handle_revision_pseudo_opt(const char *submodule,
for_each_glob_ref_in(handle_one_ref, arg + 10, "refs/remotes/", &cb);
clear_ref_exclusion(&revs->ref_excludes);
} else if (!strcmp(arg, "--reflog")) {
handle_reflog(revs, *flags);
add_reflogs_to_pending(revs, *flags);
} else if (!strcmp(arg, "--not")) {
*flags ^= UNINTERESTING | BOTTOM;
} else if (!strcmp(arg, "--no-walk")) {
Expand Down
1 change: 1 addition & 0 deletions revision.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ extern void add_pending_sha1(struct rev_info *revs,
unsigned int flags);

extern void add_head_to_pending(struct rev_info *);
extern void add_reflogs_to_pending(struct rev_info *, unsigned int flags);

enum commit_action {
commit_ignore,
Expand Down

0 comments on commit 718ccc9

Please sign in to comment.