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

git-branch --contains: doc and test

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Nov 18, 2007 at 22:22 UTC 3f7dfe77b71ff0ae78923518ab5ca28b0cf4d786
2 files changed +62
Documentation/git-branch.txt
+4
@@ -10,6 +10,7 @@ SYNOPSIS
10 [verse]
11 'git-branch' [--color | --no-color] [-r | -a]
12 [-v [--abbrev=<length> | --no-abbrev]]
13 + [--contains <commit>]
14 'git-branch' [--track | --no-track] [-l] [-f] <branchname> [<start-point>]
15 'git-branch' (-m | -M) [<oldbranch>] <newbranch>
16 'git-branch' (-d | -D) [-r] <branchname>...
@@ -20,6 +21,9 @@ With no arguments given a list of existing branches
21 will be shown, the current branch will be highlighted with an asterisk.
22 Option `-r` causes the remote-tracking branches to be listed,
23 and option `-a` shows both.
24 +With `--contains <commit>`, shows only the branches that
25 +contains the named commit (in other words, the branches whose
26 +tip commits are descendant of the named commit).
27
28 In its second form, a new branch named <branchname> will be created.
29 It will start out with a head equal to the one given as <start-point>.
t/t3201-branch-contains.sh new
+58
@@ -0,0 +1,58 @@
1 +#!/bin/sh
2 +
3 +test_description='branch --contains <commit>'
4 +
5 +. ./test-lib.sh
6 +
7 +test_expect_success setup '
8 +
9 + >file &&
10 + git add file &&
11 + test_tick &&
12 + git commit -m initial &&
13 + git branch side &&
14 +
15 + echo 1 >file &&
16 + test_tick &&
17 + git commit -a -m "second on master" &&
18 +
19 + git checkout side &&
20 + echo 1 >file &&
21 + test_tick &&
22 + git commit -a -m "second on side" &&
23 +
24 + git merge master
25 +
26 +'
27 +
28 +test_expect_success 'branch --contains=master' '
29 +
30 + git branch --contains=master >actual &&
31 + {
32 + echo " master" && echo "* side"
33 + } >expect &&
34 + diff -u expect actual
35 +
36 +'
37 +
38 +test_expect_success 'branch --contains master' '
39 +
40 + git branch --contains master >actual &&
41 + {
42 + echo " master" && echo "* side"
43 + } >expect &&
44 + diff -u expect actual
45 +
46 +'
47 +
48 +test_expect_success 'branch --contains=side' '
49 +
50 + git branch --contains=side >actual &&
51 + {
52 + echo "* side"
53 + } >expect &&
54 + diff -u expect actual
55 +
56 +'
57 +
58 +test_done