* [PATCH] branch: write branch properties
@ 2006-09-24 22:42 Santi Béjar
2006-09-24 23:00 ` Santi Béjar
0 siblings, 1 reply; 4+ messages in thread
From: Santi Béjar @ 2006-09-24 22:42 UTC (permalink / raw)
To: git
If you want to work in the 'next' branch of git.git:
$ git clone --use-separate-remote git://git.kernel.org/pub/scm/git/git.git
$ cd git
$ git branch next origin next
Signed-off-by: Santi Béjar <sbejar@gmail.com>
---
Documentation/git-branch.txt | 7 +++++--
git-branch.sh | 17 +++++++++++++++--
git-parse-remote.sh | 21 +++++++++++++++++++++
3 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index d43ef1d..de2889d 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -9,7 +9,7 @@ SYNOPSIS
--------
[verse]
'git-branch' [-r]
-'git-branch' [-l] [-f] <branchname> [<start-point>]
+'git-branch' [-l] [-f] <branchname> [<start-point> | <remote> <remotebranch>]
'git-branch' (-d | -D) <branchname>...
DESCRIPTION
@@ -18,9 +18,12 @@ With no arguments given (or just `-r`) a
will be shown, the current branch will be highlighted with an asterisk.
In its second form, a new branch named <branchname> will be created.
-It will start out with a head equal to the one given as <start-point>.
+It will start out with a head equal to the one given as <start-point>,
+or from branch <remotebranch> of the repository <remote>.
If no <start-point> is given, the branch will be created with a head
equal to that of the currently checked out branch.
+In the form <remote> <remotebranch> it will also record the branch
+properties `branch.<branchname>.remote` and `branch.<branchname>.merge`.
With a `-d` or `-D` option, `<branchname>` will be deleted. You may
specify more than one branch for deletion. If the branch currently
diff --git a/git-branch.sh b/git-branch.sh
index e0501ec..94dd157 100755
--- a/git-branch.sh
+++ b/git-branch.sh
@@ -1,9 +1,10 @@
#!/bin/sh
-USAGE='[-l] [(-d | -D) <branchname>] | [[-f] <branchname> [<start-point>]] | -r'
+USAGE='[-l] [(-d | -D) <branchname>] | [[-f] <branchname> [<start-point> | <remote> <remotebranch>]] | -r'
LONG_USAGE='If no arguments, show available branches and mark current branch with a star.
If one argument, create a new branch <branchname> based off of current HEAD.
-If two arguments, create a new branch <branchname> based off of <start-point>.'
+If two arguments, create a new branch <branchname> based off of <start-point>.
+If three arguments, create a new branch <branchname> based off the branch <remotebranch> of the repository <remote>, writing the branch properties for fetch.'
SUBDIRECTORY_OK='Yes'
. git-sh-setup
@@ -104,6 +105,12 @@ case "$#" in
head=HEAD ;;
2)
head="$2^0" ;;
+3)
+ remote="$2"
+ remote_branch="$3"
+ . ./git-parse-remote.sh
+ ref=$(get_ref_for_remote_branch "$2" "$3")
+ head="$ref^0";;
esac
branchname="$1"
@@ -128,3 +135,9 @@ then
touch "$GIT_DIR/logs/refs/heads/$branchname"
fi
git update-ref -m "branch: Created from $head" "refs/heads/$branchname" $rev
+
+if test -n "$ref"
+then
+ git repo-config branch."$branchname".remote "$remote"
+ git repo-config branch."$branchname".merge "$remote_branch"
+fi
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 187f088..51f3b9b 100755
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -209,3 +209,24 @@ resolve_alternates () {
esac
done
}
+
+get_ref_for_remote_branch (){
+ data_source=$(get_data_source "$1")
+ case "$data_source" in
+ '' | config-partial | branches | branches-partial)
+ ;;
+ config)
+ ref=$(git-repo-config --get-all "remote.$1.fetch" |\
+ grep "^$2:")
+ expr "z$ref" : 'z[^:]*:\(.*\)'
+ ;;
+ remotes)
+ ref=$(sed -ne '/^Pull: */{
+ s///p
+ }' "$GIT_DIR/remotes/$1" | grep "$2:")
+ expr "z$ref" : 'z[^:]*:\(.*\)'
+ ;;
+ *)
+ die "internal error: get-ref-for-remote-branch $1 $2" ;;
+ esac
+}
--
1.4.2.1.g279b
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] branch: write branch properties
2006-09-24 22:42 [PATCH] branch: write branch properties Santi Béjar
@ 2006-09-24 23:00 ` Santi Béjar
2006-09-25 0:41 ` Santi Béjar
0 siblings, 1 reply; 4+ messages in thread
From: Santi Béjar @ 2006-09-24 23:00 UTC (permalink / raw)
To: git
Santi Béjar <sbejar@gmail.com> writes:
> If you want to work in the 'next' branch of git.git:
>
> $ git clone --use-separate-remote git://git.kernel.org/pub/scm/git/git.git
> $ cd git
> $ git branch next origin next
this has to be: git branch next origin refs/heads/next
and then you work as usual with:
... work
$ git pull
and it does the right thing.
Please use this instead:
-- >8 --
[PATCH] branch: write branch properties
If you want to work in the 'next' branch of git.git:
$ git clone --use-separate-remote git://git.kernel.org/pub/scm/git/git.git
$ cd git
$ git branch next origin refs/heads/next
... work/edit/commit ...
$ git pull
and it merges from branch 'refs/heads/next' of origin.
Signed-off-by: Santi Béjar <sbejar@gmail.com>
---
Documentation/git-branch.txt | 7 +++++--
git-branch.sh | 17 +++++++++++++++--
git-parse-remote.sh | 21 +++++++++++++++++++++
3 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index d43ef1d..de2889d 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -9,7 +9,7 @@ SYNOPSIS
--------
[verse]
'git-branch' [-r]
-'git-branch' [-l] [-f] <branchname> [<start-point>]
+'git-branch' [-l] [-f] <branchname> [<start-point> | <remote> <remotebranch>]
'git-branch' (-d | -D) <branchname>...
DESCRIPTION
@@ -18,9 +18,12 @@ With no arguments given (or just `-r`) a
will be shown, the current branch will be highlighted with an asterisk.
In its second form, a new branch named <branchname> will be created.
-It will start out with a head equal to the one given as <start-point>.
+It will start out with a head equal to the one given as <start-point>,
+or from branch <remotebranch> of the repository <remote>.
If no <start-point> is given, the branch will be created with a head
equal to that of the currently checked out branch.
+In the form <remote> <remotebranch> it will also record the branch
+properties `branch.<branchname>.remote` and `branch.<branchname>.merge`.
With a `-d` or `-D` option, `<branchname>` will be deleted. You may
specify more than one branch for deletion. If the branch currently
diff --git a/git-branch.sh b/git-branch.sh
index e0501ec..94dd157 100755
--- a/git-branch.sh
+++ b/git-branch.sh
@@ -1,9 +1,10 @@
#!/bin/sh
-USAGE='[-l] [(-d | -D) <branchname>] | [[-f] <branchname> [<start-point>]] | -r'
+USAGE='[-l] [(-d | -D) <branchname>] | [[-f] <branchname> [<start-point> | <remote> <remotebranch>]] | -r'
LONG_USAGE='If no arguments, show available branches and mark current branch with a star.
If one argument, create a new branch <branchname> based off of current HEAD.
-If two arguments, create a new branch <branchname> based off of <start-point>.'
+If two arguments, create a new branch <branchname> based off of <start-point>.
+If three arguments, create a new branch <branchname> based off the branch <remotebranch> of the repository <remote>, writing the branch properties for fetch.'
SUBDIRECTORY_OK='Yes'
. git-sh-setup
@@ -104,6 +105,12 @@ case "$#" in
head=HEAD ;;
2)
head="$2^0" ;;
+3)
+ remote="$2"
+ remote_branch="$3"
+ . ./git-parse-remote.sh
+ ref=$(get_ref_for_remote_branch "$2" "$3")
+ head="$ref^0";;
esac
branchname="$1"
@@ -128,3 +135,9 @@ then
touch "$GIT_DIR/logs/refs/heads/$branchname"
fi
git update-ref -m "branch: Created from $head" "refs/heads/$branchname" $rev
+
+if test -n "$ref"
+then
+ git repo-config branch."$branchname".remote "$remote"
+ git repo-config branch."$branchname".merge "$remote_branch"
+fi
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 187f088..51f3b9b 100755
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -209,3 +209,24 @@ resolve_alternates () {
esac
done
}
+
+get_ref_for_remote_branch (){
+ data_source=$(get_data_source "$1")
+ case "$data_source" in
+ '' | config-partial | branches | branches-partial)
+ ;;
+ config)
+ ref=$(git-repo-config --get-all "remote.$1.fetch" |\
+ grep "^$2:")
+ expr "z$ref" : 'z[^:]*:\(.*\)'
+ ;;
+ remotes)
+ ref=$(sed -ne '/^Pull: */{
+ s///p
+ }' "$GIT_DIR/remotes/$1" | grep "$2:")
+ expr "z$ref" : 'z[^:]*:\(.*\)'
+ ;;
+ *)
+ die "internal error: get-ref-for-remote-branch $1 $2" ;;
+ esac
+}
--
1.4.2.1.g279b
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] branch: write branch properties
2006-09-24 23:00 ` Santi Béjar
@ 2006-09-25 0:41 ` Santi Béjar
2006-09-29 22:47 ` Santi
0 siblings, 1 reply; 4+ messages in thread
From: Santi Béjar @ 2006-09-25 0:41 UTC (permalink / raw)
To: git
Hi *,
>
> Please use this instead:
>
or even this, sorry:
* . ./git-parse-remotes.sh?
* not a bug, but test for $remote and $remote_branch instead of $ref.
-- >8 --
[PATCH] branch: write branch properties
If you want to work in the 'next' branch of git.git:
$ git clone --use-separate-remote git://git.kernel.org/pub/scm/git/git.git
$ cd git
$ git branch next origin refs/heads/next
... work/edit/commit ...
$ git pull
and it merges from branch 'refs/heads/next' of origin.
Signed-off-by: Santi Béjar <sbejar@gmail.com>
---
Documentation/git-branch.txt | 7 +++++--
git-branch.sh | 17 +++++++++++++++--
git-parse-remote.sh | 21 +++++++++++++++++++++
3 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index d43ef1d..de2889d 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -9,7 +9,7 @@ SYNOPSIS
--------
[verse]
'git-branch' [-r]
-'git-branch' [-l] [-f] <branchname> [<start-point>]
+'git-branch' [-l] [-f] <branchname> [<start-point> | <remote> <remotebranch>]
'git-branch' (-d | -D) <branchname>...
DESCRIPTION
@@ -18,9 +18,12 @@ With no arguments given (or just `-r`) a
will be shown, the current branch will be highlighted with an asterisk.
In its second form, a new branch named <branchname> will be created.
-It will start out with a head equal to the one given as <start-point>.
+It will start out with a head equal to the one given as <start-point>,
+or from branch <remotebranch> of the repository <remote>.
If no <start-point> is given, the branch will be created with a head
equal to that of the currently checked out branch.
+In the form <remote> <remotebranch> it will also record the branch
+properties `branch.<branchname>.remote` and `branch.<branchname>.merge`.
With a `-d` or `-D` option, `<branchname>` will be deleted. You may
specify more than one branch for deletion. If the branch currently
diff --git a/git-branch.sh b/git-branch.sh
index e0501ec..78e2c92 100755
--- a/git-branch.sh
+++ b/git-branch.sh
@@ -1,9 +1,10 @@
#!/bin/sh
-USAGE='[-l] [(-d | -D) <branchname>] | [[-f] <branchname> [<start-point>]] | -r'
+USAGE='[-l] [(-d | -D) <branchname>] | [[-f] <branchname> [<start-point> | <remote> <remotebranch>]] | -r'
LONG_USAGE='If no arguments, show available branches and mark current branch with a star.
If one argument, create a new branch <branchname> based off of current HEAD.
-If two arguments, create a new branch <branchname> based off of <start-point>.'
+If two arguments, create a new branch <branchname> based off of <start-point>.
+If three arguments, create a new branch <branchname> based off the branch <remotebranch> of the repository <remote>, writing the branch properties for fetch.'
SUBDIRECTORY_OK='Yes'
. git-sh-setup
@@ -104,6 +105,12 @@ case "$#" in
head=HEAD ;;
2)
head="$2^0" ;;
+3)
+ remote="$2"
+ remote_branch="$3"
+ . git-parse-remote
+ ref=$(get_ref_for_remote_branch "$2" "$3")
+ head="$ref^0";;
esac
branchname="$1"
@@ -128,3 +135,9 @@ then
touch "$GIT_DIR/logs/refs/heads/$branchname"
fi
git update-ref -m "branch: Created from $head" "refs/heads/$branchname" $rev
+
+if test -n "$remote" && test -n "$remote_branch"
+then
+ git repo-config branch."$branchname".remote "$remote"
+ git repo-config branch."$branchname".merge "$remote_branch"
+fi
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 187f088..51f3b9b 100755
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -209,3 +209,24 @@ resolve_alternates () {
esac
done
}
+
+get_ref_for_remote_branch (){
+ data_source=$(get_data_source "$1")
+ case "$data_source" in
+ '' | config-partial | branches | branches-partial)
+ ;;
+ config)
+ ref=$(git-repo-config --get-all "remote.$1.fetch" |\
+ grep "^$2:")
+ expr "z$ref" : 'z[^:]*:\(.*\)'
+ ;;
+ remotes)
+ ref=$(sed -ne '/^Pull: */{
+ s///p
+ }' "$GIT_DIR/remotes/$1" | grep "$2:")
+ expr "z$ref" : 'z[^:]*:\(.*\)'
+ ;;
+ *)
+ die "internal error: get-ref-for-remote-branch $1 $2" ;;
+ esac
+}
--
1.4.2.1.gf2ca-dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] branch: write branch properties
2006-09-25 0:41 ` Santi Béjar
@ 2006-09-29 22:47 ` Santi
0 siblings, 0 replies; 4+ messages in thread
From: Santi @ 2006-09-29 22:47 UTC (permalink / raw)
To: git
> [PATCH] branch: write branch properties
>
> If you want to work in the 'next' branch of git.git:
>
> $ git clone --use-separate-remote git://git.kernel.org/pub/scm/git/git.git
> $ cd git
> $ git branch next origin refs/heads/next
> ... work/edit/commit ...
> $ git pull
>
> and it merges from branch 'refs/heads/next' of origin.
>
Any comments on this?
Possible comments :D
- No comments
- Not interested
- Not interesting
- I like the idea but not the patch because...
- I like the patch but not the idea (?)
- Broken syntax. Could be done in this other way...
- Stop all this crazy things, just config all this manually!
- Start more crazy things, like...
- ...
Santi
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-09-29 22:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-24 22:42 [PATCH] branch: write branch properties Santi Béjar
2006-09-24 23:00 ` Santi Béjar
2006-09-25 0:41 ` Santi Béjar
2006-09-29 22:47 ` Santi
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).