static int reload_refs(bool force) { const char *ls_remote_argv[SIZEOF_ARG] = { "git", "ls-remote", repo.git_dir, NULL }; static bool init = FALSE; struct ref_opt opt = { repo.remote, repo.head, WATCH_NONE }; struct repo_info old_repo = repo; size_t i; if (!init) { if (!argv_from_env(ls_remote_argv, "TIG_LS_REMOTE")) return ERR; init = TRUE; } if (!*repo.git_dir) return OK; if (force || !*repo.head) load_repo_head(); if (strcmp(old_repo.head, repo.head)) opt.changed |= WATCH_HEAD; refs_head = NULL; for (i = 0; i < refs_size; i++) refs[i]->valid = 0; done_ref_lists(); if (io_run_load(ls_remote_argv, "\t", read_ref, &opt) == ERR) return ERR; for (i = 0; i < refs_size; i++) if (!refs[i]->valid) { refs[i]->id[0] = 0; opt.changed |= WATCH_REFS; } if (opt.changed) watch_apply(NULL, opt.changed); qsort(refs, refs_size, sizeof(*refs), compare_refs); return OK; }
static enum status_code reload_refs(bool force) { const char *ls_remote_argv[SIZEOF_ARG] = { "git", "show-ref", "--head", "--dereference", NULL }; static bool init = false; struct ref_opt opt = { repo.remote, repo.head, WATCH_NONE }; struct repo_info old_repo = repo; enum status_code code; if (!init) { if (!argv_from_env(ls_remote_argv, "TIG_LS_REMOTE")) return ERROR_OUT_OF_MEMORY; init = true; } if (!*repo.git_dir) return SUCCESS; if (force || !*repo.head) load_repo_head(); if (strcmp(old_repo.head, repo.head)) opt.changed |= WATCH_HEAD; refs_head = NULL; refs_tags = 0; string_map_clear(&refs_by_id); string_map_foreach(&refs_by_name, invalidate_refs, NULL); code = io_run_load(ls_remote_argv, " ", read_ref, &opt); if (code != SUCCESS) return code; string_map_foreach(&refs_by_name, cleanup_refs, &opt); if (opt.changed) watch_apply(NULL, opt.changed); return SUCCESS; }