From: Bo Yang <struggleyb.nku@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, Jens.Lehmann@web.de, trast@student.ethz.ch
Subject: [PATCH v1 1/4] make rewrite_parents an external function
Date: Sun, 11 Jul 2010 14:27:34 +0800 [thread overview]
Message-ID: <1278829657-26607-2-git-send-email-struggleyb.nku@gmail.com> (raw)
In-Reply-To: <1278829657-26607-1-git-send-email-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.
This commit decouple the dependence between them, make
rewrite_one as a callback function and be passed to
rewrite_parents. Make rewrite_parents public to other
part of git.
We will use this function in line.c.
Signed-off-by: Bo Yang <struggleyb.nku@gmail.com>
---
revision.c | 11 +++--------
revision.h | 10 ++++++++++
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/revision.c b/revision.c
index 63f37ea..72d9654 100644
--- a/revision.c
+++ b/revision.c
@@ -1893,12 +1893,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;
@@ -1920,7 +1914,8 @@ 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 rewrite_one)
{
struct commit_list **pp = &commit->parents;
while (*pp) {
@@ -1993,7 +1988,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 433da9a..9b8e3d9 100644
--- a/revision.h
+++ b/revision.h
@@ -200,4 +200,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)(struct rev_info *revs, struct commit **pp);
+
+extern int rewrite_parents(struct rev_info *revs, struct commit *commit,
+ rewrite_parent rewrite_one);
#endif
--
1.7.0.2.273.gc2413.dirty
next prev parent reply other threads:[~2010-07-11 6:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-11 6:27 [PATCH v1 0/4] add parent rewrite feature to line level log Bo Yang
2010-07-11 6:27 ` Bo Yang [this message]
2010-07-14 19:10 ` [PATCH v1 1/4] make rewrite_parents an external function Junio C Hamano
2010-07-11 6:27 ` [PATCH v1 2/4] add parent rewrite feature to line level log Bo Yang
2010-07-13 20:47 ` Junio C Hamano
2010-07-11 6:27 ` [PATCH v1 3/4] line.c output the '--graph' padding before each line Bo Yang
2010-07-13 20:49 ` Junio C Hamano
2010-07-11 6:27 ` [PATCH v1 4/4] add test cases for '--graph' of line level log Bo Yang
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=1278829657-26607-2-git-send-email-struggleyb.nku@gmail.com \
--to=struggleyb.nku@gmail.com \
--cc=Jens.Lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=trast@student.ethz.ch \
/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).