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

[PATCH] Catch empty pathnames in trees during fsck

From
Shawn O. Pearce <spearce@spearce.org>
Date
Apr 29, 2007, 00:29 UTC
Message-ID
<20070429002923.GA30026@spearce.org>

Released versions of fast-import have been able to create a tree that contains files or subtrees that contain no name. Unfortunately these trees aren't valid, but people may have actually tried to create them due to bugs in import-tars.perl or their own fast-import frontend.

We now look for this unusual condition and warn the user if at least one of their tree objects contains the problem.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 builtin-fsck.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/builtin-fsck.c b/builtin-fsck.c
index fcb8ed5..44ce629 100644
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
@@ -219,6 +219,7 @@ static int fsck_tree(struct tree *item)
 {
 	int retval;
 	int has_full_path = 0;
+	int has_empty_name = 0;
 	int has_zero_pad = 0;
 	int has_bad_modes = 0;
 	int has_dup_entries = 0;
@@ -242,6 +243,8 @@ static int fsck_tree(struct tree *item)
 
 		if (strchr(name, '/'))
 			has_full_path = 1;
+		if (!*name)
+			has_empty_name = 1;
 		has_zero_pad |= *(char *)desc.buffer == '0';
 		update_tree_entry(&desc);
 
@@ -291,6 +294,9 @@ static int fsck_tree(struct tree *item)
 	if (has_full_path) {
 		objwarning(&item->object, "contains full pathnames");
 	}
+	if (has_empty_name) {
+		objwarning(&item->object, "contains empty pathname");
+	}
 	if (has_zero_pad) {
 		objwarning(&item->object, "contains zero-padded file modes");
 	}
-- 
1.5.1.1.135.gf948
Message 1 of 1 in “Catch empty pathnames in trees during fsck”
  1. Catch empty pathnames in trees during fsckShawn O. Pearce, Apr 29, 2007

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.