[PATCH] Allow remote branch names when reading a git object tree
Linus Torvalds
torvalds at linux-foundation.org
Wed Mar 12 21:12:32 PDT 2014
From: Linus Torvalds <torvalds at linux-foundation.org>
Date: Wed, 12 Mar 2014 21:04:12 -0700
Subject: [PATCH] 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 kin dof 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 at linux-foundation.org>
---
Ok, as the commit message says, I'll need to improve on the git history
saving part in order for us to do clever things, but this is useful on its
own.
load-git.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/load-git.c b/load-git.c
index 5d55245dbed5..c268cf1ef093 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);
--
1.9.0
More information about the subsurface
mailing list