sha1_file: reorder code in prepare_packed_git_one()

The current loop does

	while (...) {
		if (it is not an .idx file)
			continue;
		process .idx file;
	}

and is reordered to

	while (...) {
		if (it is an .idx file) {
			process .idx file;
		}
	}

This makes it easier to add new extension file processing.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Nguyễn Thái Ngọc Duy 2013-02-13 16:13:17 +07:00 коммит произвёл Junio C Hamano
Родитель 0bdaa12169
Коммит d90906a902
1 изменённых файлов: 14 добавлений и 16 удалений

Просмотреть файл

@ -1024,28 +1024,26 @@ static void prepare_packed_git_one(char *objdir, int local)
int namelen = strlen(de->d_name);
struct packed_git *p;
if (!has_extension(de->d_name, ".idx"))
continue;
if (len + namelen + 1 > sizeof(path))
continue;
/* Don't reopen a pack we already have. */
strcpy(path + len, de->d_name);
if (has_extension(de->d_name, ".idx")) {
/* Don't reopen a pack we already have. */
for (p = packed_git; p; p = p->next) {
if (!memcmp(path, p->pack_name, len + namelen - 4))
break;
}
if (p)
continue;
/* See if it really is a valid .idx file with corresponding
* .pack file that we can map.
if (p == NULL &&
/*
* See if it really is a valid .idx file with
* corresponding .pack file that we can map.
*/
p = add_packed_git(path, len + namelen, local);
if (!p)
continue;
(p = add_packed_git(path, len + namelen, local)) != NULL)
install_packed_git(p);
}
}
closedir(dir);
}