@matheusbsbs / matheus-bagliano / commits / b8431b033f
Fork 0

has_sha1_kept_pack(): take "struct rev_info"

Its "ignore_packed" parameter always comes from struct rev_info. This patch makes the function take a pointer to the surrounding structure, so that the refactoring in the next patch becomes easier to review. There is an unfortunate header file dependency and the easiest workaround is to temporarily move the function declaration from cache.h to revision.h; this will be moved back to cache.h once the function loses this "ignore_packed" parameter altogether in the later part of the series. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Feb 27, 2009 at 23:30 UTC b8431b033f9e60f87a75b864612873307a3e5966
4 files changed +12 -9
cache.h
-1
@@ -566,7 +566,6 @@ 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, const char **ignore);
569 extern int has_sha1_file(const unsigned char *sha1);
570 extern int has_loose_object_nonlocal(const unsigned char *sha1);
571
revision.c
+1 -1
@@ -1486,7 +1486,7 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
1486 if (commit->object.flags & SHOWN)
1487 return commit_ignore;
1488 if (revs->unpacked &&
1489 - has_sha1_kept_pack(commit->object.sha1, revs->ignore_packed))
1489 + has_sha1_kept_pack(commit->object.sha1, revs))
1490 return commit_ignore;
1491 if (revs->show_all)
1492 return commit_show;
revision.h
+2
@@ -158,4 +158,6 @@ enum commit_action {
158
159 extern enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit);
160
161 +extern int has_sha1_kept_pack(const unsigned char *sha1, const struct rev_info *);
162 +
163 #endif
sha1_file.c
+9 -7
@@ -16,6 +16,8 @@
16 #include "refs.h"
17 #include "pack-revindex.h"
18 #include "sha1-lookup.h"
19 +#include "diff.h"
20 +#include "revision.h"
21
22 #ifndef O_NOATIME
23 #if defined(__linux__) && (defined(__i386__) || defined(__PPC__))
@@ -1875,7 +1877,7 @@ int matches_pack_name(struct packed_git *p, const char *name)
1877 }
1878
1879 static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
1878 - const char **ignore_packed)
1880 + const struct rev_info *revs)
1881 {
1882 static struct packed_git *last_found = (void *)1;
1883 struct packed_git *p;
@@ -1887,9 +1889,9 @@ static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
1889 p = (last_found == (void *)1) ? packed_git : last_found;
1890
1891 do {
1890 - if (ignore_packed) {
1892 + if (revs->ignore_packed) {
1893 const char **ig;
1892 - for (ig = ignore_packed; *ig; ig++)
1894 + for (ig = revs->ignore_packed; *ig; ig++)
1895 if (matches_pack_name(p, *ig))
1896 break;
1897 if (*ig)
@@ -1941,9 +1943,9 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
1943 }
1944
1945 static int find_kept_pack_entry(const unsigned char *sha1, struct pack_entry *e,
1944 - const char **ignore_packed)
1946 + const struct rev_info *revs)
1947 {
1946 - return find_pack_ent(sha1, e, ignore_packed);
1948 + return find_pack_ent(sha1, e, revs);
1949 }
1950
1951 struct packed_git *find_sha1_pack(const unsigned char *sha1,
@@ -2413,10 +2415,10 @@ int has_sha1_pack(const unsigned char *sha1)
2415 return find_pack_entry(sha1, &e);
2416 }
2417
2416 -int has_sha1_kept_pack(const unsigned char *sha1, const char **ignore_packed)
2418 +int has_sha1_kept_pack(const unsigned char *sha1, const struct rev_info *revs)
2419 {
2420 struct pack_entry e;
2419 - return find_kept_pack_entry(sha1, &e, ignore_packed);
2421 + return find_kept_pack_entry(sha1, &e, revs);
2422 }
2423
2424 int has_sha1_file(const unsigned char *sha1)