git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] t/t4202-log.sh: Add testcases
@ 2009-01-22 16:37 Arjen Laarhoven
  2009-01-22 16:37 ` [PATCH 2/2] git-log: Follow file copies with 'git log --follow -C -C' Arjen Laarhoven
  0 siblings, 1 reply; 3+ messages in thread
From: Arjen Laarhoven @ 2009-01-22 16:37 UTC (permalink / raw)
  To: git

Add testcases for 'git log --diff-filter=[CM]' (copies and renames).
Also add a testcase for 'git log --follow'.

Signed-off-by: Arjen Laarhoven <arjen@yaph.org>
---
 t/t4202-log.sh |   59 +++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 50 insertions(+), 9 deletions(-)

diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 0ab925c..7b976ee 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -16,27 +16,31 @@ test_expect_success setup '
 	test_tick &&
 	git commit -m second &&
 
-	mkdir a &&
-	echo ni >a/two &&
-	git add a/two &&
+	git mv one ichi &&
 	test_tick &&
 	git commit -m third &&
 
-	echo san >a/three &&
-	git add a/three &&
+	cp ichi ein &&
+	git add ein &&
 	test_tick &&
 	git commit -m fourth &&
 
-	git rm a/three &&
+	mkdir a &&
+	echo ni >a/two &&
+	git add a/two &&
+	test_tick &&
+	git commit -m fifth  &&
+
+	git rm a/two &&
 	test_tick &&
-	git commit -m fifth
+	git commit -m sixth
 
 '
 
 test_expect_success 'diff-filter=A' '
 
 	actual=$(git log --pretty="format:%s" --diff-filter=A HEAD) &&
-	expect=$(echo fourth ; echo third ; echo initial) &&
+	expect=$(echo fifth ; echo fourth ; echo third ; echo initial) &&
 	test "$actual" = "$expect" || {
 		echo Oops
 		echo "Actual: $actual"
@@ -60,7 +64,43 @@ test_expect_success 'diff-filter=M' '
 test_expect_success 'diff-filter=D' '
 
 	actual=$(git log --pretty="format:%s" --diff-filter=D HEAD) &&
-	expect=$(echo fifth) &&
+	expect=$(echo sixth ; echo third) &&
+	test "$actual" = "$expect" || {
+		echo Oops
+		echo "Actual: $actual"
+		false
+	}
+
+'
+
+test_expect_success 'diff-filter=R' '
+
+	actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
+	expect=$(echo third) &&
+	test "$actual" = "$expect" || {
+		echo Oops
+		echo "Actual: $actual"
+		false
+	}
+
+'
+
+test_expect_success 'diff-filter=C' '
+
+	actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
+	expect=$(echo fourth) &&
+	test "$actual" = "$expect" || {
+		echo Oops
+		echo "Actual: $actual"
+		false
+	}
+
+'
+
+test_expect_success 'git log --follow' '
+
+	actual=$(git log --follow --pretty="format:%s" ichi) &&
+	expect=$(echo third ; echo second ; echo initial) &&
 	test "$actual" = "$expect" || {
 		echo Oops
 		echo "Actual: $actual"
@@ -72,6 +112,7 @@ test_expect_success 'diff-filter=D' '
 test_expect_success 'setup case sensitivity tests' '
 	echo case >one &&
 	test_tick &&
+	git add one
 	git commit -a -m Second
 '
 
-- 
1.6.1.354.gd9e51

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] git-log: Follow file copies with 'git log --follow -C -C'
  2009-01-22 16:37 [PATCH 1/2] t/t4202-log.sh: Add testcases Arjen Laarhoven
@ 2009-01-22 16:37 ` Arjen Laarhoven
  2009-01-22 17:28   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Arjen Laarhoven @ 2009-01-22 16:37 UTC (permalink / raw)
  To: git

When the '--follow' option is used with '--find-copies-harder' ('-C -C')
logs on individual files will work across file copies as well as
renames.

Intermediate copies will not be shown as a result of the workings of the
'--find-copies-harder' option.

Signed-off-by: Arjen Laarhoven <arjen@yaph.org>
---
 Documentation/git-log.txt |    6 +++++-
 t/t4202-log.sh            |   12 ++++++++++++
 tree-diff.c               |    2 ++
 3 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
index 34cf4e5..2d42101 100644
--- a/Documentation/git-log.txt
+++ b/Documentation/git-log.txt
@@ -52,7 +52,11 @@ include::diff-options.txt[]
 	commits, and doesn't limit diff for those commits.
 
 --follow::
-	Continue listing the history of a file beyond renames.
+	Continue listing the history of a file beyond renames.  When
+	combined with `--find-copies-harder` (`-C -C`) git will also
+	list the file history beyond copies.  Intermediate copies
+	will be skipped, e.g. a copy of file A to B to C will not
+	show B when showing the log on file C.
 
 --log-size::
 	Before the log message print out its size in bytes. Intended
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 7b976ee..a8dd690 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -109,6 +109,18 @@ test_expect_success 'git log --follow' '
 
 '
 
+test_expect_success 'git log --follow --find-copies-harder' '
+
+	actual=$(git log --follow -C -C --pretty="format:%s" ein) &&
+	expect=$(echo fourth; echo third ; echo second ; echo initial) &&
+	test "$actual" = "$expect" || {
+		echo Oops
+		echo "Actual: $actual"
+		false
+	}
+
+'
+
 test_expect_success 'setup case sensitivity tests' '
 	echo case >one &&
 	test_tick &&
diff --git a/tree-diff.c b/tree-diff.c
index 9f67af6..73652b2 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -333,6 +333,8 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co
 
 	diff_setup(&diff_opts);
 	DIFF_OPT_SET(&diff_opts, RECURSIVE);
+	if (DIFF_OPT_TST(opt, FIND_COPIES_HARDER))
+		DIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);
 	diff_opts.detect_rename = DIFF_DETECT_RENAME;
 	diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
 	diff_opts.single_follow = opt->paths[0];
-- 
1.6.1.354.gd9e51

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] git-log: Follow file copies with 'git log --follow -C -C'
  2009-01-22 16:37 ` [PATCH 2/2] git-log: Follow file copies with 'git log --follow -C -C' Arjen Laarhoven
@ 2009-01-22 17:28   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2009-01-22 17:28 UTC (permalink / raw)
  To: Arjen Laarhoven; +Cc: git

Arjen Laarhoven <arjen@yaph.org> writes:

> When the '--follow' option is used with '--find-copies-harder' ('-C -C')
> logs on individual files will work across file copies as well as
> renames.

Is there a reason to limit this to "harder" case?

> diff --git a/tree-diff.c b/tree-diff.c
> index 9f67af6..73652b2 100644
> --- a/tree-diff.c
> +++ b/tree-diff.c
> @@ -333,6 +333,8 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co
>  
>  	diff_setup(&diff_opts);
>  	DIFF_OPT_SET(&diff_opts, RECURSIVE);
> +	if (DIFF_OPT_TST(opt, FIND_COPIES_HARDER))
> +		DIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);
>  	diff_opts.detect_rename = DIFF_DETECT_RENAME;

Hmm, why isn't this DIFF_DETECT_COPY?

>  	diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
>  	diff_opts.single_follow = opt->paths[0];
> -- 
> 1.6.1.354.gd9e51

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-01-22 17:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-22 16:37 [PATCH 1/2] t/t4202-log.sh: Add testcases Arjen Laarhoven
2009-01-22 16:37 ` [PATCH 2/2] git-log: Follow file copies with 'git log --follow -C -C' Arjen Laarhoven
2009-01-22 17:28   ` Junio C Hamano

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).