summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4ccafd7)
raw | patch | inline | side by side (parent: 4ccafd7)
author | Junio C Hamano <junkio@cox.net> | |
Wed, 2 Nov 2005 20:17:47 +0000 (12:17 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Thu, 3 Nov 2005 00:50:58 +0000 (16:50 -0800) |
"git-checkout -b frotz/nitfol master" failed to create
$GIT_DIR/refs/heads/frotz/nitfol but went ahead and updated
$GIT_DIR/HEAD to point at it, resulting in a corrupt repository.
Exit when we cannot create the new branch with an error status.
While we are at it, there is no reason to forbid subdirectories
in refs/heads, so make sure we handle that correctly.
Signed-off-by: Junio C Hamano <junkio@cox.net>
$GIT_DIR/refs/heads/frotz/nitfol but went ahead and updated
$GIT_DIR/HEAD to point at it, resulting in a corrupt repository.
Exit when we cannot create the new branch with an error status.
While we are at it, there is no reason to forbid subdirectories
in refs/heads, so make sure we handle that correctly.
Signed-off-by: Junio C Hamano <junkio@cox.net>
git-branch.sh | patch | blob | history | |
git-checkout.sh | patch | blob | history |
diff --git a/git-branch.sh b/git-branch.sh
index e2db9063d4c63288c5834046962290ff9dfca127..67f113acb9abc2bbcd444de42326854bdd88ba4a 100755 (executable)
--- a/git-branch.sh
+++ b/git-branch.sh
git-check-ref-format "heads/$branchname" ||
die "we do not like '$branchname' as a branch name."
+leading=`expr "refs/heads/$branchname" : '\(.*\)/'` &&
+mkdir -p "$GIT_DIR/$leading" &&
echo $rev > "$GIT_DIR/refs/heads/$branchname"
diff --git a/git-checkout.sh b/git-checkout.sh
index cb33fdc7e20272a77d97d1b68c31d9b93d3cf4d4..4c08f36b591508b5d940384db603e2f4483116d6 100755 (executable)
--- a/git-checkout.sh
+++ b/git-checkout.sh
#
if [ "$?" -eq 0 ]; then
if [ "$newbranch" ]; then
- echo $new > "$GIT_DIR/refs/heads/$newbranch"
+ leading=`expr "refs/heads/$newbranch" : '\(.*\)/'` &&
+ mkdir -p "$GIT_DIR/$leading" &&
+ echo $new >"$GIT_DIR/refs/heads/$newbranch" || exit
branch="$newbranch"
fi
[ "$branch" ] &&