summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e0aaa29)
raw | patch | inline | side by side (parent: e0aaa29)
author | Daniel Barkalow <barkalow@iabervon.org> | |
Sun, 27 Apr 2008 17:39:24 +0000 (13:39 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 5 May 2008 00:41:44 +0000 (17:41 -0700) |
These refs can be anything, but they are most likely useful as
pointing to objects that you know are in the object database but don't
have any regular refs for. For example, when cloning with --reference,
the refs in this repository should be listed as objects that we have,
even though we don't have refs in our newly-created repository for
them yet.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pointing to objects that you know are in the object database but don't
have any regular refs for. For example, when cloning with --reference,
the refs in this repository should be listed as objects that we have,
even though we don't have refs in our newly-created repository for
them yet.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c | patch | blob | history | |
refs.h | patch | blob | history |
index 4db73ed8f01200fca4008bafb23bda36a8e23446..8300cc1b54cd0e46ebad1f0c5ea407010e0386a0 100644 (file)
--- a/refs.c
+++ b/refs.c
} cached_refs;
static struct ref_list *current_ref;
+static struct ref_list *extra_refs;
+
static void free_ref_list(struct ref_list *list)
{
struct ref_list *next;
cached_refs->packed = sort_ref_list(list);
}
+void add_extra_ref(const char *name, const unsigned char *sha1, int flag)
+{
+ extra_refs = add_ref(name, sha1, flag, extra_refs, NULL);
+}
+
+void clear_extra_refs(void)
+{
+ free_ref_list(extra_refs);
+ extra_refs = NULL;
+}
+
static struct ref_list *get_packed_refs(void)
{
if (!cached_refs.did_packed) {
struct ref_list *packed = get_packed_refs();
struct ref_list *loose = get_loose_refs();
+ struct ref_list *extra;
+
+ for (extra = extra_refs; extra; extra = extra->next)
+ retval = do_one_ref(base, fn, trim, cb_data, extra);
+
while (packed && loose) {
struct ref_list *entry;
int cmp = strcmp(packed->name, loose->name);
index 06abee15266cc3b234ec64cd27362c482874e54b..06ad26055661a9b9e475d0f8a7bd6d1cfb42e792 100644 (file)
--- a/refs.h
+++ b/refs.h
extern int for_each_branch_ref(each_ref_fn, void *);
extern int for_each_remote_ref(each_ref_fn, void *);
+/*
+ * Extra refs will be listed by for_each_ref() before any actual refs
+ * for the duration of this process or until clear_extra_refs() is
+ * called. Only extra refs added before for_each_ref() is called will
+ * be listed on a given call of for_each_ref().
+ */
+extern void add_extra_ref(const char *refname, const unsigned char *sha1, int flags);
+extern void clear_extra_refs(void);
+
extern int peel_ref(const char *, unsigned char *);
/** Locks a "refs/" ref returning the lock on success and NULL on failure. **/