Export rewrite_parents() for 'log -L'
The function rewrite_one is used to rewrite a single parent of the current commit, and is used by rewrite_parents to rewrite all the parents. Decouple the dependence between them by making rewrite_one a callback function that is passed to rewrite_parents. Then export rewrite_parents for reuse by the line history browser. We will use this function in line-log.c. Signed-off-by: Bo Yang <struggleyb.nku@gmail.com> Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Bo Yang committed
Mar 28, 2013 at 17:47 UTC
c7edcae06ed90ec0567179a78d7d1170e610c042
2 files changed
+14
-9
revision.c
+4
-9
@@ -2173,12 +2173,6 @@ int prepare_revision_walk(struct rev_info *revs)
2173
return 0;
2174
}
2175
2176
-enum rewrite_result {
2177
- rewrite_one_ok,
2178
- rewrite_one_noparents,
2179
- rewrite_one_error
2180
-};
2181
-
2176
static enum rewrite_result rewrite_one(struct rev_info *revs, struct commit **pp)
2177
{
2178
struct commit_list *cache = NULL;
@@ -2200,12 +2194,13 @@ static enum rewrite_result rewrite_one(struct rev_info *revs, struct commit **pp
2194
}
2195
}
2196
2203
-static int rewrite_parents(struct rev_info *revs, struct commit *commit)
2197
+int rewrite_parents(struct rev_info *revs, struct commit *commit,
2198
+ rewrite_parent_fn_t rewrite_parent)
2199
{
2200
struct commit_list **pp = &commit->parents;
2201
while (*pp) {
2202
struct commit_list *parent = *pp;
2208
- switch (rewrite_one(revs, &parent->item)) {
2203
+ switch (rewrite_parent(revs, &parent->item)) {
2204
case rewrite_one_ok:
2205
break;
2206
case rewrite_one_noparents:
@@ -2371,7 +2366,7 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
2366
if (action == commit_show &&
2367
!revs->show_all &&
2368
revs->prune && revs->dense && want_ancestry(revs)) {
2374
- if (rewrite_parents(revs, commit) < 0)
2369
+ if (rewrite_parents(revs, commit, rewrite_one) < 0)
2370
return commit_error;
2371
}
2372
return action;
revision.h
+10
@@ -241,4 +241,14 @@ enum commit_action {
241
extern enum commit_action get_commit_action(struct rev_info *revs, struct commit *commit);
242
extern enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit);
243
244
+enum rewrite_result {
245
+ rewrite_one_ok,
246
+ rewrite_one_noparents,
247
+ rewrite_one_error
248
+};
249
+
250
+typedef enum rewrite_result (*rewrite_parent_fn_t)(struct rev_info *revs, struct commit **pp);
251
+
252
+extern int rewrite_parents(struct rev_info *revs, struct commit *commit,
253
+ rewrite_parent_fn_t rewrite_parent);
254
#endif