add a test for bug fixed in a0975128
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
diff --git a/regress/cmdline/blame.sh b/regress/cmdline/blame.sh
index 1b9e7ee..33d4c77 100755
--- a/regress/cmdline/blame.sh
+++ b/regress/cmdline/blame.sh
@@ -681,6 +681,56 @@ EOF
test_done "$testroot" "$ret"
}
+function test_blame_added_on_branch {
+ local testroot=`test_init blame_added_on_branch`
+
+ got branch -r $testroot/repo -c master newbranch
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ echo 1 > $testroot/wt/new
+ (cd $testroot/wt && got add new > /dev/null)
+ (cd $testroot/wt && got commit -m "change 1" > /dev/null)
+ local commit1=`git_show_branch_head $testroot/repo newbranch`
+
+ echo 2 >> $testroot/wt/new
+ (cd $testroot/wt && got commit -m "change 2" > /dev/null)
+ local commit2=`git_show_branch_head $testroot/repo newbranch`
+
+ echo 3 >> $testroot/wt/new
+ (cd $testroot/wt && got commit -m "change 3" > /dev/null)
+ local commit3=`git_show_branch_head $testroot/repo newbranch`
+ local author_time=`git_show_author_time $testroot/repo`
+
+ (cd $testroot/wt && got blame new > $testroot/stdout)
+
+ local short_commit1=`trim_obj_id 32 $commit1`
+ local short_commit2=`trim_obj_id 32 $commit2`
+ local short_commit3=`trim_obj_id 32 $commit3`
+
+ d=`date -r $author_time +"%G-%m-%d"`
+ echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
+ echo "2) $short_commit2 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected
+ echo "3) $short_commit3 $d $GOT_AUTHOR_8 3" >> $testroot/stdout.expected
+
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ fi
+ test_done "$testroot" "$ret"
+}
+
run_test test_blame_basic
run_test test_blame_tag
run_test test_blame_file_single_line
@@ -690,3 +740,4 @@ run_test test_blame_lines_shifted_up
run_test test_blame_lines_shifted_down
run_test test_blame_commit_subsumed
run_test test_blame_blame_h
+run_test test_blame_added_on_branch
diff --git a/regress/cmdline/common.sh b/regress/cmdline/common.sh
index 4dbd408..64c49a7 100644
--- a/regress/cmdline/common.sh
+++ b/regress/cmdline/common.sh
@@ -58,6 +58,14 @@ function git_show_head
(cd $repo && git show --no-patch --pretty='format:%H')
}
+function git_show_branch_head
+{
+ local repo="$1"
+ local branch="$2"
+ (cd $repo && git show --no-patch --pretty='format:%H' $branch)
+}
+
+
function git_show_author_time
{
local repo="$1"