From: "Santi Béjar" <sbejar@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Subject: [COGITO PATCH]Re: Origin handling
Date: Thu, 02 Jun 2005 12:18:26 +0200 [thread overview]
Message-ID: <87ll5trril.fsf@gmail.com> (raw)
In-Reply-To: <877jhdthhr.fsf@gmail.com> ( Santi Béjar's message of "Thu, 02 Jun 2005 08:12:00 +0200")
I propose that the origin of a branch comes from a file in
.git/branches/ of the same name. So the origin of default branch
master is the content of the file .git/branches/master that in
the current practice would be "origin". But we could have the
remote branch "git", being the origin of the local branch
"git_dirs" (the content of .git/branches/git_dirs = "git").
The origin branch is reserved. When you cg-clone the origin is now
called cloned (but "commit-id cloned" = "commit-id origin" while you do
not switch to another branch whith other origin). The transition from
old handling is not in the patch.
So now you can:
cg-clone -s rsync://rsync.kernel.org/pub/scm/git/git.git/
and work in this in your "master" branch with origin "cloned".
You can add another repository:
cg-branch-add pb http://pasky.or.cz/~pasky/dev/git/git-pb.git
cg-pull pb
and if you want to do some modifications based on pb:
cg-branch-add pb-sb pb
ln -s refs/heads/pb-sb .git/HEAD
commit-id pb > .git/HEAD
git-read-tree HEAD
git-checkout-cache -f -q -u -a
and work on your branch.
The last four lines are the work of the hipothetical cg-branch-switch.
Signed-off-by: "Santi Béjar" <sbejar@gmail.com>
---
cg-Xnormid | 6 ++++++
cg-branch-add | 2 +-
cg-clone | 2 +-
cg-commit | 7 ++++++-
cg-init | 9 +++++----
cg-merge | 7 ++++++-
cg-pull | 7 ++++++-
7 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/cg-Xnormid b/cg-Xnormid
--- a/cg-Xnormid
+++ b/cg-Xnormid
@@ -6,6 +6,7 @@
#
# Strings resolve in this order:
# NULL, this, HEAD => .git/HEAD
+# origin => origin of the branch
# <tags>
# <heads>
# short SHA1 (4 or more hex digits)
@@ -19,6 +20,11 @@ id="$1"
if [ ! "$id" ] || [ "$id" = "this" ] || [ "$id" = "HEAD" ]; then
read id < "$_git/HEAD"
+elif [ "$id" = "origin" ]; then
+ branch=$(readlink $_git/HEAD | sed 's@refs/heads/@@')
+ origin=$(cat $_git/branches/$branch)
+ read id < "$_git/refs/heads/$origin"
+
elif [ -r "$_git/refs/tags/$id" ]; then
read id < "$_git/refs/tags/$id"
diff --git a/cg-branch-add b/cg-branch-add
--- a/cg-branch-add
+++ b/cg-branch-add
@@ -40,7 +40,7 @@ location=$2
([ "$name" ] && [ "$location" ]) || usage
(echo $name | egrep -qv '[^a-zA-Z0-9_.@!:-]') || \
die "name contains invalid characters"
-if [ "$name" = "this" ] || [ "$name" = "HEAD" ]; then
+if [ "$name" = "this" ] || [ "$name" = "HEAD" ] || [ "$name" = "origin" ]; then
die "given branch name is reserved"
fi
diff --git a/cg-clone b/cg-clone
--- a/cg-clone
+++ b/cg-clone
@@ -56,4 +56,4 @@ fi
trap "rm -rf $dir" SIGTERM EXIT
cg-init $location || exit $?
trap "" SIGTERM EXIT
-echo "Cloned to $dir/ (origin $location available as branch \"origin\")"
+echo "Cloned to $dir/ (origin $location available as branch \"cloned\")"
diff --git a/cg-commit b/cg-commit
--- a/cg-commit
+++ b/cg-commit
@@ -141,7 +141,12 @@ if [ "$merging" ]; then
[ "$msgs" ] && echo -n 'Merge with '
[ -s $_git/merging-sym ] || cp $_git/merging $_git/merging-sym
for sym in $(cat $_git/merging-sym); do
- uri=$(cat $_git/branches/$sym)
+ if [ $sym = origin ] ; then
+ branch=$(readlink $_git/HEAD | sed 's@refs/heads/@@')
+ uri=$(cat $_git/branches/$branch)
+ else
+ uri=$(cat $_git/branches/$sym)
+ fi
[ "$uri" ] || uri="$sym"
echo "$uri" >>$LOGMSG
[ "$msgs" ] && echo "$uri"
diff --git a/cg-init b/cg-init
--- a/cg-init
+++ b/cg-init
@@ -26,15 +26,16 @@ mkdir $_git/branches
touch $_git/refs/heads/master
if [ "$uri" ]; then
- echo "$uri" >$_git/branches/origin
- cg-pull origin || die "pull failed"
+ echo "$uri" >$_git/branches/cloned
+ echo cloned >$_git/branches/master
+ cg-pull cloned || die "pull failed"
- cp $_git/refs/heads/origin $_git/refs/heads/master
+ cp $_git/refs/heads/cloned $_git/refs/heads/master
git-read-tree HEAD
git-checkout-cache -a
git-update-cache --refresh
- echo "Cloned (origin $uri available as branch \"origin\")"
+ echo "Cloned (cloned $uri available as branch \"cloned\")"
else
git-read-tree # Seed the dircache
find * \( -type f -o -type l \) -print0 | xargs -0r cg-add
diff --git a/cg-pull b/cg-pull
--- a/cg-pull
+++ b/cg-pull
@@ -14,10 +14,15 @@ USAGE="cg-pull [BRANCH_NAME]"
name=$1
-[ "$name" ] || { [ -s $_git/refs/heads/origin ] && name=origin; }
+if [ -z "$name" ]; then
+ branch=$(readlink $_git/HEAD | sed 's@refs/heads/@@')
+ name=$(cat $_git/branches/$branch 2>/dev/null)
+fi
[ "$name" ] || die "where to pull from?"
uri=$(cat "$_git/branches/$name" 2>/dev/null) || die "unknown branch: $name"
+[ -e "$_git/branches/$uri" ] && die "local branches cannot pull"
+
rembranch=master
if echo "$uri" | grep -q '#'; then
rembranch=$(echo $uri | cut -d '#' -f 2)
prev parent reply other threads:[~2005-06-02 10:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-02 6:12 Origin handling Santi Béjar
2005-06-02 10:18 ` Santi Béjar [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ll5trril.fsf@gmail.com \
--to=sbejar@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.