git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Cogito: Support for implicit remote branches in cloned repositories
@ 2005-11-04 16:01 Josef Weidendorfer
  2005-11-04 17:43 ` Junio C Hamano
  0 siblings, 1 reply; 10+ messages in thread
From: Josef Weidendorfer @ 2005-11-04 16:01 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git

This allows to specify remote branch names from the
repository this one was cloned from (= remote repository of
"origin" branch), without explicitly adding a branch for them.
Therefore, these remote branches are called implicit.

Use them together with cg-fetch or cg-update.
Example: Your current repository was cloned with

  cg-clone git+ssh://remotehost:/path myrep

If this remote repository contains a branch "foo",
you can say inside of myrep:

  cg-fetch foo

This fetches "git+ssh://remotehost:/path#foo" into
a local branch "foo" (created if not existing).
Similarily, a "cg-update foo" will fetch the remote
branch and merge it into your current local branch.

After fetching from an implicit remote branch, cg-status
will show the corresponding local branch, but still without
an "R", because that is only shown for explicit branches.
The implicit remote branch in the example above can be
made explicit with

  cg-branch-add foo git+ssh://remotehost:/path#foo

Note that cg-update now always tries to fetch from a
remote repository, as every non-explicit branch
name is supposed to be an implicit remote branch.

Signed-off-by: Josef Weidendorfer <Josef.Weidendorfer@gmx.de>

---

This patch is RFC. IMHO, it simplifies the usage of Cogito
quite a lot. One difference of cloning with GIT vs. with
Cogito is that Git always clones all remote branches. This can
be limiting if you want to work with multiple repositories,
but allows you to immediatly work with all the branches.

Cogito instead clones only one remote branch, and requires
you to explicitly add further branches with "cg-branch-add".
This is not necessary with implicit remote branches, and
they should cover the standard use case which works with
branches from the repository you clone from.

The nice thing here is that the patch is really small for
the added functionality. If you accept it, I will provide
updates for the documentation and tutorial.

Josef

 cg-fetch  |   10 +++++++++-
 cg-update |    6 +-----
 2 files changed, 10 insertions(+), 6 deletions(-)

applies-to: 22948869bcf0ec216ed9aa14e1c5ecc22114d66b
769aa2148fc2b583b071354e8eef3dae74e09c14
diff --git a/cg-fetch b/cg-fetch
index 759488a..5a5aeb1 100755
--- a/cg-fetch
+++ b/cg-fetch
@@ -262,7 +262,15 @@ name=${ARGS[0]}
 
 [ "$name" ] || { [ -s "$_git/branches/origin" ] && name=origin; }
 [ "$name" ] || die "where to fetch from?"
-uri=$(cat "$_git/branches/$name" 2>/dev/null) || die "unknown branch: $name"
+uri=$(cat "$_git/branches/$name" 2>/dev/null) || \
+    { if [ -s "$_git/branches/origin" ]; then
+	uri=$(cat "$_git/branches/origin" 2>/dev/null)
+	uri="$(echo "$uri" | cut -d '#' -f 1)#$name"
+	echo Fetching implicit remote branch "$uri".
+      else
+        die "unknown branch: $name"
+      fi
+    }
 
 rembranch=
 if echo "$uri" | grep -q '#'; then
diff --git a/cg-update b/cg-update
index 96035c5..534bf4a 100755
--- a/cg-update
+++ b/cg-update
@@ -39,11 +39,7 @@ name=${ARGS[0]}
 [ "$name" ] || { [ -s $_git/branches/origin ] && name=origin; }
 [ "$name" ] || die "where to update from?"
 
-if [ -s "$_git/branches/$name" ]; then
-	cg-fetch $force $name || exit 1
-else
-	echo "Updating from a local branch."
-fi
+cg-fetch $force $name || exit 1
 echo
 echo "Applying changes..."
 cg-merge $name

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-11-08 16:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-04 16:01 [PATCH] Cogito: Support for implicit remote branches in cloned repositories Josef Weidendorfer
2005-11-04 17:43 ` Junio C Hamano
2005-11-04 18:38   ` Josef Weidendorfer
2005-11-04 21:08   ` Petr Baudis
2005-11-04 21:50     ` Junio C Hamano
2005-11-04 22:07       ` Linus Torvalds
2005-11-06  9:11         ` Junio C Hamano
2005-11-07 23:21           ` Petr Baudis
2005-11-07 23:45             ` Junio C Hamano
2005-11-08 16:46             ` Josef Weidendorfer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).