daemon: move daemonize() to libgit.a
[gitweb.git] / builtin / repack.c
index 9f4c782d4318f7aeaf655066ed719976e0310e05..ba66c6e37782fcf1bad53b7986e69ec113c4521c 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");
 
        /*
@@ -327,7 +325,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
                                chmod(fname_old, statbuffer.st_mode);
                        }
                        if (rename(fname_old, fname))
-                               exit(errno);
+                               die_errno(_("renaming '%s' failed"), fname_old);
                        free(fname);
                        free(fname_old);
                }
@@ -341,7 +339,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
                                        packdir,
                                        item->string,
                                        exts[ext]);
-                       remove_path(fname);
+                       if (remove_path(fname))
+                               warning(_("removing '%s' failed"), fname);
                }
        }