repack: stop using magic number for ARRAY_SIZE(exts)

We have a static array of extensions, but hardcode the size of the array in our loops. Let's pull out this magic number, which will make it easier to change. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Dec 21, 2013 at 09:00 UTC b328c2166e67a0391a776d075acdfbd74e122e5c
1 file changed +4 -4
builtin/repack.c
+4 -4
@@ -115,7 +115,7 @@ static void remove_redundant_pack(const char *dir_name, const char *base_name)
115
116 int cmd_repack(int argc, const char **argv, const char *prefix)
117 {
118 - const char *exts[2] = {".pack", ".idx"};
118 + const char *exts[] = {".pack", ".idx"};
119 struct child_process cmd;
120 struct string_list_item *item;
121 struct argv_array cmd_args = ARGV_ARRAY_INIT;
@@ -258,7 +258,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
258 */
259 failed = 0;
260 for_each_string_list_item(item, &names) {
261 - for (ext = 0; ext < 2; ext++) {
261 + for (ext = 0; ext < ARRAY_SIZE(exts); ext++) {
262 char *fname, *fname_old;
263 fname = mkpathdup("%s/%s%s", packdir,
264 item->string, exts[ext]);
@@ -315,7 +315,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
315
316 /* Now the ones with the same name are out of the way... */
317 for_each_string_list_item(item, &names) {
318 - for (ext = 0; ext < 2; ext++) {
318 + for (ext = 0; ext < ARRAY_SIZE(exts); ext++) {
319 char *fname, *fname_old;
320 struct stat statbuffer;
321 fname = mkpathdup("%s/pack-%s%s",
@@ -335,7 +335,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
335
336 /* Remove the "old-" files */
337 for_each_string_list_item(item, &names) {
338 - for (ext = 0; ext < 2; ext++) {
338 + for (ext = 0; ext < ARRAY_SIZE(exts); ext++) {
339 char *fname;
340 fname = mkpath("%s/old-pack-%s%s",
341 packdir,