1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-12-23 19:18:58 +02:00

eeshow/: implement related_same_repo

This commit is contained in:
Werner Almesberger 2016-08-02 19:21:43 -03:00
parent a21bc66e55
commit 3c13d609f7

View File

@ -133,7 +133,6 @@ static char *canonical_path_into_repo(const char *repo_dir, const char *path)
if (slash && slash != tmp && !slash[1]) if (slash && slash != tmp && !slash[1])
*slash = 0; *slash = 0;
/* /*
* If path does point to inexistent object, separate into the part that * If path does point to inexistent object, separate into the part that
* is valid on the current system and the tail containing dead things. * is valid on the current system and the tail containing dead things.
@ -345,11 +344,28 @@ static bool send_line(const char *s, unsigned len,
} }
static void access_file_data(struct vcs_git *vcs_git, const char *name)
{
git_tree_entry *entry;
entry = find_file(vcs_git->repo, vcs_git->tree, name);
if (verbose)
fprintf(stderr, "reading %s\n", name);
vcs_git->data = get_data(vcs_git->repo, entry, &vcs_git->size);
}
static bool related_same_repo(struct vcs_git *vcs_git) static bool related_same_repo(struct vcs_git *vcs_git)
{ {
/* @@@ use same revision */ const struct vcs_git *related = vcs_git->related;
fprintf(stderr, "related_same_repo is no yet implemented\n");
return 0; vcs_git->repo = related->repo;
vcs_git->tree = related->tree;
access_file_data(vcs_git, vcs_git->name);
return 1;
} }
@ -365,7 +381,6 @@ static bool related_only_repo(struct vcs_git *vcs_git)
{ {
const struct vcs_git *related = vcs_git->related; const struct vcs_git *related = vcs_git->related;
char *tmp; char *tmp;
git_tree_entry *entry;
if (verbose > 1) if (verbose > 1)
fprintf(stderr, "trying graft \"%s\" \"%s\"\n", fprintf(stderr, "trying graft \"%s\" \"%s\"\n",
@ -377,13 +392,7 @@ static bool related_only_repo(struct vcs_git *vcs_git)
vcs_git->repo = related->repo; vcs_git->repo = related->repo;
vcs_git->tree = related->tree; vcs_git->tree = related->tree;
/* @@@ code below also exists in vcs_git_open */ access_file_data(vcs_git, tmp);
entry = find_file(vcs_git->repo, vcs_git->tree, tmp);
if (verbose)
fprintf(stderr, "reading %s\n", tmp);
vcs_git->data = get_data(vcs_git->repo, entry, &vcs_git->size);
free((char *) vcs_git->name); free((char *) vcs_git->name);
vcs_git->name = tmp; vcs_git->name = tmp;
@ -417,7 +426,6 @@ struct vcs_git *vcs_git_open(const char *revision, const char *name,
{ {
static bool initialized = 0; static bool initialized = 0;
struct vcs_git *vcs_git = alloc_type(struct vcs_git); struct vcs_git *vcs_git = alloc_type(struct vcs_git);
git_tree_entry *entry;
if (!initialized) { if (!initialized) {
git_libgit2_init(); git_libgit2_init();
@ -443,11 +451,8 @@ struct vcs_git *vcs_git_open(const char *revision, const char *name,
if (!revision) if (!revision)
revision = "HEAD"; revision = "HEAD";
vcs_git->tree = pick_revision(vcs_git->repo, revision); vcs_git->tree = pick_revision(vcs_git->repo, revision);
entry = find_file(vcs_git->repo, vcs_git->tree, name);
if (verbose)
fprintf(stderr, "reading %s:%s\n", revision, name);
vcs_git->data = get_data(vcs_git->repo, entry, &vcs_git->size); access_file_data(vcs_git, name);
return vcs_git; return vcs_git;
} }