revision.c: make save_parents() and free_saved_parents() static

No external callers exist. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jan 14, 2015 at 14:49 UTC 0131c4909674b35f870916f875e6404e3ba58bc9
2 files changed +59 -59
revision.c
+55 -51
@@ -2968,6 +2968,61 @@ enum commit_action get_commit_action(struct rev_info *revs, struct commit *commi
2968 return commit_show;
2969 }
2970
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 +
3026 enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
3027 {
3028 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)
3322 fputs(mark, stdout);
3323 putchar(' ');
3324 }
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
+4 -8
@@ -298,18 +298,14 @@ extern int rewrite_parents(struct rev_info *revs, struct commit *commit,
298 rewrite_parent_fn_t rewrite_parent);
299
300 /*
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.
305 *
306 * get_saved_parents() will transparently return commit->parents if
307 * history simplification is off.
308 */
311 -extern void save_parents(struct rev_info *revs, struct commit *commit);
309 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);
310
311 #endif