From 09d46644b780ede1a6b757db3e1a1ae9c1128a13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Thu, 18 Aug 2011 19:29:35 +0700 Subject: [PATCH] Add for_each_commit_graft() to iterate all grafts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- commit.c | 8 ++++++++ commit.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/commit.c b/commit.c index ac337c7d7d..246cd18b0e 100644 --- a/commit.c +++ b/commit.c @@ -214,6 +214,14 @@ struct commit_graft *lookup_commit_graft(const unsigned char *sha1) return commit_graft[pos]; } +int for_each_commit_graft(each_commit_graft_fn fn, void *cb_data) +{ + int i, ret; + for (i = ret = 0; i < commit_graft_nr && !ret; i++) + ret = fn(commit_graft[i], cb_data); + return ret; +} + int write_shallow_commits(struct strbuf *out, int use_pack_protocol) { int i, count = 0; diff --git a/commit.h b/commit.h index a2d571b974..9bf3fefea2 100644 --- a/commit.h +++ b/commit.h @@ -142,6 +142,7 @@ struct commit_graft { int nr_parent; /* < 0 if shallow commit */ unsigned char parent[FLEX_ARRAY][20]; /* more */ }; +typedef int (*each_commit_graft_fn)(const struct commit_graft *, void *); struct commit_graft *read_graft_line(char *buf, int len); int register_commit_graft(struct commit_graft *, int); @@ -154,6 +155,7 @@ extern struct commit_list *get_octopus_merge_bases(struct commit_list *in); extern int register_shallow(const unsigned char *sha1); extern int unregister_shallow(const unsigned char *sha1); extern int write_shallow_commits(struct strbuf *out, int use_pack_protocol); +extern int for_each_commit_graft(each_commit_graft_fn, void *); extern int is_repository_shallow(void); extern struct commit_list *get_shallow_commits(struct object_array *heads, int depth, int shallow_flag, int not_shallow_flag);