From: Junio C Hamano Date: Wed, 5 Feb 2014 20:02:29 +0000 (-0800) Subject: Merge branch 'tb/repack-fix-renames' (early part) X-Git-Tag: v1.9.0-rc3~6 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/2171c0c36fb1edbacf17c14490cbe935269dcd04?ds=inline;hp=-c Merge branch 'tb/repack-fix-renames' (early part) Finishing touches to the "rewrite repack in C" series. * 'tb/repack-fix-renames' (early part): repack.c: rename and unlink pack file if it exists --- 2171c0c36fb1edbacf17c14490cbe935269dcd04 diff --combined builtin/repack.c index 6284846d82,fe315772d8..bb2314c9cb --- a/builtin/repack.c +++ b/builtin/repack.c @@@ -78,7 -78,7 +78,7 @@@ static void get_non_kept_pack_filenames 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 +123,7 @@@ int cmd_repack(int argc, const char **a 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,11 -233,13 +233,11 @@@ 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); @@@ -245,7 -247,7 +245,7 @@@ return ret; argv_array_clear(&cmd_args); - if (!nr_packs && !quiet) + if (!names.nr && !quiet) printf("Nothing new to pack.\n"); /* @@@ -258,7 -260,7 +258,7 @@@ 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); @@@ -335,7 -337,7 +335,7 @@@ 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]);