mirror of
https://github.com/git/git.git
synced 2026-01-10 10:13:33 +00:00
shallow: add repository argument to register_shallow
Add a repository argument to allow callers of register_shallow to be more specific about which repository to handle. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet. As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
6a2df51c84
commit
19143f139d
@@ -2875,7 +2875,7 @@ static void get_object_list(int ac, const char **av)
|
|||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
if (get_oid_hex(line + 10, &oid))
|
if (get_oid_hex(line + 10, &oid))
|
||||||
die("not an SHA-1 '%s'", line + 10);
|
die("not an SHA-1 '%s'", line + 10);
|
||||||
register_shallow(&oid);
|
register_shallow(the_repository, &oid);
|
||||||
use_bitmap_index = 0;
|
use_bitmap_index = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -906,7 +906,7 @@ static int update_shallow_ref(struct command *cmd, struct shallow_info *si)
|
|||||||
* not lose these new roots..
|
* not lose these new roots..
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < extra.nr; i++)
|
for (i = 0; i < extra.nr; i++)
|
||||||
register_shallow(&extra.oid[i]);
|
register_shallow(the_repository, &extra.oid[i]);
|
||||||
|
|
||||||
si->shallow_ref[cmd->index] = 0;
|
si->shallow_ref[cmd->index] = 0;
|
||||||
oid_array_clear(&extra);
|
oid_array_clear(&extra);
|
||||||
|
|||||||
3
commit.h
3
commit.h
@@ -191,7 +191,8 @@ extern struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n,
|
|||||||
|
|
||||||
struct oid_array;
|
struct oid_array;
|
||||||
struct ref;
|
struct ref;
|
||||||
extern int register_shallow(const struct object_id *oid);
|
#define register_shallow(r, o) register_shallow_##r(o);
|
||||||
|
extern int register_shallow_the_repository(const struct object_id *oid);
|
||||||
extern int unregister_shallow(const struct object_id *oid);
|
extern int unregister_shallow(const struct object_id *oid);
|
||||||
extern int for_each_commit_graft(each_commit_graft_fn, void *);
|
extern int for_each_commit_graft(each_commit_graft_fn, void *);
|
||||||
extern int is_repository_shallow(void);
|
extern int is_repository_shallow(void);
|
||||||
|
|||||||
@@ -428,7 +428,7 @@ static int find_common(struct fetch_pack_args *args,
|
|||||||
if (skip_prefix(line, "shallow ", &arg)) {
|
if (skip_prefix(line, "shallow ", &arg)) {
|
||||||
if (get_oid_hex(arg, &oid))
|
if (get_oid_hex(arg, &oid))
|
||||||
die(_("invalid shallow line: %s"), line);
|
die(_("invalid shallow line: %s"), line);
|
||||||
register_shallow(&oid);
|
register_shallow(the_repository, &oid);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (skip_prefix(line, "unshallow ", &arg)) {
|
if (skip_prefix(line, "unshallow ", &arg)) {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ void set_alternate_shallow_file_the_repository(const char *path, int override)
|
|||||||
alternate_shallow_file = xstrdup_or_null(path);
|
alternate_shallow_file = xstrdup_or_null(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
int register_shallow(const struct object_id *oid)
|
int register_shallow_the_repository(const struct object_id *oid)
|
||||||
{
|
{
|
||||||
struct commit_graft *graft =
|
struct commit_graft *graft =
|
||||||
xmalloc(sizeof(struct commit_graft));
|
xmalloc(sizeof(struct commit_graft));
|
||||||
@@ -70,7 +70,7 @@ int is_repository_shallow(void)
|
|||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
if (get_oid_hex(buf, &oid))
|
if (get_oid_hex(buf, &oid))
|
||||||
die("bad shallow line: %s", buf);
|
die("bad shallow line: %s", buf);
|
||||||
register_shallow(&oid);
|
register_shallow(the_repository, &oid);
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return is_shallow;
|
return is_shallow;
|
||||||
|
|||||||
@@ -663,7 +663,7 @@ static void send_shallow(struct commit_list *result)
|
|||||||
if (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {
|
if (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {
|
||||||
packet_write_fmt(1, "shallow %s",
|
packet_write_fmt(1, "shallow %s",
|
||||||
oid_to_hex(&object->oid));
|
oid_to_hex(&object->oid));
|
||||||
register_shallow(&object->oid);
|
register_shallow(the_repository, &object->oid);
|
||||||
shallow_nr++;
|
shallow_nr++;
|
||||||
}
|
}
|
||||||
result = result->next;
|
result = result->next;
|
||||||
@@ -700,7 +700,7 @@ static void send_unshallow(const struct object_array *shallows)
|
|||||||
add_object_array(object, NULL, &extra_edge_obj);
|
add_object_array(object, NULL, &extra_edge_obj);
|
||||||
}
|
}
|
||||||
/* make sure commit traversal conforms to client */
|
/* make sure commit traversal conforms to client */
|
||||||
register_shallow(&object->oid);
|
register_shallow(the_repository, &object->oid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -912,7 +912,8 @@ static void receive_needs(void)
|
|||||||
if (shallows.nr > 0) {
|
if (shallows.nr > 0) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < shallows.nr; i++)
|
for (i = 0; i < shallows.nr; i++)
|
||||||
register_shallow(&shallows.objects[i].item->oid);
|
register_shallow(the_repository,
|
||||||
|
&shallows.objects[i].item->oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
shallow_nr += shallows.nr;
|
shallow_nr += shallows.nr;
|
||||||
|
|||||||
Reference in New Issue
Block a user