From: Bo Yang <struggleyb.nku@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, Jens.Lehmann@web.de, trast@student.ethz.ch
Subject: [PATCH v2 12/13] add two test cases
Date: Wed, 30 Jun 2010 23:25:25 +0800 [thread overview]
Message-ID: <1277911526-12105-12-git-send-email-struggleyb.nku@gmail.com> (raw)
In-Reply-To: <1277911526-12105-1-git-send-email-struggleyb.nku@gmail.com>
t4301: for simple linear history only
t4302: for history contains merge
Signed-off-by: Bo Yang <struggleyb.nku@gmail.com>
---
t/t4301-log-line-single-history.sh | 342 ++++++++++++++++++++++++++++++++++++
t/t4302-log-line-merge-history.sh | 118 +++++++++++++
2 files changed, 460 insertions(+), 0 deletions(-)
create mode 100755 t/t4301-log-line-single-history.sh
create mode 100755 t/t4302-log-line-merge-history.sh
diff --git a/t/t4301-log-line-single-history.sh b/t/t4301-log-line-single-history.sh
new file mode 100755
index 0000000..9981496
--- /dev/null
+++ b/t/t4301-log-line-single-history.sh
@@ -0,0 +1,342 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Bo Yang
+#
+
+test_description='Test git log -L with single line of history
+
+'
+. ./test-lib.sh
+. "$TEST_DIRECTORY"/diff-lib.sh
+
+echo >path0 'void func(){
+ int a = 0;
+ int b = 1;
+ int c;
+ c = a + b;
+}
+'
+
+echo >path1 'void output(){
+ printf("hello world");
+}
+'
+
+test_expect_success \
+ 'add path0/path1 and commit.' \
+ 'git add path0 path1 &&
+ git commit -m "Base commit"'
+
+echo >path0 'void func(){
+ int a = 10;
+ int b = 11;
+ int c;
+ c = a + b;
+}
+'
+
+echo >path1 'void output(){
+ const char *str = "hello world!";
+ printf("%s", str);
+}
+'
+
+test_expect_success \
+ 'Change the 2,3 lines of path0 and path1.' \
+ 'git add path0 path1 &&
+ git commit -m "Change 2,3 lines of path0 and path1"'
+
+echo >path0 'void func(){
+ int a = 10;
+ int b = 11;
+ int c;
+ c = 10 * (a + b);
+}
+'
+
+test_expect_success \
+ 'Change the 5th line of path0.' \
+ 'git add path0 &&
+ git commit -m "Change the 5th line of path0"'
+
+echo >path0 'void func(){
+ int a = 10;
+ int b = 11;
+ printf("%d", a - b);
+}
+'
+
+test_expect_success \
+ 'Final change of path0.' \
+ 'git add path0 &&
+ git commit -m "Final change of path0"'
+
+test_expect_success \
+ 'Show the line level log of path0' \
+ 'git log --pretty=format:%s%n%b -L /func/,/^}/ path0 > current-path0'
+
+test_expect_success \
+ 'Show the line level log of path1' \
+ 'git log --pretty=format:%s%n%b -L /output/,/^}/ path1 > current-path1'
+
+test_expect_success \
+ 'Show the line level log of two files' \
+ 'git log --pretty=format:%s%n%b -L /func/,/^}/ path0 -L /output/,/^}/ path1 > current-pathall'
+
+test_expect_success \
+ 'Test the line number argument' \
+ 'git log --pretty=format:%s%n%b -L 1,2 path0 > current-linenum'
+
+test_expect_success \
+ 'Test the --always-print option' \
+ 'git log --pretty=format:%s%n%b --always-print -L 1,2 path0 > current-always'
+
+cat >expected-path0 <<\EOF
+Final change of path0
+
+diff --git a/path0 b/path0
+index 44db133..1518c15 100644
+--- a/path0
++++ b/path0
+@@ -1,6 +1,5 @@
+ void func(){
+ int a = 10;
+ int b = 11;
+- int c;
+- c = 10 * (a + b);
++ printf("%d", a - b);
+ }
+
+Change the 5th line of path0
+
+diff --git a/path0 b/path0
+index 9ef1692..44db133 100644
+--- a/path0
++++ b/path0
+@@ -1,6 +1,6 @@
+ void func(){
+ int a = 10;
+ int b = 11;
+ int c;
+- c = a + b;
++ c = 10 * (a + b);
+ }
+
+Change 2,3 lines of path0 and path1
+
+diff --git a/path0 b/path0
+index aabffdf..9ef1692 100644
+--- a/path0
++++ b/path0
+@@ -1,6 +1,6 @@
+ void func(){
+- int a = 0;
+- int b = 1;
++ int a = 10;
++ int b = 11;
+ int c;
+ c = a + b;
+ }
+
+Base commit
+
+diff --git a/path0 b/path0
+new file mode 100644
+index 0000000..aabffdf
+--- /dev/null
++++ b/path0
+@@ -0,0 +1,6 @@
++void func(){
++ int a = 0;
++ int b = 1;
++ int c;
++ c = a + b;
++}
+EOF
+
+cat >expected-path1 <<\EOF
+Change 2,3 lines of path0 and path1
+
+diff --git a/path1 b/path1
+index 997d841..1d711b5 100644
+--- a/path1
++++ b/path1
+@@ -1,3 +1,4 @@
+ void output(){
+- printf("hello world");
++ const char *str = "hello world!";
++ printf("%s", str);
+ }
+
+Base commit
+
+diff --git a/path1 b/path1
+new file mode 100644
+index 0000000..997d841
+--- /dev/null
++++ b/path1
+@@ -0,0 +1,3 @@
++void output(){
++ printf("hello world");
++}
+EOF
+
+cat >expected-pathall <<\EOF
+Final change of path0
+
+diff --git a/path0 b/path0
+index 44db133..1518c15 100644
+--- a/path0
++++ b/path0
+@@ -1,6 +1,5 @@
+ void func(){
+ int a = 10;
+ int b = 11;
+- int c;
+- c = 10 * (a + b);
++ printf("%d", a - b);
+ }
+
+Change the 5th line of path0
+
+diff --git a/path0 b/path0
+index 9ef1692..44db133 100644
+--- a/path0
++++ b/path0
+@@ -1,6 +1,6 @@
+ void func(){
+ int a = 10;
+ int b = 11;
+ int c;
+- c = a + b;
++ c = 10 * (a + b);
+ }
+
+Change 2,3 lines of path0 and path1
+
+diff --git a/path0 b/path0
+index aabffdf..9ef1692 100644
+--- a/path0
++++ b/path0
+@@ -1,6 +1,6 @@
+ void func(){
+- int a = 0;
+- int b = 1;
++ int a = 10;
++ int b = 11;
+ int c;
+ c = a + b;
+ }
+diff --git a/path1 b/path1
+index 997d841..1d711b5 100644
+--- a/path1
++++ b/path1
+@@ -1,3 +1,4 @@
+ void output(){
+- printf("hello world");
++ const char *str = "hello world!";
++ printf("%s", str);
+ }
+
+Base commit
+
+diff --git a/path0 b/path0
+new file mode 100644
+index 0000000..aabffdf
+--- /dev/null
++++ b/path0
+@@ -0,0 +1,6 @@
++void func(){
++ int a = 0;
++ int b = 1;
++ int c;
++ c = a + b;
++}
+diff --git a/path1 b/path1
+new file mode 100644
+index 0000000..997d841
+--- /dev/null
++++ b/path1
+@@ -0,0 +1,3 @@
++void output(){
++ printf("hello world");
++}
+EOF
+
+cat >expected-linenum <<\EOF
+Change 2,3 lines of path0 and path1
+
+diff --git a/path0 b/path0
+index aabffdf..9ef1692 100644
+--- a/path0
++++ b/path0
+@@ -1,2 +1,2 @@
+ void func(){
+- int a = 0;
++ int a = 10;
+
+Base commit
+
+diff --git a/path0 b/path0
+new file mode 100644
+index 0000000..aabffdf
+--- /dev/null
++++ b/path0
+@@ -0,0 +1,2 @@
++void func(){
++ int a = 0;
+EOF
+
+cat >expected-always <<\EOF
+Final change of path0
+
+diff --git a/path0 b/path0
+index 44db133..1518c15 100644
+--- a/path0
++++ b/path0
+@@ -1,2 +1,2 @@
+ void func(){
+ int a = 10;
+
+Change the 5th line of path0
+
+diff --git a/path0 b/path0
+index 9ef1692..44db133 100644
+--- a/path0
++++ b/path0
+@@ -1,2 +1,2 @@
+ void func(){
+ int a = 10;
+
+Change 2,3 lines of path0 and path1
+
+diff --git a/path0 b/path0
+index aabffdf..9ef1692 100644
+--- a/path0
++++ b/path0
+@@ -1,2 +1,2 @@
+ void func(){
+- int a = 0;
++ int a = 10;
+
+Base commit
+
+diff --git a/path0 b/path0
+new file mode 100644
+index 0000000..aabffdf
+--- /dev/null
++++ b/path0
+@@ -0,0 +1,2 @@
++void func(){
++ int a = 0;
+EOF
+
+test_expect_success \
+ 'validate the output.' \
+ 'test_cmp current-path0 expected-path0 &&
+ test_cmp current-path1 expected-path1 &&
+ test_cmp current-pathall expected-pathall &&
+ test_cmp current-linenum expected-linenum &&
+ test_cmp current-always expected-always'
+
+test_done
diff --git a/t/t4302-log-line-merge-history.sh b/t/t4302-log-line-merge-history.sh
new file mode 100755
index 0000000..70ad0bf
--- /dev/null
+++ b/t/t4302-log-line-merge-history.sh
@@ -0,0 +1,118 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Bo Yang
+#
+
+test_description='Test git log -L with merge commit
+
+'
+. ./test-lib.sh
+. "$TEST_DIRECTORY"/diff-lib.sh
+
+echo >path0 'void func(){
+ printf("hello");
+}
+'
+
+test_expect_success \
+ 'Add path0 and commit.' \
+ 'git add path0 &&
+ git commit -m "Base commit"'
+
+echo >path0 'void func(){
+ printf("hello earth");
+}
+'
+
+test_expect_success \
+ 'Change path0 in master.' \
+ 'git add path0 &&
+ git commit -m "Change path0 in master"'
+
+test_expect_success \
+ 'Make a new branch from the base commit' \
+ 'git checkout -b feature master^'
+
+echo >path0 'void func(){
+ print("hello moon");
+}
+'
+
+test_expect_success \
+ 'Change path0 in feature.' \
+ 'git add path0 &&
+ git commit -m "Change path0 in feature"'
+
+test_expect_success \
+ 'Merge the master to feature' \
+ '! git merge master'
+
+echo >path0 'void func(){
+ printf("hello earth and moon");
+}
+'
+
+test_expect_success \
+ 'Resolve the conflict' \
+ 'git add path0 &&
+ git commit -m "Merge two branches"'
+
+test_expect_success \
+ 'Show the line level log of path0' \
+ 'git log --pretty=format:%s%n%b -L /func/,/^}/ path0 > current-path0'
+
+test_expect_success \
+ 'Show the line level log of path0' \
+ 'git log --pretty=format:%s%n%b -L /func/,/^}/ path0 > current'
+
+cat >expected <<\EOF
+Merge two branches
+
+nontrivial merge found
+path0
+
+@@ 2,1 @@
+ printf("hello earth and moon");
+
+
+Change path0 in master
+
+diff --git a/path0 b/path0
+index f628dea..bef7fa3 100644
+--- a/path0
++++ b/path0
+@@ -1,3 +1,3 @@
+ void func(){
+- printf("hello");
++ printf("hello earth");
+ }
+
+Change path0 in feature
+
+diff --git a/path0 b/path0
+index f628dea..a940ef6 100644
+--- a/path0
++++ b/path0
+@@ -1,3 +1,3 @@
+ void func(){
+- printf("hello");
++ print("hello moon");
+ }
+
+Base commit
+
+diff --git a/path0 b/path0
+new file mode 100644
+index 0000000..f628dea
+--- /dev/null
++++ b/path0
+@@ -0,0 +1,3 @@
++void func(){
++ printf("hello");
++}
+EOF
+test_expect_success \
+ 'validate the output.' \
+ 'test_cmp current expected'
+
+test_done
--
1.7.0.2.273.gc2413.dirty
next prev parent reply other threads:[~2010-06-30 15:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-30 15:25 [PATCH v2 01/13] parse-options: stop when encounter a non-option Bo Yang
2010-06-30 15:25 ` [PATCH v2 02/13] parse-options: add two helper functions Bo Yang
2010-06-30 15:25 ` [PATCH v2 03/13] add the basic data structure for line level history Bo Yang
2010-07-06 2:36 ` Junio C Hamano
2010-07-06 14:21 ` Bo Yang
2010-06-30 15:25 ` [PATCH v2 04/13] refactor parse_loc Bo Yang
2010-06-30 15:25 ` [PATCH v2 05/13] parse the -L options Bo Yang
2010-06-30 15:25 ` [PATCH v2 06/13] export three functions from diff.c Bo Yang
2010-06-30 15:25 ` [PATCH v2 07/13] add range clone functions Bo Yang
2010-06-30 15:25 ` [PATCH v2 08/13] map/take range to parent Bo Yang
2010-06-30 15:25 ` [PATCH v2 09/13] print the line log Bo Yang
2010-06-30 15:25 ` [PATCH v2 10/13] map/print ranges along traversing the history topologically Bo Yang
2010-06-30 15:25 ` [PATCH v2 11/13] add --always-print option Bo Yang
2010-06-30 15:25 ` Bo Yang [this message]
2010-06-30 15:25 ` [PATCH v2 13/13] some document update Bo Yang
2010-07-06 2:36 ` [PATCH v2 01/13] parse-options: stop when encounter a non-option Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1277911526-12105-12-git-send-email-struggleyb.nku@gmail.com \
--to=struggleyb.nku@gmail.com \
--cc=Jens.Lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=trast@student.ethz.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).