@@ -2968,6 +2968,61 @@ enum commit_action get_commit_action(struct rev_info *revs, struct commit *commi
2968
2968
return commit_show ;
2969
2969
}
2970
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
+
2971
3026
enum commit_action simplify_commit (struct rev_info * revs , struct commit * commit )
2972
3027
{
2973
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)
3267
3322
fputs (mark , stdout );
3268
3323
putchar (' ' );
3269
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
- }
0 commit comments