Git 2.23
[gitweb.git] / builtin / verify-pack.c
index e841b4a38d2b47c39d95683a5747cbc19da1f48b..c2a1a5c5048412abaa545862dbd0f3dd93338dc5 100644 (file)
@@ -1,5 +1,6 @@
 #include "builtin.h"
 #include "cache.h"
+#include "config.h"
 #include "run-command.h"
 #include "parse-options.h"
 
@@ -8,7 +9,7 @@
 
 static int verify_one_pack(const char *path, unsigned int flags)
 {
-       struct child_process index_pack;
+       struct child_process index_pack = CHILD_PROCESS_INIT;
        const char *argv[] = {"index-pack", NULL, NULL, NULL };
        struct strbuf arg = STRBUF_INIT;
        int verbose = flags & VERIFY_PACK_VERBOSE;
@@ -27,13 +28,11 @@ static int verify_one_pack(const char *path, unsigned int flags)
         * normalize these forms to "foo.pack" for "index-pack --verify".
         */
        strbuf_addstr(&arg, path);
-       if (has_extension(arg.buf, ".idx"))
-               strbuf_splice(&arg, arg.len - 3, 3, "pack", 4);
-       else if (!has_extension(arg.buf, ".pack"))
-               strbuf_add(&arg, ".pack", 5);
+       if (strbuf_strip_suffix(&arg, ".idx") ||
+           !ends_with(arg.buf, ".pack"))
+               strbuf_addstr(&arg, ".pack");
        argv[2] = arg.buf;
 
-       memset(&index_pack, 0, sizeof(index_pack));
        index_pack.argv = argv;
        index_pack.git_cmd = 1;
 
@@ -53,7 +52,7 @@ static int verify_one_pack(const char *path, unsigned int flags)
 }
 
 static const char * const verify_pack_usage[] = {
-       "git verify-pack [-v|--verbose] [-s|--stat-only] <pack>...",
+       N_("git verify-pack [-v | --verbose] [-s | --stat-only] <pack>..."),
        NULL
 };
 
@@ -63,9 +62,9 @@ int cmd_verify_pack(int argc, const char **argv, const char *prefix)
        unsigned int flags = 0;
        int i;
        const struct option verify_pack_options[] = {
-               OPT_BIT('v', "verbose", &flags, "verbose",
+               OPT_BIT('v', "verbose", &flags, N_("verbose"),
                        VERIFY_PACK_VERBOSE),
-               OPT_BIT('s', "stat-only", &flags, "show statistics only",
+               OPT_BIT('s', "stat-only", &flags, N_("show statistics only"),
                        VERIFY_PACK_STAT_ONLY),
                OPT_END()
        };