git-verify-pack: get rid of while loop
Get rid of that while loop which was apparently used as a way to avoid goto's (why?). It's easy now because there is only one break left at the end of it. Also make the comment clearer. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <junkio@cox.net>
Rene Scharfe committed
Aug 10, 2006 at 17:02 UTC
fc5fc50980958f742a9f3d79fb7a64f02e87877a
1 file changed
+16
-16
verify-pack.c
+16
-16
@@ -11,23 +11,23 @@ static int verify_one_pack(const char *path, int verbose)
11
if (len >= PATH_MAX)
12
return error("name too long: %s", path);
13
14
- while (1) {
15
- /* Should name foo.idx, but foo.pack may be named;
16
- * convert it to foo.idx
17
- */
18
- if (has_extension(arg, len, ".pack")) {
19
- strcpy(arg + len - 5, ".idx");
20
- len--;
21
- } else if (!has_extension(arg, len, ".idx")) {
22
- if (len + 4 >= PATH_MAX)
23
- return error("name too long: %s.idx", arg);
24
- strcpy(arg + len, ".idx");
25
- len += 4;
26
- }
27
- if ((g = add_packed_git(arg, len, 1)))
28
- break;
29
- return error("packfile %s not found.", arg);
14
+ /*
15
+ * In addition to "foo.idx" we accept "foo.pack" and "foo";
16
+ * normalize these forms to "foo.idx" for add_packed_git().
17
+ */
18
+ if (has_extension(arg, len, ".pack")) {
19
+ strcpy(arg + len - 5, ".idx");
20
+ len--;
21
+ } else if (!has_extension(arg, len, ".idx")) {
22
+ if (len + 4 >= PATH_MAX)
23
+ return error("name too long: %s.idx", arg);
24
+ strcpy(arg + len, ".idx");
25
+ len += 4;
26
}
27
+
28
+ if (!(g = add_packed_git(arg, len, 1)))
29
+ return error("packfile %s not found.", arg);
30
+
31
return verify_pack(g, verbose);
32
}
33