From: "Santi Béjar" <sbejar@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Subject: [PATCHv2] git-branch: Set branch properties
Date: Tue, 17 Oct 2006 16:47:07 +0200 [thread overview]
Message-ID: <87y7rf80es.fsf@gmail.com> (raw)
Added a flag to git-branch (-c) that makes git-branch to write the
config (branch properties) for the new branch so it will pull the same
branch it branched from.
If you want to work in the 'next' branch of git.git:
$ git clone git://git.kernel.org/pub/scm/git/git.git
$ cd git
$ git branch -c mynext origin next
$ tail -n 3 .git/config
[branch "mynext"]
remote = origin
merge = refs/heads/next
$ git branch -c secondnext next
$ tail -n 3 .git/config
[branch "secondnext"]
remote = .
merge = next
Signed-off-by: Santi Béjar <sbejar@gmail.com>
---
Hi,
it needs the get_ref_for_remote_branch function in
git-parse-remote.sh that is with the patch:
[RFC/PATCH] git-fetch: Use already fetched branch with the --local
flag
Also, this does not apply cleanly in next, the change in next is and
the resolution trivial:
< rm -f "$GIT_DIR/logs/refs/heads/$branch_name"
< rm -f "$GIT_DIR/refs/heads/$branch_name"
> git update-ref -d "refs/heads/$branch_name" "$branch"
What I have to do? Send the postimage or what?
Another questions is about rerere: Can it be done at the hunk level? We
could record the git-patch-id of the conflict and the postimage.
Documentation/git-branch.txt | 12 ++++++++++--
git-branch.sh | 30 +++++++++++++++++++++++++++---
2 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index d43ef1d..77bbf81 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] [-c] <branchname> [<start-point> | <remote> <remotebranch>]
'git-branch' (-d | -D) <branchname>...
DESCRIPTION
@@ -18,7 +18,8 @@ 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.
@@ -26,9 +27,16 @@ With a `-d` or `-D` option, `<branchname
specify more than one branch for deletion. If the branch currently
has a ref log then the ref log will also be deleted.
+With a `-c` option, the branch properties `branch.<branchname>.remote`
+and `branch.<branchname>.merge` will be set.
+
OPTIONS
-------
+-c::
+ Write the branch properties `branch.<branchname>.remote`
+ and `branch.<branchname>.merge`.
+
-d::
Delete a branch. The branch must be fully merged.
diff --git a/git-branch.sh b/git-branch.sh
index 4f31903..afd768a 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] [-c] <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>.'
SUBDIRECTORY_OK='Yes'
. git-sh-setup
@@ -44,6 +45,8 @@ If you are sure you want to delete it, r
esac
rm -f "$GIT_DIR/logs/refs/heads/$branch_name"
rm -f "$GIT_DIR/refs/heads/$branch_name"
+ git repo-config --unset branch."$branchname".remote
+ git repo-config --unset-all branch."$branchname".merge
echo "Deleted branch $branch_name."
done
exit 0
@@ -71,6 +74,9 @@ do
-f)
force="$1"
;;
+ -c)
+ config="yes"
+ ;;
-l)
create_log="yes"
;;
@@ -101,9 +107,21 @@ case "$#" in
done
exit 0 ;;
1)
+ remote="."
+ remote_branch="$headref"
head=HEAD ;;
2)
+ remote="."
+ remote_branch="$2"
head="$2^0" ;;
+3)
+ remote="$2"
+ remote_branch="$3"
+ . git-parse-remote
+ ref=$(get_ref_for_remote_branch "$remote" "$remote_branch")
+ [ -z "$ref" ] && remote_branch="refs/heads/$remote_branch" && \
+ ref=$(get_ref_for_remote_branch "$remote" "$remote_branch")
+ head="$ref^0";;
esac
branchname="$1"
@@ -137,4 +155,10 @@ then
mkdir -p $(dirname "$GIT_DIR/logs/refs/heads/$branchname")
touch "$GIT_DIR/logs/refs/heads/$branchname"
fi
-git update-ref -m "branch: Created from $head" "refs/heads/$branchname" $rev
+git update-ref -m "branch: Created from $head" "refs/heads/$branchname" $rev || exit $?
+
+if test "$config" = "yes"
+then
+ git repo-config branch."$branchname".remote "$remote"
+ git repo-config branch."$branchname".merge "$remote_branch"
+fi
--
1.4.2.4.g687a-dirty
reply other threads:[~2006-10-17 14:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=87y7rf80es.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.