From: Thomas Rast <trast@student.ethz.ch>
To: <git@vger.kernel.org>
Cc: Bo Yang <struggleyb.nku@gmail.com>
Subject: [PATCH v7 4/5] Export rewrite_parents() for 'log -L'
Date: Thu, 7 Jun 2012 12:23:28 +0200 [thread overview]
Message-ID: <de90975ae231f0a982e6ba4cdd576e085bb08029.1339063659.git.trast@student.ethz.ch> (raw)
In-Reply-To: <cover.1339063659.git.trast@student.ethz.ch>
From: Bo Yang <struggleyb.nku@gmail.com>
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.c.
Signed-off-by: Bo Yang <struggleyb.nku@gmail.com>
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
revision.c | 13 ++++---------
revision.h | 10 ++++++++++
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/revision.c b/revision.c
index 935e7a7..183ca58 100644
--- a/revision.c
+++ b/revision.c
@@ -2109,12 +2109,6 @@ int prepare_revision_walk(struct rev_info *revs)
return 0;
}
-enum rewrite_result {
- rewrite_one_ok,
- rewrite_one_noparents,
- rewrite_one_error
-};
-
static enum rewrite_result rewrite_one(struct rev_info *revs, struct commit **pp)
{
struct commit_list *cache = NULL;
@@ -2136,12 +2130,13 @@ static enum rewrite_result rewrite_one(struct rev_info *revs, struct commit **pp
}
}
-static int rewrite_parents(struct rev_info *revs, struct commit *commit)
+int rewrite_parents(struct rev_info *revs, struct commit *commit,
+ rewrite_parent_fn_t rewrite_parent)
{
struct commit_list **pp = &commit->parents;
while (*pp) {
struct commit_list *parent = *pp;
- switch (rewrite_one(revs, &parent->item)) {
+ switch (rewrite_parent(revs, &parent->item)) {
case rewrite_one_ok:
break;
case rewrite_one_noparents:
@@ -2213,7 +2208,7 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
if (action == commit_show &&
!revs->show_all &&
revs->prune && revs->dense && want_ancestry(revs)) {
- if (rewrite_parents(revs, commit) < 0)
+ if (rewrite_parents(revs, commit, rewrite_one) < 0)
return commit_error;
}
return action;
diff --git a/revision.h b/revision.h
index 863f4f6..6d09550 100644
--- a/revision.h
+++ b/revision.h
@@ -231,4 +231,14 @@ enum commit_action {
extern enum commit_action get_commit_action(struct rev_info *revs, struct commit *commit);
extern enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit);
+enum rewrite_result {
+ rewrite_one_ok,
+ rewrite_one_noparents,
+ rewrite_one_error
+};
+
+typedef enum rewrite_result (*rewrite_parent_fn_t)(struct rev_info *revs, struct commit **pp);
+
+extern int rewrite_parents(struct rev_info *revs, struct commit *commit,
+ rewrite_parent_fn_t rewrite_parent);
#endif
--
1.7.11.rc1.243.gbf4713c
next prev parent reply other threads:[~2012-06-07 10:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-07 10:23 [PATCH v7 0/5] git log -L, all new and shiny Thomas Rast
2012-06-07 10:23 ` [PATCH v7 1/5] Refactor parse_loc Thomas Rast
2012-06-07 10:23 ` [PATCH v7 2/5] blame: introduce $ as "end of file" in -L syntax Thomas Rast
2012-06-07 17:23 ` Junio C Hamano
2012-06-07 17:44 ` Thomas Rast
2012-06-07 10:23 ` [PATCH v7 3/5] Export three functions from diff.c Thomas Rast
2012-06-07 17:44 ` Junio C Hamano
2012-06-07 10:23 ` Thomas Rast [this message]
2012-06-07 10:23 ` [PATCH v7 5/5] Implement line-history search (git log -L) Thomas Rast
2012-06-07 17:42 ` Junio C Hamano
2012-06-07 17:52 ` Thomas Rast
2012-06-10 9:38 ` Zbigniew Jędrzejewski-Szmek
2012-06-15 4:40 ` [PATCH v7 0/5] git log -L, all new and shiny Junio C Hamano
2012-06-15 13:29 ` Thomas Rast
2012-06-15 15:23 ` Junio C Hamano
2012-06-16 6:01 ` Junio C Hamano
2012-06-19 10:11 ` Thomas Rast
2012-06-19 10:33 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=de90975ae231f0a982e6ba4cdd576e085bb08029.1339063659.git.trast@student.ethz.ch \
--to=trast@student.ethz.ch \
--cc=git@vger.kernel.org \
--cc=struggleyb.nku@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).