{"thread":{"id":"804","subject":"Origin handling","startedAt":"2005-06-02T06:12:00Z","lastAt":"2005-06-02T10:18:26Z","messageCount":2,"participants":["Santi Béjar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"4398","messageId":"877jhdthhr.fsf@gmail.com","threadId":"804","inReplyTo":null,"subject":"Origin handling","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2005-06-02T06:12:00Z","receivedAt":"2005-06-02T06:12:00Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"\nI propose that the origin of a branch comes from a file in\n.git/branches/ of the same name. So the origin of default branch\nmaster is the content of the file .git/branches/master that in\nthe current practice would be \"origin\". But we could have the\nremote branch \"git\", being the origin of the local branch\n\"git_dirs\" (the content of .git/branches/git_dirs = \"git\").\n\nWhat do you think?\n\n     Santi\n\n"},{"id":"4407","messageId":"87ll5trril.fsf@gmail.com","threadId":"804","inReplyTo":"877jhdthhr.fsf@gmail.com","subject":"[COGITO PATCH]Re: Origin handling","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2005-06-02T10:18:26Z","receivedAt":"2005-06-02T10:18:26Z","isPatch":true,"sender":{"key":"santi@agolina.net","avatar":null},"body":"\nI propose that the origin of a branch comes from a file in\n.git/branches/ of the same name. So the origin of default branch\nmaster is the content of the file .git/branches/master that in\nthe current practice would be \"origin\". But we could have the\nremote branch \"git\", being the origin of the local branch\n\"git_dirs\" (the content of .git/branches/git_dirs = \"git\").\n\nThe origin branch is reserved. When you cg-clone the origin is now\ncalled cloned (but \"commit-id cloned\" = \"commit-id origin\" while you do\nnot switch to another branch whith other origin). The transition from\nold handling is not in the patch.\n\nSo now you can:\n\ncg-clone -s rsync://rsync.kernel.org/pub/scm/git/git.git/\n\nand work in this in your \"master\" branch with origin \"cloned\".\n\nYou can add another repository:\n\ncg-branch-add pb http://pasky.or.cz/~pasky/dev/git/git-pb.git\ncg-pull pb\n\nand if you want to do some modifications based on pb:\n\ncg-branch-add pb-sb pb\nln -s refs/heads/pb-sb .git/HEAD\ncommit-id pb > .git/HEAD\ngit-read-tree HEAD\ngit-checkout-cache -f -q -u -a\n\nand work on your branch.\n\nThe last four lines are the work of the hipothetical cg-branch-switch.\n\n\n\nSigned-off-by: \"Santi Béjar\" <sbejar@gmail.com>\n\n---\n\n cg-Xnormid    |    6 ++++++\n cg-branch-add |    2 +-\n cg-clone      |    2 +-\n cg-commit     |    7 ++++++-\n cg-init       |    9 +++++----\n cg-merge      |    7 ++++++-\n cg-pull       |    7 ++++++-\n 7 files changed, 31 insertions(+), 9 deletions(-)\n\ndiff --git a/cg-Xnormid b/cg-Xnormid\n--- a/cg-Xnormid\n+++ b/cg-Xnormid\n@@ -6,6 +6,7 @@\n #\n # Strings resolve in this order:\n # \tNULL, this, HEAD  => .git/HEAD\n+# \torigin => origin of the branch\n # \t<tags>\n # \t<heads>\n # \tshort SHA1 (4 or more hex digits)\n@@ -19,6 +20,11 @@ id=\"$1\"\n if [ ! \"$id\" ] || [ \"$id\" = \"this\" ] || [ \"$id\" = \"HEAD\" ]; then\n \tread id < \"$_git/HEAD\"\n \n+elif [ \"$id\" = \"origin\" ]; then\n+\tbranch=$(readlink $_git/HEAD | sed 's@refs/heads/@@')\n+\torigin=$(cat $_git/branches/$branch)\n+\tread id < \"$_git/refs/heads/$origin\"\n+\n elif [ -r \"$_git/refs/tags/$id\" ]; then\n \tread id < \"$_git/refs/tags/$id\"\n \ndiff --git a/cg-branch-add b/cg-branch-add\n--- a/cg-branch-add\n+++ b/cg-branch-add\n@@ -40,7 +40,7 @@ location=$2\n ([ \"$name\" ] && [ \"$location\" ]) || usage\n (echo $name | egrep -qv '[^a-zA-Z0-9_.@!:-]') || \\\n \tdie \"name contains invalid characters\"\n-if [ \"$name\" = \"this\" ] || [ \"$name\" = \"HEAD\" ]; then\n+if [ \"$name\" = \"this\" ] || [ \"$name\" = \"HEAD\" ] || [ \"$name\" = \"origin\" ]; then\n \tdie \"given branch name is reserved\"\n fi\n \ndiff --git a/cg-clone b/cg-clone\n--- a/cg-clone\n+++ b/cg-clone\n@@ -56,4 +56,4 @@ fi\n trap \"rm -rf $dir\" SIGTERM EXIT\n cg-init $location || exit $?\n trap \"\" SIGTERM EXIT\n-echo \"Cloned to $dir/ (origin $location available as branch \\\"origin\\\")\"\n+echo \"Cloned to $dir/ (origin $location available as branch \\\"cloned\\\")\"\ndiff --git a/cg-commit b/cg-commit\n--- a/cg-commit\n+++ b/cg-commit\n@@ -141,7 +141,12 @@ if [ \"$merging\" ]; then\n \t[ \"$msgs\" ] && echo -n 'Merge with '\n \t[ -s $_git/merging-sym ] || cp $_git/merging $_git/merging-sym\n \tfor sym in $(cat $_git/merging-sym); do\n-\t\turi=$(cat $_git/branches/$sym)\n+\t\tif [ $sym = origin ] ; then\n+\t\t\tbranch=$(readlink $_git/HEAD | sed 's@refs/heads/@@')\n+\t\t\turi=$(cat $_git/branches/$branch)\n+\t\telse\n+\t\t\turi=$(cat $_git/branches/$sym)\n+\t\tfi\n \t\t[ \"$uri\" ] || uri=\"$sym\"\n \t\techo \"$uri\" >>$LOGMSG\n \t\t[ \"$msgs\" ] && echo \"$uri\"\ndiff --git a/cg-init b/cg-init\n--- a/cg-init\n+++ b/cg-init\n@@ -26,15 +26,16 @@ mkdir $_git/branches\n touch $_git/refs/heads/master\n \n if [ \"$uri\" ]; then\n-\techo \"$uri\" >$_git/branches/origin\n-\tcg-pull origin || die \"pull failed\"\n+\techo \"$uri\" >$_git/branches/cloned\n+\techo cloned >$_git/branches/master\n+\tcg-pull cloned || die \"pull failed\"\n \n-\tcp $_git/refs/heads/origin $_git/refs/heads/master\n+\tcp $_git/refs/heads/cloned $_git/refs/heads/master\n \tgit-read-tree HEAD\n \tgit-checkout-cache -a\n \tgit-update-cache --refresh\n \n-\techo \"Cloned (origin $uri available as branch \\\"origin\\\")\"\n+\techo \"Cloned (cloned $uri available as branch \\\"cloned\\\")\"\n else\n \tgit-read-tree # Seed the dircache\n \tfind * \\( -type f -o -type l \\) -print0 | xargs -0r cg-add\ndiff --git a/cg-pull b/cg-pull\n--- a/cg-pull\n+++ b/cg-pull\n@@ -14,10 +14,15 @@ USAGE=\"cg-pull [BRANCH_NAME]\"\n name=$1\n \n \n-[ \"$name\" ] || { [ -s $_git/refs/heads/origin ] && name=origin; }\n+if [ -z \"$name\" ]; then\n+\tbranch=$(readlink $_git/HEAD | sed 's@refs/heads/@@')\n+\tname=$(cat $_git/branches/$branch 2>/dev/null)\n+fi\n [ \"$name\" ] || die \"where to pull from?\"\n uri=$(cat \"$_git/branches/$name\" 2>/dev/null) || die \"unknown branch: $name\"\n \n+[ -e \"$_git/branches/$uri\" ] && die \"local branches cannot pull\"\n+\n rembranch=master\n if echo \"$uri\" | grep -q '#'; then\n \trembranch=$(echo $uri | cut -d '#' -f 2)\n\n"}]}