From 13e2210d75bb29a78fa1d08c79b5930a7fbaa3e4 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 12 Mar 2014 21:04:12 -0700 Subject: 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 Signed-off-by: Dirk Hohndel --- load-git.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/load-git.c b/load-git.c index 5d55245db..c268cf1ef 100644 --- a/load-git.c +++ b/load-git.c @@ -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) - return report_error("Unable to look up branch '%s'", branch); + 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); -- cgit v1.2.3-70-g09d2