revision.c: make save_parents() and free_saved_parents() static
No external callers exist. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
2b102efc8c
commit
0131c49096
106
revision.c
106
revision.c
@ -2968,6 +2968,61 @@ enum commit_action get_commit_action(struct rev_info *revs, struct commit *commi
|
|||||||
return commit_show;
|
return commit_show;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define_commit_slab(saved_parents, struct commit_list *);
|
||||||
|
|
||||||
|
#define EMPTY_PARENT_LIST ((struct commit_list *)-1)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* You may only call save_parents() once per commit (this is checked
|
||||||
|
* for non-root commits).
|
||||||
|
*/
|
||||||
|
static void save_parents(struct rev_info *revs, struct commit *commit)
|
||||||
|
{
|
||||||
|
struct commit_list **pp;
|
||||||
|
|
||||||
|
if (!revs->saved_parents_slab) {
|
||||||
|
revs->saved_parents_slab = xmalloc(sizeof(struct saved_parents));
|
||||||
|
init_saved_parents(revs->saved_parents_slab);
|
||||||
|
}
|
||||||
|
|
||||||
|
pp = saved_parents_at(revs->saved_parents_slab, commit);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When walking with reflogs, we may visit the same commit
|
||||||
|
* several times: once for each appearance in the reflog.
|
||||||
|
*
|
||||||
|
* In this case, save_parents() will be called multiple times.
|
||||||
|
* We want to keep only the first set of parents. We need to
|
||||||
|
* store a sentinel value for an empty (i.e., NULL) parent
|
||||||
|
* list to distinguish it from a not-yet-saved list, however.
|
||||||
|
*/
|
||||||
|
if (*pp)
|
||||||
|
return;
|
||||||
|
if (commit->parents)
|
||||||
|
*pp = copy_commit_list(commit->parents);
|
||||||
|
else
|
||||||
|
*pp = EMPTY_PARENT_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void free_saved_parents(struct rev_info *revs)
|
||||||
|
{
|
||||||
|
if (revs->saved_parents_slab)
|
||||||
|
clear_saved_parents(revs->saved_parents_slab);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit *commit)
|
||||||
|
{
|
||||||
|
struct commit_list *parents;
|
||||||
|
|
||||||
|
if (!revs->saved_parents_slab)
|
||||||
|
return commit->parents;
|
||||||
|
|
||||||
|
parents = *saved_parents_at(revs->saved_parents_slab, commit);
|
||||||
|
if (parents == EMPTY_PARENT_LIST)
|
||||||
|
return NULL;
|
||||||
|
return parents;
|
||||||
|
}
|
||||||
|
|
||||||
enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
|
enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
|
||||||
{
|
{
|
||||||
enum commit_action action = get_commit_action(revs, commit);
|
enum commit_action action = get_commit_action(revs, commit);
|
||||||
@ -3267,54 +3322,3 @@ void put_revision_mark(const struct rev_info *revs, const struct commit *commit)
|
|||||||
fputs(mark, stdout);
|
fputs(mark, stdout);
|
||||||
putchar(' ');
|
putchar(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
define_commit_slab(saved_parents, struct commit_list *);
|
|
||||||
|
|
||||||
#define EMPTY_PARENT_LIST ((struct commit_list *)-1)
|
|
||||||
|
|
||||||
void save_parents(struct rev_info *revs, struct commit *commit)
|
|
||||||
{
|
|
||||||
struct commit_list **pp;
|
|
||||||
|
|
||||||
if (!revs->saved_parents_slab) {
|
|
||||||
revs->saved_parents_slab = xmalloc(sizeof(struct saved_parents));
|
|
||||||
init_saved_parents(revs->saved_parents_slab);
|
|
||||||
}
|
|
||||||
|
|
||||||
pp = saved_parents_at(revs->saved_parents_slab, commit);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* When walking with reflogs, we may visit the same commit
|
|
||||||
* several times: once for each appearance in the reflog.
|
|
||||||
*
|
|
||||||
* In this case, save_parents() will be called multiple times.
|
|
||||||
* We want to keep only the first set of parents. We need to
|
|
||||||
* store a sentinel value for an empty (i.e., NULL) parent
|
|
||||||
* list to distinguish it from a not-yet-saved list, however.
|
|
||||||
*/
|
|
||||||
if (*pp)
|
|
||||||
return;
|
|
||||||
if (commit->parents)
|
|
||||||
*pp = copy_commit_list(commit->parents);
|
|
||||||
else
|
|
||||||
*pp = EMPTY_PARENT_LIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit *commit)
|
|
||||||
{
|
|
||||||
struct commit_list *parents;
|
|
||||||
|
|
||||||
if (!revs->saved_parents_slab)
|
|
||||||
return commit->parents;
|
|
||||||
|
|
||||||
parents = *saved_parents_at(revs->saved_parents_slab, commit);
|
|
||||||
if (parents == EMPTY_PARENT_LIST)
|
|
||||||
return NULL;
|
|
||||||
return parents;
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_saved_parents(struct rev_info *revs)
|
|
||||||
{
|
|
||||||
if (revs->saved_parents_slab)
|
|
||||||
clear_saved_parents(revs->saved_parents_slab);
|
|
||||||
}
|
|
||||||
|
12
revision.h
12
revision.h
@ -298,18 +298,14 @@ extern int rewrite_parents(struct rev_info *revs, struct commit *commit,
|
|||||||
rewrite_parent_fn_t rewrite_parent);
|
rewrite_parent_fn_t rewrite_parent);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Save a copy of the parent list, and return the saved copy. This is
|
* The log machinery saves the original parent list so that
|
||||||
* used by the log machinery to retrieve the original parents when
|
* get_saved_parents() can later tell what the real parents of the
|
||||||
* commit->parents has been modified by history simpification.
|
* commits are, when commit->parents has been modified by history
|
||||||
*
|
* simpification.
|
||||||
* You may only call save_parents() once per commit (this is checked
|
|
||||||
* for non-root commits).
|
|
||||||
*
|
*
|
||||||
* get_saved_parents() will transparently return commit->parents if
|
* get_saved_parents() will transparently return commit->parents if
|
||||||
* history simplification is off.
|
* history simplification is off.
|
||||||
*/
|
*/
|
||||||
extern void save_parents(struct rev_info *revs, struct commit *commit);
|
|
||||||
extern struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit *commit);
|
extern struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit *commit);
|
||||||
extern void free_saved_parents(struct rev_info *revs);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user