summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7acab8f)
raw | patch | inline | side by side (parent: 7acab8f)
author | Alex Riesen <raa.lkml@gmail.com> | |
Mon, 14 Nov 2005 22:10:59 +0000 (23:10 +0100) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Tue, 15 Nov 2005 01:15:32 +0000 (17:15 -0800) |
Make git-update-ref create references with slashes in them. git-branch
and git-checkout already support such reference names.
git-branch can use git-update-ref to create the references in a more
formal manner now.
Signed-off-by: Junio C Hamano <junkio@cox.net>
and git-checkout already support such reference names.
git-branch can use git-update-ref to create the references in a more
formal manner now.
Signed-off-by: Junio C Hamano <junkio@cox.net>
git-branch.sh | patch | blob | history | |
t/t3200-branch.sh | patch | blob | history | |
update-ref.c | patch | blob | history |
diff --git a/git-branch.sh b/git-branch.sh
index 67f113acb9abc2bbcd444de42326854bdd88ba4a..11d52fd78ed11887006ba23470083e2560439c0c 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"
+git update-ref "refs/heads/$branchname" $rev
+
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 5f98f64de16560d9f6599623e7424efac9dc407f..36f7749bed8a40f50f218bbd6c4dcf7763c5abee 100755 (executable)
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
'git branch --help should not have created a bogus branch' \
'test -f .git/refs/heads/--help'
+test_expect_success \
+ 'git branch abc should create a branch' \
+ 'git-branch abc && test -f .git/refs/heads/abc'
+
+test_expect_success \
+ 'git branch a/b/c should create a branch' \
+ 'git-branch a/b/c && test -f .git/refs/heads/a/b/c'
+
test_done
diff --git a/update-ref.c b/update-ref.c
index d79dc52fd7d1eb1117e37c6b400c5f99bc8e4fcd..e6fbddbab6939023c4bbea9e0b685904dc6ba0b0 100644 (file)
--- a/update-ref.c
+++ b/update-ref.c
int main(int argc, char **argv)
{
char *hex;
- const char *refname, *value, *oldval, *path, *lockpath;
+ const char *refname, *value, *oldval, *path;
+ char *lockpath;
unsigned char sha1[20], oldsha1[20], currsha1[20];
int fd, written;
}
path = strdup(path);
lockpath = mkpath("%s.lock", path);
+ if (safe_create_leading_directories(lockpath) < 0)
+ die("Unable to create all of %s", lockpath);
fd = open(lockpath, O_CREAT | O_EXCL | O_WRONLY, 0666);
if (fd < 0)