Merge branch 'jk/config-path-include-fix'
[gitweb.git] / builtin / repack.c
index bca771054e30f621f4aed31d6dc2ab6b30a0b5cb..bb2314c9cb0ce3e01372c6c3a27396931c0143ab 100644 (file)
@@ -78,7 +78,7 @@ static void get_non_kept_pack_filenames(struct string_list *fname_list)
                return;
 
        while ((e = readdir(dir)) != NULL) {
-               if (suffixcmp(e->d_name, ".pack"))
+               if (!ends_with(e->d_name, ".pack"))
                        continue;
 
                len = strlen(e->d_name) - strlen(".pack");
@@ -123,7 +123,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
        struct string_list rollback = STRING_LIST_INIT_NODUP;
        struct string_list existing_packs = STRING_LIST_INIT_DUP;
        struct strbuf line = STRBUF_INIT;
-       int nr_packs, ext, ret, failed;
+       int ext, ret, failed;
        FILE *out;
 
        /* variables to be filled by option parsing */
@@ -233,13 +233,11 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
        if (ret)
                return ret;
 
-       nr_packs = 0;
        out = xfdopen(cmd.out, "r");
        while (strbuf_getline(&line, out, '\n') != EOF) {
                if (line.len != 40)
                        die("repack: Expecting 40 character sha1 lines only from pack-objects.");
                string_list_append(&names, line.buf);
-               nr_packs++;
        }
        fclose(out);
        ret = finish_command(&cmd);
@@ -247,7 +245,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
                return ret;
        argv_array_clear(&cmd_args);
 
-       if (!nr_packs && !quiet)
+       if (!names.nr && !quiet)
                printf("Nothing new to pack.\n");
 
        /*
@@ -260,7 +258,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
        for_each_string_list_item(item, &names) {
                for (ext = 0; ext < 2; ext++) {
                        char *fname, *fname_old;
-                       fname = mkpathdup("%s/%s%s", packdir,
+                       fname = mkpathdup("%s/pack-%s%s", packdir,
                                                item->string, exts[ext]);
                        if (!file_exists(fname)) {
                                free(fname);
@@ -337,7 +335,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
        for_each_string_list_item(item, &names) {
                for (ext = 0; ext < 2; ext++) {
                        char *fname;
-                       fname = mkpath("%s/old-pack-%s%s",
+                       fname = mkpath("%s/old-%s%s",
                                        packdir,
                                        item->string,
                                        exts[ext]);