Anonymous avatar Anonymous committed cb2cada

Catch empty pathnames in trees during fsck

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>;
Signed-off-by: Junio C Hamano <junkio@cox.net>;

Comments (0)

Files changed (1)

 {
 	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;
 
 		if (strchr(name, '/'))
 			has_full_path = 1;
+		if (!*name)
+			has_empty_name = 1;
 		has_zero_pad |= *(char *)desc.buffer == '0';
 		update_tree_entry(&desc);
 
 	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");
 	}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.