Skip to content

Commit c7edcae

Browse files
byanggitster
authored andcommitted
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 <[email protected]> Signed-off-by: Thomas Rast <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 25ed341 commit c7edcae

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

revision.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,12 +2173,6 @@ int prepare_revision_walk(struct rev_info *revs)
21732173
return 0;
21742174
}
21752175

2176-
enum rewrite_result {
2177-
rewrite_one_ok,
2178-
rewrite_one_noparents,
2179-
rewrite_one_error
2180-
};
2181-
21822176
static enum rewrite_result rewrite_one(struct rev_info *revs, struct commit **pp)
21832177
{
21842178
struct commit_list *cache = NULL;
@@ -2200,12 +2194,13 @@ static enum rewrite_result rewrite_one(struct rev_info *revs, struct commit **pp
22002194
}
22012195
}
22022196

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)
22042199
{
22052200
struct commit_list **pp = &commit->parents;
22062201
while (*pp) {
22072202
struct commit_list *parent = *pp;
2208-
switch (rewrite_one(revs, &parent->item)) {
2203+
switch (rewrite_parent(revs, &parent->item)) {
22092204
case rewrite_one_ok:
22102205
break;
22112206
case rewrite_one_noparents:
@@ -2371,7 +2366,7 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
23712366
if (action == commit_show &&
23722367
!revs->show_all &&
23732368
revs->prune && revs->dense && want_ancestry(revs)) {
2374-
if (rewrite_parents(revs, commit) < 0)
2369+
if (rewrite_parents(revs, commit, rewrite_one) < 0)
23752370
return commit_error;
23762371
}
23772372
return action;

revision.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,14 @@ enum commit_action {
241241
extern enum commit_action get_commit_action(struct rev_info *revs, struct commit *commit);
242242
extern enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit);
243243

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);
244254
#endif

0 commit comments

Comments
 (0)