diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-10-19 10:49:13 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-10-19 10:49:13 -0700 |
commit | 9b55aa03daebf43067021b7d58abea249229987b (patch) | |
tree | 1ca8767031f5f0968d8bc96bb8c2b192b7b94a9b /t | |
parent | 662384c4996c7bc46322dc6d4f5afafa6e069d40 (diff) | |
parent | 14937c2c06e63f93f65e1bc6693b95d4e54053d7 (diff) | |
download | git-9b55aa03daebf43067021b7d58abea249229987b.tar.gz git-9b55aa03daebf43067021b7d58abea249229987b.tar.xz |
Merge branch 'rs/diff-whole-function'
* rs/diff-whole-function:
diff: add option to show whole functions as context
xdiff: factor out get_func_line()
Diffstat (limited to 't')
-rw-r--r-- | t/t4051-diff-function-context.sh | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/t/t4051-diff-function-context.sh b/t/t4051-diff-function-context.sh new file mode 100644 index 000000000..001d678e0 --- /dev/null +++ b/t/t4051-diff-function-context.sh @@ -0,0 +1,92 @@ +#!/bin/sh + +test_description='diff function context' + +. ./test-lib.sh +. "$TEST_DIRECTORY"/diff-lib.sh + + +cat <<\EOF >hello.c +#include <stdio.h> + +static int a(void) +{ + /* + * Dummy. + */ +} + +static int hello_world(void) +{ + /* Classic. */ + printf("Hello world.\n"); + + /* Success! */ + return 0; +} +static int b(void) +{ + /* + * Dummy, too. + */ +} + +int main(int argc, char **argv) +{ + a(); + b(); + return hello_world(); +} +EOF + +test_expect_success 'setup' ' + git add hello.c && + test_tick && + git commit -m initial && + + grep -v Classic <hello.c >hello.c.new && + mv hello.c.new hello.c +' + +cat <<\EOF >expected +diff --git a/hello.c b/hello.c +--- a/hello.c ++++ b/hello.c +@@ -10,8 +10,7 @@ static int a(void) + static int hello_world(void) + { +- /* Classic. */ + printf("Hello world.\n"); + + /* Success! */ + return 0; + } +EOF + +test_expect_success 'diff -U0 -W' ' + git diff -U0 -W >actual && + compare_diff_patch actual expected +' + +cat <<\EOF >expected +diff --git a/hello.c b/hello.c +--- a/hello.c ++++ b/hello.c +@@ -9,9 +9,8 @@ static int a(void) + + static int hello_world(void) + { +- /* Classic. */ + printf("Hello world.\n"); + + /* Success! */ + return 0; + } +EOF + +test_expect_success 'diff -W' ' + git diff -W >actual && + compare_diff_patch actual expected +' + +test_done |