30
#include "list.h"
31
#include "packfile.h"
32
#include "object-store.h"
33
+#include "dir.h"
34
35
static const char *pack_usage[] = {
36
N_("git pack-objects --stdout [<options>...] [< <ref-list> | < <object-list>]"),
56
static int local;
57
static int have_non_local_packs;
58
static int incremental;
58
-static int ignore_packed_keep;
59
+static int ignore_packed_keep_on_disk;
60
+static int ignore_packed_keep_in_core;
61
static int allow_ofs_delta;
62
static struct pack_idx_option pack_idx_opts;
63
static const char *base_name;
984
* Otherwise, we signal "-1" at the end to tell the caller that we do
985
* not know either way, and it needs to check more packs.
986
*/
985
- if (!ignore_packed_keep &&
987
+ if (!ignore_packed_keep_on_disk &&
988
+ !ignore_packed_keep_in_core &&
989
(!local || !have_non_local_packs))
990
return 1;
991
992
if (local && !p->pack_local)
993
return 0;
991
- if (ignore_packed_keep && p->pack_local && p->pack_keep)
994
+ if (p->pack_local &&
995
+ ((ignore_packed_keep_on_disk && p->pack_keep) ||
996
+ (ignore_packed_keep_in_core && p->pack_keep_in_core)))
997
return 0;
998
999
/* we don't know yet; keep looking for more packs */
2680
struct object_id oid;
2681
struct object *o;
2682
2678
- if (!p->pack_local || p->pack_keep)
2683
+ if (!p->pack_local || p->pack_keep || p->pack_keep_in_core)
2684
continue;
2685
if (open_pack_index(p))
2686
die("cannot open pack index");
2743
get_packed_git(the_repository);
2744
2745
while (p) {
2741
- if ((!p->pack_local || p->pack_keep) &&
2746
+ if ((!p->pack_local || p->pack_keep ||
2747
+ p->pack_keep_in_core) &&
2748
find_pack_entry_one(oid->hash, p)) {
2749
last_found = p;
2750
return 1;
2787
struct object_id oid;
2788
2789
for (p = get_packed_git(the_repository); p; p = p->next) {
2784
- if (!p->pack_local || p->pack_keep)
2790
+ if (!p->pack_local || p->pack_keep || p->pack_keep_in_core)
2791
continue;
2792
2793
if (open_pack_index(p))
2813
{
2814
return pack_to_stdout &&
2815
allow_ofs_delta &&
2810
- !ignore_packed_keep &&
2816
+ !ignore_packed_keep_on_disk &&
2817
+ !ignore_packed_keep_in_core &&
2818
(!local || !have_non_local_packs) &&
2819
!incremental;
2820
}
2923
oid_array_clear(&recent_objects);
2924
}
2925
2926
+static void add_extra_kept_packs(const struct string_list *names)
2927
+{
2928
+ struct packed_git *p;
2929
+
2930
+ if (!names->nr)
2931
+ return;
2932
+
2933
+ for (p = get_packed_git(the_repository); p; p = p->next) {
2934
+ const char *name = basename(p->pack_name);
2935
+ int i;
2936
+
2937
+ if (!p->pack_local)
2938
+ continue;
2939
+
2940
+ for (i = 0; i < names->nr; i++)
2941
+ if (!fspathcmp(name, names->items[i].string))
2942
+ break;
2943
+
2944
+ if (i < names->nr) {
2945
+ p->pack_keep_in_core = 1;
2946
+ ignore_packed_keep_in_core = 1;
2947
+ continue;
2948
+ }
2949
+ }
2950
+}
2951
+
2952
static int option_parse_index_version(const struct option *opt,
2953
const char *arg, int unset)
2954
{
2988
struct argv_array rp = ARGV_ARRAY_INIT;
2989
int rev_list_unpacked = 0, rev_list_all = 0, rev_list_reflog = 0;
2990
int rev_list_index = 0;
2991
+ struct string_list keep_pack_list = STRING_LIST_INIT_NODUP;
2992
struct option pack_objects_options[] = {
2993
OPT_SET_INT('q', "quiet", &progress,
2994
N_("do not show progress meter"), 0),
3053
N_("create thin packs")),
3054
OPT_BOOL(0, "shallow", &shallow,
3055
N_("create packs suitable for shallow fetches")),
3022
- OPT_BOOL(0, "honor-pack-keep", &ignore_packed_keep,
3056
+ OPT_BOOL(0, "honor-pack-keep", &ignore_packed_keep_on_disk,
3057
N_("ignore packs that have companion .keep file")),
3058
+ OPT_STRING_LIST(0, "keep-pack", &keep_pack_list, N_("name"),
3059
+ N_("ignore this pack")),
3060
OPT_INTEGER(0, "compression", &pack_compression_level,
3061
N_("pack compression level")),
3062
OPT_SET_INT(0, "keep-true-parents", &grafts_replace_parents,
3184
if (progress && all_progress_implied)
3185
progress = 2;
3186
3151
- if (ignore_packed_keep) {
3187
+ add_extra_kept_packs(&keep_pack_list);
3188
+ if (ignore_packed_keep_on_disk) {
3189
struct packed_git *p;
3190
for (p = get_packed_git(the_repository); p; p = p->next)
3191
if (p->pack_local && p->pack_keep)
3192
break;
3193
if (!p) /* no keep-able packs found */
3157
- ignore_packed_keep = 0;
3194
+ ignore_packed_keep_on_disk = 0;
3195
}
3196
if (local) {
3197
/*
3161
- * unlike ignore_packed_keep above, we do not want to
3162
- * unset "local" based on looking at packs, as it
3163
- * also covers non-local objects
3198
+ * unlike ignore_packed_keep_on_disk above, we do not
3199
+ * want to unset "local" based on looking at packs, as
3200
+ * it also covers non-local objects
3201
*/
3202
struct packed_git *p;
3203
for (p = get_packed_git(the_repository); p; p = p->next) {