@matheusbsbs / matheus-bagliano / commits / 69e020ae00
Fork 0

is_kept_pack(): final clean-up

Now is_kept_pack() is just a member lookup into a structure, we can write it as such. Also rewrite the sole caller of has_sha1_kept_pack() to switch on the criteria the callee uses (namely, revs->kept_pack_only) between calling has_sha1_kept_pack() and has_sha1_pack(), so that these two callees do not have to take a pointer to struct rev_info as an argument. This removes the header file dependency issue temporarily introduced by the earlier commit, so we revert changes associated to that as well. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Feb 28, 2009 at 00:37 UTC 69e020ae00ebd3f7ae3c2f35acb139361417ef64
5 files changed +13 -21
builtin-pack-objects.c
+2 -2
@@ -1915,7 +1915,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)
1915 const unsigned char *sha1;
1916 struct object *o;
1917
1918 - if (is_kept_pack(p))
1918 + if (p->pack_keep)
1919 continue;
1920 if (open_pack_index(p))
1921 die("cannot open pack index");
@@ -1951,7 +1951,7 @@ static void loosen_unused_packed_objects(struct rev_info *revs)
1951 const unsigned char *sha1;
1952
1953 for (p = packed_git; p; p = p->next) {
1954 - if (is_kept_pack(p))
1954 + if (p->pack_keep)
1955 continue;
1956
1957 if (open_pack_index(p))
cache.h
+1
@@ -566,6 +566,7 @@ extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned l
566 extern int move_temp_to_file(const char *tmpfile, const char *filename);
567
568 extern int has_sha1_pack(const unsigned char *sha1);
569 +extern int has_sha1_kept_pack(const unsigned char *sha1);
570 extern int has_sha1_file(const unsigned char *sha1);
571 extern int has_loose_object_nonlocal(const unsigned char *sha1);
572
revision.c
+3 -1
@@ -1476,7 +1476,9 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
1476 if (commit->object.flags & SHOWN)
1477 return commit_ignore;
1478 if (revs->unpacked &&
1479 - has_sha1_kept_pack(commit->object.sha1, revs))
1479 + (revs->kept_pack_only
1480 + ? has_sha1_kept_pack(commit->object.sha1)
1481 + : has_sha1_pack(commit->object.sha1)))
1482 return commit_ignore;
1483 if (revs->show_all)
1484 return commit_show;
revision.h
-3
@@ -156,7 +156,4 @@ enum commit_action {
156
157 extern enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit);
158
159 -extern int has_sha1_kept_pack(const unsigned char *sha1, const struct rev_info *);
160 -extern int is_kept_pack(const struct packed_git *);
161 -
159 #endif
sha1_file.c
+7 -15
@@ -16,8 +16,6 @@
16 #include "refs.h"
17 #include "pack-revindex.h"
18 #include "sha1-lookup.h"
19 -#include "diff.h"
20 -#include "revision.h"
19
20 #ifndef O_NOATIME
21 #if defined(__linux__) && (defined(__i386__) || defined(__PPC__))
@@ -1858,13 +1856,8 @@ off_t find_pack_entry_one(const unsigned char *sha1,
1856 return 0;
1857 }
1858
1861 -int is_kept_pack(const struct packed_git *p)
1862 -{
1863 - return p->pack_keep;
1864 -}
1865 -
1859 static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
1867 - const struct rev_info *revs)
1860 + int kept_pack_only)
1861 {
1862 static struct packed_git *last_found = (void *)1;
1863 struct packed_git *p;
@@ -1876,7 +1869,7 @@ static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
1869 p = (last_found == (void *)1) ? packed_git : last_found;
1870
1871 do {
1879 - if (revs->kept_pack_only && !is_kept_pack(p))
1872 + if (kept_pack_only && !p->pack_keep)
1873 goto next;
1874 if (p->num_bad_objects) {
1875 unsigned i;
@@ -1919,13 +1912,12 @@ static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
1912
1913 static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
1914 {
1922 - return find_pack_ent(sha1, e, NULL);
1915 + return find_pack_ent(sha1, e, 0);
1916 }
1917
1925 -static int find_kept_pack_entry(const unsigned char *sha1, struct pack_entry *e,
1926 - const struct rev_info *revs)
1918 +static int find_kept_pack_entry(const unsigned char *sha1, struct pack_entry *e)
1919 {
1928 - return find_pack_ent(sha1, e, revs);
1920 + return find_pack_ent(sha1, e, 1);
1921 }
1922
1923 struct packed_git *find_sha1_pack(const unsigned char *sha1,
@@ -2395,10 +2387,10 @@ int has_sha1_pack(const unsigned char *sha1)
2387 return find_pack_entry(sha1, &e);
2388 }
2389
2398 -int has_sha1_kept_pack(const unsigned char *sha1, const struct rev_info *revs)
2390 +int has_sha1_kept_pack(const unsigned char *sha1)
2391 {
2392 struct pack_entry e;
2401 - return find_kept_pack_entry(sha1, &e, revs);
2393 + return find_kept_pack_entry(sha1, &e);
2394 }
2395
2396 int has_sha1_file(const unsigned char *sha1)