If you use libgit.a to perform reference resolutions on two or more repositories that contain packed refs, cached_refs will store the packed refs for the first repository to contain a packed-refs file only. Subsequent calls to get_packed_refs() will return the *cached* list, even when you changed to a different repository with set_git_dir(). Thus, references will almost certainly resolve to non-existent commits. The patch explicitly invalidates the cached list when calling set_git_dir() which calls setup_git_env(). Signed-off-by: Julius Plenz <plenz@xxxxxxxxxxxxxxxx> --- cache.h | 1 + environment.c | 1 + refs.c | 2 +- 3 files changed, 3 insertions(+), 1 deletions(-) diff --git a/cache.h b/cache.h index 08a9022..95491fe 100644 --- a/cache.h +++ b/cache.h @@ -881,6 +881,7 @@ extern int check_leading_path(const char *name, int len); extern int has_dirs_only_path(const char *name, int len, int prefix_len); extern void schedule_dir_for_removal(const char *name, int len); extern void remove_scheduled_dirs(void); +extern void invalidate_cached_refs(void); extern struct alternate_object_database { struct alternate_object_database *next; diff --git a/environment.c b/environment.c index 9564475..3a7e1dc 100644 --- a/environment.c +++ b/environment.c @@ -110,6 +110,7 @@ static void setup_git_env(void) git_graft_file = git_pathdup("info/grafts"); if (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT)) read_replace_refs = 0; + invalidate_cached_refs(); } int is_bare_repository(void) diff --git a/refs.c b/refs.c index e3c0511..bbe34fb 100644 --- a/refs.c +++ b/refs.c @@ -171,7 +171,7 @@ static void free_ref_list(struct ref_list *list) } } -static void invalidate_cached_refs(void) +void invalidate_cached_refs(void) { struct cached_refs *ca = &cached_refs; -- 1.7.3.1 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html