-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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()
- Loading branch information
Showing
6 changed files
with
175 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters