@matheusbsbs / matheus-bagliano / commits / 3a4b3f269c
Fork 0

Create/delete branch ref logs.

When crating a new branch offer '-l' as a way for the user to quickly enable ref logging for the new branch. When deleting a branch also delete its ref log. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Shawn Pearce committed May 19, 2006 at 05:16 UTC 3a4b3f269c4ba1eebd5ab7206ee0915667b20cc8
2 files changed +19 -3
Documentation/git-branch.txt
+8 -2
@@ -9,7 +9,7 @@ SYNOPSIS
9 --------
10 [verse]
11 'git-branch' [-r]
12 -'git-branch' [-f] <branchname> [<start-point>]
12 +'git-branch' [-l] [-f] <branchname> [<start-point>]
13 'git-branch' (-d | -D) <branchname>...
14
15 DESCRIPTION
@@ -23,7 +23,8 @@ If no <start-point> is given, the branch will be created with a head
23 equal to that of the currently checked out branch.
24
25 With a `-d` or `-D` option, `<branchname>` will be deleted. You may
26 -specify more than one branch for deletion.
26 +specify more than one branch for deletion. If the branch currently
27 +has a ref log then the ref log will also be deleted.
28
29
30 OPTIONS
@@ -34,6 +35,11 @@ OPTIONS
35 -D::
36 Delete a branch irrespective of its index status.
37
38 +-l::
39 + Create the branch's ref log. This activates recording of
40 + all changes to made the branch ref, enabling use of date
41 + based sha1 expressions such as "<branchname>@{yesterday}".
42 +
43 -f::
44 Force the creation of a new branch even if it means deleting
45 a branch that already exists with the same name.
git-branch.sh
+11 -1
@@ -1,6 +1,6 @@
1 #!/bin/sh
2
3 -USAGE='[(-d | -D) <branchname>] | [[-f] <branchname> [<start-point>]] | -r'
3 +USAGE='[-l] [(-d | -D) <branchname>] | [[-f] <branchname> [<start-point>]] | -r'
4 LONG_USAGE='If no arguments, show available branches and mark current branch with a star.
5 If one argument, create a new branch <branchname> based off of current HEAD.
6 If two arguments, create a new branch <branchname> based off of <start-point>.'
@@ -42,6 +42,7 @@ If you are sure you want to delete it, run 'git branch -D $branch_name'."
42 esac
43 ;;
44 esac
45 + rm -f "$GIT_DIR/logs/refs/heads/$branch_name"
46 rm -f "$GIT_DIR/refs/heads/$branch_name"
47 echo "Deleted branch $branch_name."
48 done
@@ -55,6 +56,7 @@ ls_remote_branches () {
56 }
57
58 force=
59 +create_log=
60 while case "$#,$1" in 0,*) break ;; *,-*) ;; *) break ;; esac
61 do
62 case "$1" in
@@ -69,6 +71,9 @@ do
71 -f)
72 force="$1"
73 ;;
74 + -l)
75 + create_log="yes"
76 + ;;
77 --)
78 shift
79 break
@@ -117,4 +122,9 @@ then
122 die "cannot force-update the current branch."
123 fi
124 fi
125 +if test "$create_log" = 'yes'
126 +then
127 + mkdir -p $(dirname "$GIT_DIR/logs/refs/heads/$branchname")
128 + touch "$GIT_DIR/logs/refs/heads/$branchname"
129 +fi
130 git update-ref -m "branch: Created from $head" "refs/heads/$branchname" $rev