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

[PATCH 1/2] fsck_handle_reflog_sha1(): new function

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Jun 8, 2015, 13:40 UTC
Message-ID
<1c6f5540fe974016c1547163c7b891707019154d.1433769878.git.mhagger@alum.mit.edu>
In-Reply-To
<cover.1433769878.git.mhagger@alum.mit.edu>

New function, extracted from fsck_handle_reflog_ent(). The extra is_null_sha1() test for the new reference is currently unnecessary, as reflogs are deleted when the reference itself is deleted. But it doesn't hurt, either.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
 builtin/fsck.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 4e8e2ee..b1b6c60 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -451,28 +451,29 @@ static void fsck_dir(int i, char *path)
 
 static int default_refs;
 
-static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
-		const char *email, unsigned long timestamp, int tz,
-		const char *message, void *cb_data)
+static void fsck_handle_reflog_sha1(unsigned char *sha1)
 {
 	struct object *obj;
 
-	if (verbose)
-		fprintf(stderr, "Checking reflog %s->%s\n",
-			sha1_to_hex(osha1), sha1_to_hex(nsha1));
-
-	if (!is_null_sha1(osha1)) {
-		obj = lookup_object(osha1);
+	if (!is_null_sha1(sha1)) {
+		obj = lookup_object(sha1);
 		if (obj) {
 			obj->used = 1;
 			mark_object_reachable(obj);
 		}
 	}
-	obj = lookup_object(nsha1);
-	if (obj) {
-		obj->used = 1;
-		mark_object_reachable(obj);
-	}
+}
+
+static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
+		const char *email, unsigned long timestamp, int tz,
+		const char *message, void *cb_data)
+{
+	if (verbose)
+		fprintf(stderr, "Checking reflog %s->%s\n",
+			sha1_to_hex(osha1), sha1_to_hex(nsha1));
+
+	fsck_handle_reflog_sha1(osha1);
+	fsck_handle_reflog_sha1(nsha1);
 	return 0;
 }
 
-- 
2.1.4
Previous: Michael HaggertyNext: Johannes Schindelin
Message 2 of 11 in “fsck: don't ignore broken reflog entries”
  1. 0/2 fsck: don't ignore broken reflog entriesMichael Haggerty, Jun 8, 2015
  2. 1/2 fsck_handle_reflog_sha1(): new functionMichael Haggerty, Jun 8, 2015
  3. Johannes SchindelinJun 8, 2015
  4. Junio C HamanoJun 8, 2015
  5. Michael HaggertyJun 8, 2015
  6. 2/2 fsck: report errors if reflog entries point at invalid objectsMichael Haggerty, Jun 8, 2015
  7. Johannes SchindelinJun 8, 2015
  8. Michael HaggertyJun 8, 2015
  9. Johannes SchindelinJun 8, 2015
  10. Jeff KingJun 8, 2015
  11. Johannes SchindelinJun 8, 2015

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.