git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/5] Add for_each_commit_graft() to iterate all grafts

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Aug 18, 2011, 12:29 UTC
Message-ID
<1313670578-2939-3-git-send-email-pclouds@gmail.com>
In-Reply-To
<1313670578-2939-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 commit.c |    8 ++++++++
 commit.h |    2 ++
 2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/commit.c b/commit.c
index dc22695..efd647d 100644
--- a/commit.c
+++ b/commit.c
@@ -226,6 +226,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 0e36fd0..9030d42 100644
--- a/commit.h
+++ b/commit.h
@@ -143,6 +143,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);
@@ -155,6 +156,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);
-- 
1.7.4.74.g639db
Previous: Junio C HamanoNext: Nguyễn Thái Ngọc Duy
Message 7 of 14 in “log: decorate grafted commits with "grafted"”
  1. log: decorate grafted commits with "grafted"Nguyễn Thái Ngọc Duy, Aug 17, 2011
  2. Junio C HamanoAug 17, 2011
  3. Nguyen Thai Ngoc DuyAug 18, 2011
  4. 0/5 Decorate grafts and replacesNguyễn Thái Ngọc Duy, Aug 18, 2011
  5. 1/5 decoration: do not mis-decorate refs with same prefixNguyễn Thái Ngọc Duy, Aug 18, 2011
  6. Junio C HamanoAug 18, 2011
  7. 2/5 Add for_each_commit_graft() to iterate all graftsNguyễn Thái Ngọc Duy, Aug 18, 2011
  8. 3/5 Move write_shallow_commits to fetch-pack.cNguyễn Thái Ngọc Duy, Aug 18, 2011
  9. Junio C HamanoAug 18, 2011
  10. 4/5 log: decorate grafted commits with "grafted"Nguyễn Thái Ngọc Duy, Aug 18, 2011
  11. Junio C HamanoAug 18, 2011
  12. 5/5 log: decorate "replaced" on to replaced commitsNguyễn Thái Ngọc Duy, Aug 18, 2011
  13. Junio C HamanoAug 18, 2011
  14. log: decorate "replaced" on to replaced commitsNguyễn Thái Ngọc Duy, Aug 19, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.