Skip to content

Commit 09d4664

Browse files
pcloudsgitster
authored andcommitted
Add for_each_commit_graft() to iterate all grafts
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 594ffe8 commit 09d4664

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

commit.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,14 @@ struct commit_graft *lookup_commit_graft(const unsigned char *sha1)
214214
return commit_graft[pos];
215215
}
216216

217+
int for_each_commit_graft(each_commit_graft_fn fn, void *cb_data)
218+
{
219+
int i, ret;
220+
for (i = ret = 0; i < commit_graft_nr && !ret; i++)
221+
ret = fn(commit_graft[i], cb_data);
222+
return ret;
223+
}
224+
217225
int write_shallow_commits(struct strbuf *out, int use_pack_protocol)
218226
{
219227
int i, count = 0;

commit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ struct commit_graft {
142142
int nr_parent; /* < 0 if shallow commit */
143143
unsigned char parent[FLEX_ARRAY][20]; /* more */
144144
};
145+
typedef int (*each_commit_graft_fn)(const struct commit_graft *, void *);
145146

146147
struct commit_graft *read_graft_line(char *buf, int len);
147148
int register_commit_graft(struct commit_graft *, int);
@@ -154,6 +155,7 @@ extern struct commit_list *get_octopus_merge_bases(struct commit_list *in);
154155
extern int register_shallow(const unsigned char *sha1);
155156
extern int unregister_shallow(const unsigned char *sha1);
156157
extern int write_shallow_commits(struct strbuf *out, int use_pack_protocol);
158+
extern int for_each_commit_graft(each_commit_graft_fn, void *);
157159
extern int is_repository_shallow(void);
158160
extern struct commit_list *get_shallow_commits(struct object_array *heads,
159161
int depth, int shallow_flag, int not_shallow_flag);

0 commit comments

Comments
 (0)