Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
repack: stop using magic number for ARRAY_SIZE(exts)
author
Jeff King
<peff@peff.net>
Sat, 21 Dec 2013 14:00:19 +0000
(09:00 -0500)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 30 Dec 2013 20:19:23 +0000
(12:19 -0800)
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>
builtin/repack.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
7cc8f97
)
diff --git
a/builtin/repack.c
b/builtin/repack.c
index a0ff5c704f4e21c5021091aa7335e00959993470..2e88975e0c53b950505ecb87570717b2aa40eb37 100644
(file)
--- a/
builtin/repack.c
+++ b/
builtin/repack.c
@@
-115,7
+115,7
@@
static void remove_redundant_pack(const char *dir_name, const char *base_name)
int cmd_repack(int argc, const char **argv, const char *prefix)
{
int cmd_repack(int argc, const char **argv, const char *prefix)
{
- const char *exts[
2
] = {".pack", ".idx"};
+ const char *exts[] = {".pack", ".idx"};
struct child_process cmd;
struct string_list_item *item;
struct argv_array cmd_args = ARGV_ARRAY_INIT;
struct child_process cmd;
struct string_list_item *item;
struct argv_array cmd_args = ARGV_ARRAY_INIT;
@@
-258,7
+258,7
@@
int cmd_repack(int argc, const char **argv, const char *prefix)
*/
failed = 0;
for_each_string_list_item(item, &names) {
*/
failed = 0;
for_each_string_list_item(item, &names) {
- for (ext = 0; ext <
2
; ext++) {
+ for (ext = 0; ext <
ARRAY_SIZE(exts)
; ext++) {
char *fname, *fname_old;
fname = mkpathdup("%s/%s%s", packdir,
item->string, exts[ext]);
char *fname, *fname_old;
fname = mkpathdup("%s/%s%s", packdir,
item->string, exts[ext]);
@@
-315,7
+315,7
@@
int cmd_repack(int argc, const char **argv, const char *prefix)
/* Now the ones with the same name are out of the way... */
for_each_string_list_item(item, &names) {
/* Now the ones with the same name are out of the way... */
for_each_string_list_item(item, &names) {
- for (ext = 0; ext <
2
; ext++) {
+ for (ext = 0; ext <
ARRAY_SIZE(exts)
; ext++) {
char *fname, *fname_old;
struct stat statbuffer;
fname = mkpathdup("%s/pack-%s%s",
char *fname, *fname_old;
struct stat statbuffer;
fname = mkpathdup("%s/pack-%s%s",
@@
-335,7
+335,7
@@
int cmd_repack(int argc, const char **argv, const char *prefix)
/* Remove the "old-" files */
for_each_string_list_item(item, &names) {
/* Remove the "old-" files */
for_each_string_list_item(item, &names) {
- for (ext = 0; ext <
2
; ext++) {
+ for (ext = 0; ext <
ARRAY_SIZE(exts)
; ext++) {
char *fname;
fname = mkpath("%s/old-pack-%s%s",
packdir,
char *fname;
fname = mkpath("%s/old-pack-%s%s",
packdir,