Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions line-range.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ static const char *parse_range_funcname(
(*end)++;
}

/* exclude trailing empty lines from the function range */
while (*end > *begin + 1 &&
nth_line_cb(cb_data, *end - 1)[0] == '\n')
(*end)--;

regfree(&regexp);
if (xecfg)
xdiff_clear_find_func(xecfg);
Expand Down
26 changes: 26 additions & 0 deletions t/t4211-line-log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,32 @@ test_expect_success '--summary shows new file on root commit' '
test_grep "create mode 100644 file.c" actual
'

test_expect_success '-L :funcname: excludes trailing empty lines at EOF' '
git init trailing-empty &&
(
cd trailing-empty &&
test_commit --printf --no-tag "add func.py" \
func.py "def foo():\n return 1\n" &&
test_commit --printf --no-tag "add trailing empty lines" \
func.py "def foo():\n return 1\n\n\n\n" &&
git log -L :foo:func.py --format="%s" >actual &&
test_grep ! "add trailing empty lines" actual
)
'

test_expect_success '-L :funcname: excludes empty lines between functions' '
git init empty-between-funcs &&
(
cd empty-between-funcs &&
test_commit --printf --no-tag "add two funcs" \
func.py "def foo():\n return 1\n\ndef bar():\n return 2\n" &&
test_commit --printf --no-tag "add empty lines between" \
func.py "def foo():\n return 1\n\n\n\ndef bar():\n return 2\n" &&
git log -L :foo:func.py --format="%s" >actual &&
test_grep ! "add empty lines between" actual
)
'

test_expect_success 'get_commit_action() does not mutate a not-yet-walked commit' '
git init peek &&
(
Expand Down
18 changes: 6 additions & 12 deletions t/t4211/sha1/expect.parallel-change-f-to-main
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ diff --git a/b.c b/b.c
index 5de3ea4..bf79c2f 100644
--- a/b.c
+++ b/b.c
@@ -4,14 +4,14 @@
@@ -4,13 +4,13 @@
long f(long x)
{
int s = 0;
Expand All @@ -30,7 +30,6 @@ index 5de3ea4..bf79c2f 100644
/*
* This is only an example!
*/


commit ba227c6632349700fbb957dec2b50f5e2358be3f
Author: Thomas Rast <trast@inf.ethz.ch>
Expand All @@ -42,7 +41,7 @@ diff --git a/a.c b/a.c
index 5de3ea4..01b5b65 100644
--- a/a.c
+++ b/a.c
@@ -4,14 +4,14 @@
@@ -4,13 +4,13 @@
long f(long x)
{
int s = 0;
Expand All @@ -57,7 +56,6 @@ index 5de3ea4..01b5b65 100644
- * This is only an example!
+ * This is only a short example!
*/


commit 39b6eb2d5b706d3322184a169f666f25ed3fbd00
Author: Thomas Rast <trast@student.ethz.ch>
Expand All @@ -69,7 +67,7 @@ diff --git a/a.c b/a.c
index e51de13..bdb2bb1 100644
--- a/a.c
+++ b/a.c
@@ -3,14 +3,14 @@
@@ -3,13 +3,13 @@
long f(long x)
{
int s = 0;
Expand All @@ -84,7 +82,6 @@ index e51de13..bdb2bb1 100644
- * A comment.
+ * This is only an example!
*/


commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2
Author: Thomas Rast <trast@student.ethz.ch>
Expand All @@ -96,7 +93,7 @@ diff --git a/a.c b/a.c
index 3233403..e51de13 100644
--- a/a.c
+++ b/a.c
@@ -3,14 +3,14 @@
@@ -3,13 +3,13 @@
-int f(int x)
+long f(long x)
{
Expand All @@ -111,7 +108,6 @@ index 3233403..e51de13 100644
/*
* A comment.
*/


commit f04fb20f2c77850996cba739709acc6faecc58f7
Author: Thomas Rast <trast@student.ethz.ch>
Expand All @@ -123,7 +119,7 @@ diff --git a/a.c b/a.c
index 444e415..3233403 100644
--- a/a.c
+++ b/a.c
@@ -3,13 +3,14 @@
@@ -3,12 +3,13 @@
int f(int x)
{
int s = 0;
Expand All @@ -137,7 +133,6 @@ index 444e415..3233403 100644
/*
* A comment.
*/


commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a
Author: Thomas Rast <trast@student.ethz.ch>
Expand All @@ -150,7 +145,7 @@ new file mode 100644
index 0000000..444e415
--- /dev/null
+++ b/a.c
@@ -0,0 +3,13 @@
@@ -0,0 +3,12 @@
+int f(int x)
+{
+ int s = 0;
Expand All @@ -163,4 +158,3 @@ index 0000000..444e415
+/*
+ * A comment.
+ */
+
12 changes: 4 additions & 8 deletions t/t4211/sha1/expect.simple-f-to-main
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ diff --git a/a.c b/a.c
index e51de13..bdb2bb1 100644
--- a/a.c
+++ b/a.c
@@ -3,14 +3,14 @@
@@ -3,13 +3,13 @@
long f(long x)
{
int s = 0;
Expand All @@ -23,7 +23,6 @@ index e51de13..bdb2bb1 100644
- * A comment.
+ * This is only an example!
*/


commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2
Author: Thomas Rast <trast@student.ethz.ch>
Expand All @@ -35,7 +34,7 @@ diff --git a/a.c b/a.c
index 3233403..e51de13 100644
--- a/a.c
+++ b/a.c
@@ -3,14 +3,14 @@
@@ -3,13 +3,13 @@
-int f(int x)
+long f(long x)
{
Expand All @@ -50,7 +49,6 @@ index 3233403..e51de13 100644
/*
* A comment.
*/


commit f04fb20f2c77850996cba739709acc6faecc58f7
Author: Thomas Rast <trast@student.ethz.ch>
Expand All @@ -62,7 +60,7 @@ diff --git a/a.c b/a.c
index 444e415..3233403 100644
--- a/a.c
+++ b/a.c
@@ -3,13 +3,14 @@
@@ -3,12 +3,13 @@
int f(int x)
{
int s = 0;
Expand All @@ -76,7 +74,6 @@ index 444e415..3233403 100644
/*
* A comment.
*/


commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a
Author: Thomas Rast <trast@student.ethz.ch>
Expand All @@ -89,7 +86,7 @@ new file mode 100644
index 0000000..444e415
--- /dev/null
+++ b/a.c
@@ -0,0 +3,13 @@
@@ -0,0 +3,12 @@
+int f(int x)
+{
+ int s = 0;
Expand All @@ -102,4 +99,3 @@ index 0000000..444e415
+/*
+ * A comment.
+ */
+
18 changes: 6 additions & 12 deletions t/t4211/sha256/expect.parallel-change-f-to-main
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ diff --git a/b.c b/b.c
index 62c1fc2..69cb69c 100644
--- a/b.c
+++ b/b.c
@@ -4,14 +4,14 @@
@@ -4,13 +4,13 @@
long f(long x)
{
int s = 0;
Expand All @@ -30,7 +30,6 @@ index 62c1fc2..69cb69c 100644
/*
* This is only an example!
*/


commit b511694f5337663fbd697622993a5f8e1099eca84be4df313f2b3ee94a098b42
Author: Thomas Rast <trast@inf.ethz.ch>
Expand All @@ -42,7 +41,7 @@ diff --git a/a.c b/a.c
index 62c1fc2..e1e8475 100644
--- a/a.c
+++ b/a.c
@@ -4,14 +4,14 @@
@@ -4,13 +4,13 @@
long f(long x)
{
int s = 0;
Expand All @@ -57,7 +56,6 @@ index 62c1fc2..e1e8475 100644
- * This is only an example!
+ * This is only a short example!
*/


commit 5a1b3989063d55e71e7685efa3392f133385b4034bddde530dcb5090d8b8b8ca
Author: Thomas Rast <trast@student.ethz.ch>
Expand All @@ -69,7 +67,7 @@ diff --git a/a.c b/a.c
index 75c0119..3a78aaf 100644
--- a/a.c
+++ b/a.c
@@ -3,14 +3,14 @@
@@ -3,13 +3,13 @@
long f(long x)
{
int s = 0;
Expand All @@ -84,7 +82,6 @@ index 75c0119..3a78aaf 100644
- * A comment.
+ * This is only an example!
*/


commit ccf97b9878189c40a981da50b15713bb80a35755326320ec80900caf22ced46f
Author: Thomas Rast <trast@student.ethz.ch>
Expand All @@ -96,7 +93,7 @@ diff --git a/a.c b/a.c
index 7a296b9..75c0119 100644
--- a/a.c
+++ b/a.c
@@ -3,14 +3,14 @@
@@ -3,13 +3,13 @@
-int f(int x)
+long f(long x)
{
Expand All @@ -111,7 +108,6 @@ index 7a296b9..75c0119 100644
/*
* A comment.
*/


commit f6434acd34260a6c9f61e96d96bf9a323d330561df5b1ca2631104f82026dfed
Author: Thomas Rast <trast@student.ethz.ch>
Expand All @@ -123,7 +119,7 @@ diff --git a/a.c b/a.c
index 9f550c3..7a296b9 100644
--- a/a.c
+++ b/a.c
@@ -3,13 +3,14 @@
@@ -3,12 +3,13 @@
int f(int x)
{
int s = 0;
Expand All @@ -137,7 +133,6 @@ index 9f550c3..7a296b9 100644
/*
* A comment.
*/


commit 1dd7e9b2b1699324b53b341e728653b913bc192a14dfea168c5b51f2b3d03592
Author: Thomas Rast <trast@student.ethz.ch>
Expand All @@ -150,7 +145,7 @@ new file mode 100644
index 0000000..9f550c3
--- /dev/null
+++ b/a.c
@@ -0,0 +3,13 @@
@@ -0,0 +3,12 @@
+int f(int x)
+{
+ int s = 0;
Expand All @@ -163,4 +158,3 @@ index 0000000..9f550c3
+/*
+ * A comment.
+ */
+
12 changes: 4 additions & 8 deletions t/t4211/sha256/expect.simple-f-to-main
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ diff --git a/a.c b/a.c
index 75c0119..3a78aaf 100644
--- a/a.c
+++ b/a.c
@@ -3,14 +3,14 @@
@@ -3,13 +3,13 @@
long f(long x)
{
int s = 0;
Expand All @@ -23,7 +23,6 @@ index 75c0119..3a78aaf 100644
- * A comment.
+ * This is only an example!
*/


commit ccf97b9878189c40a981da50b15713bb80a35755326320ec80900caf22ced46f
Author: Thomas Rast <trast@student.ethz.ch>
Expand All @@ -35,7 +34,7 @@ diff --git a/a.c b/a.c
index 7a296b9..75c0119 100644
--- a/a.c
+++ b/a.c
@@ -3,14 +3,14 @@
@@ -3,13 +3,13 @@
-int f(int x)
+long f(long x)
{
Expand All @@ -50,7 +49,6 @@ index 7a296b9..75c0119 100644
/*
* A comment.
*/


commit f6434acd34260a6c9f61e96d96bf9a323d330561df5b1ca2631104f82026dfed
Author: Thomas Rast <trast@student.ethz.ch>
Expand All @@ -62,7 +60,7 @@ diff --git a/a.c b/a.c
index 9f550c3..7a296b9 100644
--- a/a.c
+++ b/a.c
@@ -3,13 +3,14 @@
@@ -3,12 +3,13 @@
int f(int x)
{
int s = 0;
Expand All @@ -76,7 +74,6 @@ index 9f550c3..7a296b9 100644
/*
* A comment.
*/


commit 1dd7e9b2b1699324b53b341e728653b913bc192a14dfea168c5b51f2b3d03592
Author: Thomas Rast <trast@student.ethz.ch>
Expand All @@ -89,7 +86,7 @@ new file mode 100644
index 0000000..9f550c3
--- /dev/null
+++ b/a.c
@@ -0,0 +3,13 @@
@@ -0,0 +3,12 @@
+int f(int x)
+{
+ int s = 0;
Expand All @@ -102,4 +99,3 @@ index 0000000..9f550c3
+/*
+ * A comment.
+ */
+
Loading