{"thread":{"id":"5680","subject":"[PATCH] branch: write branch properties","startedAt":"2006-09-24T22:42:02Z","lastAt":"2006-09-29T22:47:46Z","messageCount":4,"participants":["Santi Béjar","Santi"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"27592","messageId":"87r6y06g5h.fsf@gmail.com","threadId":"5680","inReplyTo":null,"subject":"[PATCH] branch: write branch properties","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2006-09-24T22:42:02Z","receivedAt":"2006-09-24T22:42:02Z","isPatch":true,"sender":{"key":"santi@agolina.net","avatar":null},"body":"\nIf you want to work in the 'next' branch of git.git:\n\n$ git clone --use-separate-remote git://git.kernel.org/pub/scm/git/git.git\n$ cd git\n$ git branch next origin next\n\nSigned-off-by: Santi Béjar <sbejar@gmail.com>\n---\n Documentation/git-branch.txt |    7 +++++--\n git-branch.sh                |   17 +++++++++++++++--\n git-parse-remote.sh          |   21 +++++++++++++++++++++\n 3 files changed, 41 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\nindex d43ef1d..de2889d 100644\n--- a/Documentation/git-branch.txt\n+++ b/Documentation/git-branch.txt\n@@ -9,7 +9,7 @@ SYNOPSIS\n --------\n [verse]\n 'git-branch' [-r]\n-'git-branch' [-l] [-f] <branchname> [<start-point>]\n+'git-branch' [-l] [-f] <branchname> [<start-point> | <remote> <remotebranch>]\n 'git-branch' (-d | -D) <branchname>...\n \n DESCRIPTION\n@@ -18,9 +18,12 @@ With no arguments given (or just `-r`) a\n will be shown, the current branch will be highlighted with an asterisk.\n \n In its second form, a new branch named <branchname> will be created.\n-It will start out with a head equal to the one given as <start-point>.\n+It will start out with a head equal to the one given as <start-point>,\n+or from branch <remotebranch> of the repository <remote>.\n If no <start-point> is given, the branch will be created with a head\n equal to that of the currently checked out branch.\n+In the form <remote> <remotebranch> it will also record the branch\n+properties `branch.<branchname>.remote` and `branch.<branchname>.merge`.\n \n With a `-d` or `-D` option, `<branchname>` will be deleted.  You may\n specify more than one branch for deletion.  If the branch currently\ndiff --git a/git-branch.sh b/git-branch.sh\nindex e0501ec..94dd157 100755\n--- a/git-branch.sh\n+++ b/git-branch.sh\n@@ -1,9 +1,10 @@\n #!/bin/sh\n \n-USAGE='[-l] [(-d | -D) <branchname>] | [[-f] <branchname> [<start-point>]] | -r'\n+USAGE='[-l] [(-d | -D) <branchname>] | [[-f] <branchname> [<start-point> | <remote> <remotebranch>]] | -r'\n LONG_USAGE='If no arguments, show available branches and mark current branch with a star.\n If one argument, create a new branch <branchname> based off of current HEAD.\n-If two arguments, create a new branch <branchname> based off of <start-point>.'\n+If two arguments, create a new branch <branchname> based off of <start-point>.\n+If three arguments, create a new branch <branchname> based off the branch <remotebranch> of the repository <remote>, writing the branch properties for fetch.'\n \n SUBDIRECTORY_OK='Yes'\n . git-sh-setup\n@@ -104,6 +105,12 @@ case \"$#\" in\n \thead=HEAD ;;\n 2)\n \thead=\"$2^0\" ;;\n+3)\n+\tremote=\"$2\"\n+\tremote_branch=\"$3\"\n+\t. ./git-parse-remote.sh\n+\tref=$(get_ref_for_remote_branch \"$2\" \"$3\")\n+\thead=\"$ref^0\";;\n esac\n branchname=\"$1\"\n \n@@ -128,3 +135,9 @@ then\n \ttouch \"$GIT_DIR/logs/refs/heads/$branchname\"\n fi\n git update-ref -m \"branch: Created from $head\" \"refs/heads/$branchname\" $rev\n+\n+if test -n \"$ref\"\n+then\n+\tgit repo-config branch.\"$branchname\".remote \"$remote\"\n+\tgit repo-config branch.\"$branchname\".merge \"$remote_branch\"\n+fi\ndiff --git a/git-parse-remote.sh b/git-parse-remote.sh\nindex 187f088..51f3b9b 100755\n--- a/git-parse-remote.sh\n+++ b/git-parse-remote.sh\n@@ -209,3 +209,24 @@ resolve_alternates () {\n \t\tesac\n \tdone\n }\n+\n+get_ref_for_remote_branch (){\n+\tdata_source=$(get_data_source \"$1\")\n+\tcase \"$data_source\" in\n+\t'' | config-partial | branches | branches-partial)\n+\t\t;;\n+\tconfig)\n+\t\tref=$(git-repo-config --get-all \"remote.$1.fetch\" |\\\n+\t\t\tgrep \"^$2:\")\n+\t\texpr \"z$ref\" : 'z[^:]*:\\(.*\\)'\n+\t\t;;\n+\tremotes)\n+\t\tref=$(sed -ne '/^Pull: */{\n+\t\t\t\ts///p\n+\t\t\t}' \"$GIT_DIR/remotes/$1\" | grep \"$2:\")\n+\t\texpr \"z$ref\" : 'z[^:]*:\\(.*\\)'\n+\t\t;;\n+\t*)\n+\t\tdie \"internal error: get-ref-for-remote-branch $1 $2\" ;;\n+\tesac\n+}\n-- \n1.4.2.1.g279b\n"},{"id":"27595","messageId":"877izs98eu.fsf@gmail.com","threadId":"5680","inReplyTo":"87r6y06g5h.fsf@gmail.com","subject":"Re: [PATCH] branch: write branch properties","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2006-09-24T23:00:57Z","receivedAt":"2006-09-24T23:00:57Z","isPatch":true,"sender":{"key":"santi@agolina.net","avatar":null},"body":"Santi Béjar <sbejar@gmail.com> writes:\n\n> If you want to work in the 'next' branch of git.git:\n>\n> $ git clone --use-separate-remote git://git.kernel.org/pub/scm/git/git.git\n> $ cd git\n> $ git branch next origin next\n\nthis has to be: git branch next origin refs/heads/next\n\nand then you work as usual with:\n\n... work\n$ git pull\n\nand it does the right thing.\n\nPlease use this instead:\n\n-- >8 --\n[PATCH] branch: write branch properties\n\nIf you want to work in the 'next' branch of git.git:\n\n$ git clone --use-separate-remote git://git.kernel.org/pub/scm/git/git.git\n$ cd git\n$ git branch next origin refs/heads/next\n... work/edit/commit ...\n$ git pull\n\nand it merges from branch 'refs/heads/next' of origin.\n\nSigned-off-by: Santi Béjar <sbejar@gmail.com>\n---\n Documentation/git-branch.txt |    7 +++++--\n git-branch.sh                |   17 +++++++++++++++--\n git-parse-remote.sh          |   21 +++++++++++++++++++++\n 3 files changed, 41 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\nindex d43ef1d..de2889d 100644\n--- a/Documentation/git-branch.txt\n+++ b/Documentation/git-branch.txt\n@@ -9,7 +9,7 @@ SYNOPSIS\n --------\n [verse]\n 'git-branch' [-r]\n-'git-branch' [-l] [-f] <branchname> [<start-point>]\n+'git-branch' [-l] [-f] <branchname> [<start-point> | <remote> <remotebranch>]\n 'git-branch' (-d | -D) <branchname>...\n \n DESCRIPTION\n@@ -18,9 +18,12 @@ With no arguments given (or just `-r`) a\n will be shown, the current branch will be highlighted with an asterisk.\n \n In its second form, a new branch named <branchname> will be created.\n-It will start out with a head equal to the one given as <start-point>.\n+It will start out with a head equal to the one given as <start-point>,\n+or from branch <remotebranch> of the repository <remote>.\n If no <start-point> is given, the branch will be created with a head\n equal to that of the currently checked out branch.\n+In the form <remote> <remotebranch> it will also record the branch\n+properties `branch.<branchname>.remote` and `branch.<branchname>.merge`.\n \n With a `-d` or `-D` option, `<branchname>` will be deleted.  You may\n specify more than one branch for deletion.  If the branch currently\ndiff --git a/git-branch.sh b/git-branch.sh\nindex e0501ec..94dd157 100755\n--- a/git-branch.sh\n+++ b/git-branch.sh\n@@ -1,9 +1,10 @@\n #!/bin/sh\n \n-USAGE='[-l] [(-d | -D) <branchname>] | [[-f] <branchname> [<start-point>]] | -r'\n+USAGE='[-l] [(-d | -D) <branchname>] | [[-f] <branchname> [<start-point> | <remote> <remotebranch>]] | -r'\n LONG_USAGE='If no arguments, show available branches and mark current branch with a star.\n If one argument, create a new branch <branchname> based off of current HEAD.\n-If two arguments, create a new branch <branchname> based off of <start-point>.'\n+If two arguments, create a new branch <branchname> based off of <start-point>.\n+If three arguments, create a new branch <branchname> based off the branch <remotebranch> of the repository <remote>, writing the branch properties for fetch.'\n \n SUBDIRECTORY_OK='Yes'\n . git-sh-setup\n@@ -104,6 +105,12 @@ case \"$#\" in\n \thead=HEAD ;;\n 2)\n \thead=\"$2^0\" ;;\n+3)\n+\tremote=\"$2\"\n+\tremote_branch=\"$3\"\n+\t. ./git-parse-remote.sh\n+\tref=$(get_ref_for_remote_branch \"$2\" \"$3\")\n+\thead=\"$ref^0\";;\n esac\n branchname=\"$1\"\n \n@@ -128,3 +135,9 @@ then\n \ttouch \"$GIT_DIR/logs/refs/heads/$branchname\"\n fi\n git update-ref -m \"branch: Created from $head\" \"refs/heads/$branchname\" $rev\n+\n+if test -n \"$ref\"\n+then\n+\tgit repo-config branch.\"$branchname\".remote \"$remote\"\n+\tgit repo-config branch.\"$branchname\".merge \"$remote_branch\"\n+fi\ndiff --git a/git-parse-remote.sh b/git-parse-remote.sh\nindex 187f088..51f3b9b 100755\n--- a/git-parse-remote.sh\n+++ b/git-parse-remote.sh\n@@ -209,3 +209,24 @@ resolve_alternates () {\n \t\tesac\n \tdone\n }\n+\n+get_ref_for_remote_branch (){\n+\tdata_source=$(get_data_source \"$1\")\n+\tcase \"$data_source\" in\n+\t'' | config-partial | branches | branches-partial)\n+\t\t;;\n+\tconfig)\n+\t\tref=$(git-repo-config --get-all \"remote.$1.fetch\" |\\\n+\t\t\tgrep \"^$2:\")\n+\t\texpr \"z$ref\" : 'z[^:]*:\\(.*\\)'\n+\t\t;;\n+\tremotes)\n+\t\tref=$(sed -ne '/^Pull: */{\n+\t\t\t\ts///p\n+\t\t\t}' \"$GIT_DIR/remotes/$1\" | grep \"$2:\")\n+\t\texpr \"z$ref\" : 'z[^:]*:\\(.*\\)'\n+\t\t;;\n+\t*)\n+\t\tdie \"internal error: get-ref-for-remote-branch $1 $2\" ;;\n+\tesac\n+}\n-- \n1.4.2.1.g279b\n"},{"id":"27604","messageId":"87d59kok0l.fsf@gmail.com","threadId":"5680","inReplyTo":"877izs98eu.fsf@gmail.com","subject":"Re: [PATCH] branch: write branch properties","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2006-09-25T00:41:14Z","receivedAt":"2006-09-25T00:41:14Z","isPatch":true,"sender":{"key":"santi@agolina.net","avatar":null},"body":"Hi *,\n\n>\n> Please use this instead:\n>\n\nor even this, sorry:\n\n* . ./git-parse-remotes.sh?\n* not a bug, but test for $remote and $remote_branch instead of $ref.\n\n-- >8 --\n[PATCH] branch: write branch properties\n\nIf you want to work in the 'next' branch of git.git:\n\n$ git clone --use-separate-remote git://git.kernel.org/pub/scm/git/git.git\n$ cd git\n$ git branch next origin refs/heads/next\n... work/edit/commit ...\n$ git pull\n\nand it merges from branch 'refs/heads/next' of origin.\n\nSigned-off-by: Santi Béjar <sbejar@gmail.com>\n---\n Documentation/git-branch.txt |    7 +++++--\n git-branch.sh                |   17 +++++++++++++++--\n git-parse-remote.sh          |   21 +++++++++++++++++++++\n 3 files changed, 41 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\nindex d43ef1d..de2889d 100644\n--- a/Documentation/git-branch.txt\n+++ b/Documentation/git-branch.txt\n@@ -9,7 +9,7 @@ SYNOPSIS\n --------\n [verse]\n 'git-branch' [-r]\n-'git-branch' [-l] [-f] <branchname> [<start-point>]\n+'git-branch' [-l] [-f] <branchname> [<start-point> | <remote> <remotebranch>]\n 'git-branch' (-d | -D) <branchname>...\n \n DESCRIPTION\n@@ -18,9 +18,12 @@ With no arguments given (or just `-r`) a\n will be shown, the current branch will be highlighted with an asterisk.\n \n In its second form, a new branch named <branchname> will be created.\n-It will start out with a head equal to the one given as <start-point>.\n+It will start out with a head equal to the one given as <start-point>,\n+or from branch <remotebranch> of the repository <remote>.\n If no <start-point> is given, the branch will be created with a head\n equal to that of the currently checked out branch.\n+In the form <remote> <remotebranch> it will also record the branch\n+properties `branch.<branchname>.remote` and `branch.<branchname>.merge`.\n \n With a `-d` or `-D` option, `<branchname>` will be deleted.  You may\n specify more than one branch for deletion.  If the branch currently\ndiff --git a/git-branch.sh b/git-branch.sh\nindex e0501ec..78e2c92 100755\n--- a/git-branch.sh\n+++ b/git-branch.sh\n@@ -1,9 +1,10 @@\n #!/bin/sh\n \n-USAGE='[-l] [(-d | -D) <branchname>] | [[-f] <branchname> [<start-point>]] | -r'\n+USAGE='[-l] [(-d | -D) <branchname>] | [[-f] <branchname> [<start-point> | <remote> <remotebranch>]] | -r'\n LONG_USAGE='If no arguments, show available branches and mark current branch with a star.\n If one argument, create a new branch <branchname> based off of current HEAD.\n-If two arguments, create a new branch <branchname> based off of <start-point>.'\n+If two arguments, create a new branch <branchname> based off of <start-point>.\n+If three arguments, create a new branch <branchname> based off the branch <remotebranch> of the repository <remote>, writing the branch properties for fetch.'\n \n SUBDIRECTORY_OK='Yes'\n . git-sh-setup\n@@ -104,6 +105,12 @@ case \"$#\" in\n \thead=HEAD ;;\n 2)\n \thead=\"$2^0\" ;;\n+3)\n+\tremote=\"$2\"\n+\tremote_branch=\"$3\"\n+\t. git-parse-remote\n+\tref=$(get_ref_for_remote_branch \"$2\" \"$3\")\n+\thead=\"$ref^0\";;\n esac\n branchname=\"$1\"\n \n@@ -128,3 +135,9 @@ then\n \ttouch \"$GIT_DIR/logs/refs/heads/$branchname\"\n fi\n git update-ref -m \"branch: Created from $head\" \"refs/heads/$branchname\" $rev\n+\n+if test -n \"$remote\" && test -n \"$remote_branch\"\n+then\n+\tgit repo-config branch.\"$branchname\".remote \"$remote\"\n+\tgit repo-config branch.\"$branchname\".merge \"$remote_branch\"\n+fi\ndiff --git a/git-parse-remote.sh b/git-parse-remote.sh\nindex 187f088..51f3b9b 100755\n--- a/git-parse-remote.sh\n+++ b/git-parse-remote.sh\n@@ -209,3 +209,24 @@ resolve_alternates () {\n \t\tesac\n \tdone\n }\n+\n+get_ref_for_remote_branch (){\n+\tdata_source=$(get_data_source \"$1\")\n+\tcase \"$data_source\" in\n+\t'' | config-partial | branches | branches-partial)\n+\t\t;;\n+\tconfig)\n+\t\tref=$(git-repo-config --get-all \"remote.$1.fetch\" |\\\n+\t\t\tgrep \"^$2:\")\n+\t\texpr \"z$ref\" : 'z[^:]*:\\(.*\\)'\n+\t\t;;\n+\tremotes)\n+\t\tref=$(sed -ne '/^Pull: */{\n+\t\t\t\ts///p\n+\t\t\t}' \"$GIT_DIR/remotes/$1\" | grep \"$2:\")\n+\t\texpr \"z$ref\" : 'z[^:]*:\\(.*\\)'\n+\t\t;;\n+\t*)\n+\t\tdie \"internal error: get-ref-for-remote-branch $1 $2\" ;;\n+\tesac\n+}\n-- \n1.4.2.1.gf2ca-dirty\n"},{"id":"28019","messageId":"8aa486160609291547y583b01fdvd6ba6b0e031d19b@mail.gmail.com","threadId":"5680","inReplyTo":"87d59kok0l.fsf@gmail.com","subject":"Re: [PATCH] branch: write branch properties","fromName":"Santi","fromEmail":"sbejar@gmail.com","sentAt":"2006-09-29T22:47:46Z","receivedAt":"2006-09-29T22:47:46Z","isPatch":true,"sender":{"key":"santi@agolina.net","avatar":null},"body":"> [PATCH] branch: write branch properties\n>\n> If you want to work in the 'next' branch of git.git:\n>\n> $ git clone --use-separate-remote git://git.kernel.org/pub/scm/git/git.git\n> $ cd git\n> $ git branch next origin refs/heads/next\n> ... work/edit/commit ...\n> $ git pull\n>\n> and it merges from branch 'refs/heads/next' of origin.\n>\n\nAny comments on this?\n\nPossible comments :D\n- No comments\n- Not interested\n- Not interesting\n- I like the idea but not the patch because...\n- I like the patch but not the idea (?)\n- Broken syntax. Could be done in this other way...\n- Stop all this crazy things, just config all this manually!\n- Start more crazy things, like...\n- ...\n\n  Santi\n"}]}