{"thread":{"id":"7892","subject":"[PATCH] Catch empty pathnames in trees during fsck","startedAt":"2007-04-29T00:29:23Z","lastAt":"2007-04-29T00:29:23Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"40681","messageId":"20070429002923.GA30026@spearce.org","threadId":"7892","inReplyTo":null,"subject":"[PATCH] Catch empty pathnames in trees during fsck","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-04-29T00:29:23Z","receivedAt":"2007-04-29T00:29:23Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Released versions of fast-import have been able to create a tree that\ncontains files or subtrees that contain no name.  Unfortunately these\ntrees aren't valid, but people may have actually tried to create them\ndue to bugs in import-tars.perl or their own fast-import frontend.\n\nWe now look for this unusual condition and warn the user if at\nleast one of their tree objects contains the problem.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n builtin-fsck.c |    6 ++++++\n 1 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-fsck.c b/builtin-fsck.c\nindex fcb8ed5..44ce629 100644\n--- a/builtin-fsck.c\n+++ b/builtin-fsck.c\n@@ -219,6 +219,7 @@ static int fsck_tree(struct tree *item)\n {\n \tint retval;\n \tint has_full_path = 0;\n+\tint has_empty_name = 0;\n \tint has_zero_pad = 0;\n \tint has_bad_modes = 0;\n \tint has_dup_entries = 0;\n@@ -242,6 +243,8 @@ static int fsck_tree(struct tree *item)\n \n \t\tif (strchr(name, '/'))\n \t\t\thas_full_path = 1;\n+\t\tif (!*name)\n+\t\t\thas_empty_name = 1;\n \t\thas_zero_pad |= *(char *)desc.buffer == '0';\n \t\tupdate_tree_entry(&desc);\n \n@@ -291,6 +294,9 @@ static int fsck_tree(struct tree *item)\n \tif (has_full_path) {\n \t\tobjwarning(&item->object, \"contains full pathnames\");\n \t}\n+\tif (has_empty_name) {\n+\t\tobjwarning(&item->object, \"contains empty pathname\");\n+\t}\n \tif (has_zero_pad) {\n \t\tobjwarning(&item->object, \"contains zero-padded file modes\");\n \t}\n-- \n1.5.1.1.135.gf948\n"}]}