diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-05-23 16:06:01 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-05-23 16:06:01 -0700 |
commit | e5e9714a106ab668ac982cf73f31919eb4e354fd (patch) | |
tree | 01c02ee795feeb0b7594ab9d91f20bfe619d3042 /builtin-pack-objects.c | |
parent | Merge branch 'sp/ignorecase' (diff) | |
parent | Documentation/git-repack.txt: document new -A behaviour (diff) | |
download | tgif-e5e9714a106ab668ac982cf73f31919eb4e354fd.tar.xz |
Merge branch 'bc/repack'
* bc/repack:
Documentation/git-repack.txt: document new -A behaviour
let pack-objects do the writing of unreachable objects as loose objects
add a force_object_loose() function
builtin-gc.c: deprecate --prune, it now really has no effect
git-gc: always use -A when manually repacking
repack: modify behavior of -A option to leave unreferenced objects unpacked
Conflicts:
builtin-pack-objects.c
Diffstat (limited to 'builtin-pack-objects.c')
-rw-r--r-- | builtin-pack-objects.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index e20851e1c9..f43eb67016 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -28,7 +28,8 @@ git-pack-objects [{ -q | --progress | --all-progress }] \n\ [--window=N] [--window-memory=N] [--depth=N] \n\ [--no-reuse-delta] [--no-reuse-object] [--delta-base-offset] \n\ [--threads=N] [--non-empty] [--revs [--unpacked | --all]*] [--reflog] \n\ - [--stdout | base-name] [--include-tag] [--keep-unreachable] \n\ + [--stdout | base-name] [--include-tag] \n\ + [--keep-unreachable | --unpack-unreachable] \n\ [<ref-list | <object-list]"; struct object_entry { @@ -67,7 +68,7 @@ static uint32_t nr_objects, nr_alloc, nr_result, nr_written; static int non_empty; static int reuse_delta = 1, reuse_object = 1; -static int keep_unreachable, include_tag; +static int keep_unreachable, unpack_unreachable, include_tag; static int local; static int incremental; static int allow_ofs_delta; @@ -1946,6 +1947,32 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs) free(in_pack.array); } +static void loosen_unused_packed_objects(struct rev_info *revs) +{ + struct packed_git *p; + uint32_t i; + const unsigned char *sha1; + + for (p = packed_git; p; p = p->next) { + for (i = 0; i < revs->num_ignore_packed; i++) { + if (matches_pack_name(p, revs->ignore_packed[i])) + break; + } + if (revs->num_ignore_packed <= i) + continue; + + if (open_pack_index(p)) + die("cannot open pack index"); + + for (i = 0; i < p->num_objects; i++) { + sha1 = nth_packed_object_sha1(p, i); + if (!locate_object_entry(sha1)) + if (force_object_loose(sha1, p->mtime)) + die("unable to force loose object"); + } + } +} + static void get_object_list(int ac, const char **av) { struct rev_info revs; @@ -1980,6 +2007,8 @@ static void get_object_list(int ac, const char **av) if (keep_unreachable) add_objects_in_unpacked_packs(&revs); + if (unpack_unreachable) + loosen_unused_packed_objects(&revs); } static int adjust_perm(const char *path, mode_t mode) @@ -2114,6 +2143,10 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) keep_unreachable = 1; continue; } + if (!strcmp("--unpack-unreachable", arg)) { + unpack_unreachable = 1; + continue; + } if (!strcmp("--include-tag", arg)) { include_tag = 1; continue; @@ -2179,6 +2212,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) if (!pack_to_stdout && thin) die("--thin cannot be used to build an indexable pack."); + if (keep_unreachable && unpack_unreachable) + die("--keep-unreachable and --unpack-unreachable are incompatible."); + #ifdef THREADED_DELTA_SEARCH if (!delta_search_threads) /* --threads=0 means autodetect */ delta_search_threads = online_cpus(); |