Allow remote branch names when reading a git object tree

This is the quick hack to read from a remote branch, which allows you to
look at other peoples branches when sharing a git tree.

Note that the "remote" part of "remote branch" is the _git_ meaning of a
remote branch: it is the local cached copy from a remote.  This does not
imply any kind of network traffic - but if you have done a "git fetch"
to get branches from some other source, you can now use the remote
branch-name to see them in subsurface.

Also notice that you should *NOT* save the end result.  It will "work",
but it won't do what you think it does.  Saving does not update the
remote branch, it would create a new *local* branch with that same
branch-name, and since it's a new branch, it would do so with no
parenthood information. So you'll be very very confused.

I think I'll add code to remember the parent when loading from a git
repository, and then use that remembered information when saving.  So
then you could create a real local branch with real history.  But that's
an independent issue from this loading case.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2014-03-12 21:04:12 -07:00 committed by Dirk Hohndel
parent 7a999a875e
commit 13e2210d75

View file

@ -1205,8 +1205,11 @@ static int do_git_load(git_repository *repo, const char *branch)
git_object *tree;
ret = git_branch_lookup(&ref, repo, branch, GIT_BRANCH_LOCAL);
if (ret) {
ret = git_branch_lookup(&ref, repo, branch, GIT_BRANCH_REMOTE);
if (ret)
return report_error("Unable to look up branch '%s'", branch);
}
if (git_reference_peel(&tree, ref, GIT_OBJ_TREE))
return report_error("Could not look up tree of branch '%s'", branch);
ret = load_dives_from_tree(repo, (git_tree *) tree);