Skip to content

Commit 0131c49

Browse files
committed
revision.c: make save_parents() and free_saved_parents() static
No external callers exist. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2b102ef commit 0131c49

File tree

2 files changed

+59
-59
lines changed

2 files changed

+59
-59
lines changed

revision.c

Lines changed: 55 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2968,6 +2968,61 @@ enum commit_action get_commit_action(struct rev_info *revs, struct commit *commi
29682968
return commit_show;
29692969
}
29702970

2971+
define_commit_slab(saved_parents, struct commit_list *);
2972+
2973+
#define EMPTY_PARENT_LIST ((struct commit_list *)-1)
2974+
2975+
/*
2976+
* You may only call save_parents() once per commit (this is checked
2977+
* for non-root commits).
2978+
*/
2979+
static void save_parents(struct rev_info *revs, struct commit *commit)
2980+
{
2981+
struct commit_list **pp;
2982+
2983+
if (!revs->saved_parents_slab) {
2984+
revs->saved_parents_slab = xmalloc(sizeof(struct saved_parents));
2985+
init_saved_parents(revs->saved_parents_slab);
2986+
}
2987+
2988+
pp = saved_parents_at(revs->saved_parents_slab, commit);
2989+
2990+
/*
2991+
* When walking with reflogs, we may visit the same commit
2992+
* several times: once for each appearance in the reflog.
2993+
*
2994+
* In this case, save_parents() will be called multiple times.
2995+
* We want to keep only the first set of parents. We need to
2996+
* store a sentinel value for an empty (i.e., NULL) parent
2997+
* list to distinguish it from a not-yet-saved list, however.
2998+
*/
2999+
if (*pp)
3000+
return;
3001+
if (commit->parents)
3002+
*pp = copy_commit_list(commit->parents);
3003+
else
3004+
*pp = EMPTY_PARENT_LIST;
3005+
}
3006+
3007+
static void free_saved_parents(struct rev_info *revs)
3008+
{
3009+
if (revs->saved_parents_slab)
3010+
clear_saved_parents(revs->saved_parents_slab);
3011+
}
3012+
3013+
struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit *commit)
3014+
{
3015+
struct commit_list *parents;
3016+
3017+
if (!revs->saved_parents_slab)
3018+
return commit->parents;
3019+
3020+
parents = *saved_parents_at(revs->saved_parents_slab, commit);
3021+
if (parents == EMPTY_PARENT_LIST)
3022+
return NULL;
3023+
return parents;
3024+
}
3025+
29713026
enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
29723027
{
29733028
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)
32673322
fputs(mark, stdout);
32683323
putchar(' ');
32693324
}
3270-
3271-
define_commit_slab(saved_parents, struct commit_list *);
3272-
3273-
#define EMPTY_PARENT_LIST ((struct commit_list *)-1)
3274-
3275-
void save_parents(struct rev_info *revs, struct commit *commit)
3276-
{
3277-
struct commit_list **pp;
3278-
3279-
if (!revs->saved_parents_slab) {
3280-
revs->saved_parents_slab = xmalloc(sizeof(struct saved_parents));
3281-
init_saved_parents(revs->saved_parents_slab);
3282-
}
3283-
3284-
pp = saved_parents_at(revs->saved_parents_slab, commit);
3285-
3286-
/*
3287-
* When walking with reflogs, we may visit the same commit
3288-
* several times: once for each appearance in the reflog.
3289-
*
3290-
* In this case, save_parents() will be called multiple times.
3291-
* We want to keep only the first set of parents. We need to
3292-
* store a sentinel value for an empty (i.e., NULL) parent
3293-
* list to distinguish it from a not-yet-saved list, however.
3294-
*/
3295-
if (*pp)
3296-
return;
3297-
if (commit->parents)
3298-
*pp = copy_commit_list(commit->parents);
3299-
else
3300-
*pp = EMPTY_PARENT_LIST;
3301-
}
3302-
3303-
struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit *commit)
3304-
{
3305-
struct commit_list *parents;
3306-
3307-
if (!revs->saved_parents_slab)
3308-
return commit->parents;
3309-
3310-
parents = *saved_parents_at(revs->saved_parents_slab, commit);
3311-
if (parents == EMPTY_PARENT_LIST)
3312-
return NULL;
3313-
return parents;
3314-
}
3315-
3316-
void free_saved_parents(struct rev_info *revs)
3317-
{
3318-
if (revs->saved_parents_slab)
3319-
clear_saved_parents(revs->saved_parents_slab);
3320-
}

revision.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,18 +298,14 @@ extern int rewrite_parents(struct rev_info *revs, struct commit *commit,
298298
rewrite_parent_fn_t rewrite_parent);
299299

300300
/*
301-
* Save a copy of the parent list, and return the saved copy. This is
302-
* used by the log machinery to retrieve the original parents when
303-
* commit->parents has been modified by history simpification.
304-
*
305-
* You may only call save_parents() once per commit (this is checked
306-
* for non-root commits).
301+
* The log machinery saves the original parent list so that
302+
* get_saved_parents() can later tell what the real parents of the
303+
* commits are, when commit->parents has been modified by history
304+
* simpification.
307305
*
308306
* get_saved_parents() will transparently return commit->parents if
309307
* history simplification is off.
310308
*/
311-
extern void save_parents(struct rev_info *revs, struct commit *commit);
312309
extern struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit *commit);
313-
extern void free_saved_parents(struct rev_info *revs);
314310

315311
#endif

0 commit comments

Comments
 (0)