]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Simplify is_kept_pack()
authorJunio C Hamano <gitster@pobox.com>
Sat, 28 Feb 2009 08:00:21 +0000 (00:00 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sat, 28 Feb 2009 09:06:06 +0000 (01:06 -0800)
This removes --unpacked=<packfile> parameter from the revision parser, and
rewrites its use in git-repack to pass a single --kept-pack-only option
instead.

The new --kept-pack-only option means just that.  When this option is
given, is_kept_pack() that used to say "not on the --unpacked=<packfile>
list" now says "the packfile has corresponding .keep file".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-pack-objects.c
git-repack.sh
revision.c
revision.h
sha1_file.c

index 7e7719b832208b86115310da782e199daae4dc59..150258b6290e55abfefd2b56ab012a2e2c20ae30 100644 (file)
@@ -1915,7 +1915,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)
                const unsigned char *sha1;
                struct object *o;
 
-               if (is_kept_pack(p, revs))
+               if (is_kept_pack(p))
                        continue;
                if (open_pack_index(p))
                        die("cannot open pack index");
@@ -1951,7 +1951,7 @@ static void loosen_unused_packed_objects(struct rev_info *revs)
        const unsigned char *sha1;
 
        for (p = packed_git; p; p = p->next) {
-               if (is_kept_pack(p, revs))
+               if (is_kept_pack(p))
                        continue;
 
                if (open_pack_index(p))
@@ -2149,7 +2149,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                        continue;
                }
                if (!strcmp("--unpacked", arg) ||
-                   !prefixcmp(arg, "--unpacked=") ||
+                   !strcmp("--kept-pack-only", arg) ||
                    !strcmp("--reflog", arg) ||
                    !strcmp("--all", arg)) {
                        use_internal_rev_list = 1;
index 86000151ccbe259132c6cf25d6c23e3f763aba06..a736009c67ec938485c16aa1760b4e56d2e4cc6f 100755 (executable)
@@ -68,10 +68,13 @@ case ",$all_into_one," in
                        if [ -e "$PACKDIR/$e.keep" ]; then
                                : keep
                        else
-                               args="$args --unpacked=$e.pack"
                                existing="$existing $e"
                        fi
                done
+               if test -n "$existing"
+               then
+                       args="--kept-pack-only"
+               fi
                if test -n "$args" -a -n "$unpack_unreachable" -a \
                        -n "$remove_redundant"
                then
index 795e0c03fef4c95cc0d45cb1515f38d8db8211eb..3cfd6539aba3baa35375690d3cb723c1ba7a0fcf 100644 (file)
@@ -963,16 +963,6 @@ static void add_message_grep(struct rev_info *revs, const char *pattern)
        add_grep(revs, pattern, GREP_PATTERN_BODY);
 }
 
-static void add_ignore_packed(struct rev_info *revs, const char *name)
-{
-       int num = ++revs->num_ignore_packed;
-
-       revs->ignore_packed = xrealloc(revs->ignore_packed,
-                                      sizeof(const char *) * (num + 1));
-       revs->ignore_packed[num-1] = name;
-       revs->ignore_packed[num] = NULL;
-}
-
 static int handle_revision_opt(struct rev_info *revs, int argc, const char **argv,
                               int *unkc, const char **unkv)
 {
@@ -1072,12 +1062,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
                revs->edge_hint = 1;
        } else if (!strcmp(arg, "--unpacked")) {
                revs->unpacked = 1;
-               free(revs->ignore_packed);
-               revs->ignore_packed = NULL;
-               revs->num_ignore_packed = 0;
-       } else if (!prefixcmp(arg, "--unpacked=")) {
+               revs->kept_pack_only = 0;
+       } else if (!strcmp(arg, "--kept-pack-only")) {
                revs->unpacked = 1;
-               add_ignore_packed(revs, arg+11);
+               revs->kept_pack_only = 1;
+       } else if (!prefixcmp(arg, "--unpacked=")) {
+               die("--unpacked=<packfile> no longer supported.");
        } else if (!strcmp(arg, "-r")) {
                revs->diff = 1;
                DIFF_OPT_SET(&revs->diffopt, RECURSIVE);
index af414e5d949626cd109db95076f59b16f93af7c4..f63596ff45a120f38abfdb3d6ac2e84691b8ddc3 100644 (file)
@@ -47,7 +47,8 @@ struct rev_info {
                        blob_objects:1,
                        edge_hint:1,
                        limited:1,
-                       unpacked:1, /* see also ignore_packed below */
+                       unpacked:1,
+                       kept_pack_only:1,
                        boundary:2,
                        left_right:1,
                        rewrite_parents:1,
@@ -75,9 +76,6 @@ struct rev_info {
                        missing_newline:1;
        enum date_mode date_mode;
 
-       const char **ignore_packed; /* pretend objects in these are unpacked */
-       int num_ignore_packed;
-
        unsigned int    abbrev;
        enum cmit_fmt   commit_format;
        struct log_info *loginfo;
@@ -159,6 +157,6 @@ enum commit_action {
 extern enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit);
 
 extern int has_sha1_kept_pack(const unsigned char *sha1, const struct rev_info *);
-extern int is_kept_pack(const struct packed_git *, const struct rev_info *);
+extern int is_kept_pack(const struct packed_git *);
 
 #endif
index 6e0a462f101329c0bae175c7f8e4d282d0ba5401..e8a9517d01d3ff671c4c72215d64153fb9098e8a 100644 (file)
@@ -1858,33 +1858,9 @@ off_t find_pack_entry_one(const unsigned char *sha1,
        return 0;
 }
 
-static int matches_pack_name(const struct packed_git *p, const char *name)
+int is_kept_pack(const struct packed_git *p)
 {
-       const char *last_c, *c;
-
-       if (!strcmp(p->pack_name, name))
-               return 1;
-
-       for (c = p->pack_name, last_c = c; *c;)
-               if (*c == '/')
-                       last_c = ++c;
-               else
-                       ++c;
-       if (!strcmp(last_c, name))
-               return 1;
-
-       return 0;
-}
-
-int is_kept_pack(const struct packed_git *p, const struct rev_info *revs)
-{
-       int i;
-
-       for (i = 0; i < revs->num_ignore_packed; i++) {
-               if (matches_pack_name(p, revs->ignore_packed[i]))
-                       return 0;
-       }
-       return 1;
+       return p->pack_keep;
 }
 
 static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
@@ -1900,7 +1876,7 @@ static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
        p = (last_found == (void *)1) ? packed_git : last_found;
 
        do {
-               if (revs->ignore_packed && !is_kept_pack(p, revs))
+               if (revs->kept_pack_only && !is_kept_pack(p))
                        goto next;
                if (p->num_bad_objects) {
                        unsigned i;