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

[RFC PATCH 2/4] Add attach_reflog_info

From
Deskin Miller <deskinm@umich.edu>
Date
Feb 26, 2009, 04:44 UTC
Message-ID
<dde2a04808e6791dafecfab811b6c55ba252c3c5.1235622145.git.deskinm@umich.edu>
In-Reply-To
<cover.1235622145.git.deskinm@umich.edu>

To enable pretty-printing to print reflog information, the commit object needs to carry its associated reflog entry. This function uses the util field to point to the appropriate struct reflog_info.

Signed-off-by: Deskin Miller <deskinm@umich.edu>
---
 reflog-walk.c |   18 ++++++++++++++++++
 reflog-walk.h |    2 ++
 2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/reflog-walk.c b/reflog-walk.c
index dd172ae..3e8457f 100644
--- a/reflog-walk.c
+++ b/reflog-walk.c
@@ -235,6 +235,24 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
 	commit->object.flags &= ~(ADDED | SEEN | SHOWN);
 }
 
+void attach_reflog_info(struct reflog_walk_info *info, struct commit *commit)
+{
+	if (info && info->last_commit_reflog) {
+		struct commit_reflog *commit_reflog = info->last_commit_reflog;
+
+		if (commit->util &&
+		    (((void *)(commit_reflog->reflogs->items
+			       + commit_reflog->reflogs->nr) < commit->util)
+		     || ((void *)(commit_reflog->reflogs->items +
+				  commit_reflog->recno + 1) > commit->util))) {
+			die("commit->util being used, cannot attach reflog");
+		}
+
+		commit->util = &commit_reflog->reflogs->items
+			[commit_reflog->recno+1];
+	}
+}
+
 void show_reflog_message(struct reflog_walk_info* info, int oneline,
 	int relative_date)
 {
diff --git a/reflog-walk.h b/reflog-walk.h
index 7b00993..44f97e1 100644
--- a/reflog-walk.h
+++ b/reflog-walk.h
@@ -16,6 +16,8 @@ extern int add_reflog_for_walk(struct reflog_walk_info *info,
 		struct commit *commit, const char *name);
 extern void fake_reflog_parent(struct reflog_walk_info *info,
 		struct commit *commit);
+extern void attach_reflog_info(struct reflog_walk_info *info,
+		struct commit *commit);
 extern void show_reflog_message(struct reflog_walk_info *info, int, int);
 
 #endif
-- 
1.6.2.rc0.90.g0753
Previous: Deskin MillerNext: Deskin Miller
Message 3 of 7 in “git log -g --pretty=format: learns about reflog”
  1. 0/4 git log -g --pretty=format: learns about reflogDeskin Miller, Feb 26, 2009
  2. 1/4 Expose reflog_info struct in headerDeskin Miller, Feb 26, 2009
  3. 2/4 Add attach_reflog_infoDeskin Miller, Feb 26, 2009
  4. 3/4 Attach reflog to commit prior to pretty-printingDeskin Miller, Feb 26, 2009
  5. 4/4 Teach pretty-printer new reflog format codesDeskin Miller, Feb 26, 2009
  6. Johannes SchindelinFeb 26, 2009
  7. Jeff KingFeb 26, 2009

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.