git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Cc: Arjen Laarhoven <arjen@yaph.org>,
	Junio C Hamano <gitster@pobox.com>,
	Jakub Narebski <jnareb@gmail.com>
Subject: [PATCH] Test "git log --diff-filter"
Date: Sat,  5 Jan 2008 23:20:22 +0100	[thread overview]
Message-ID: <1199571622-12953-1-git-send-email-jnareb@gmail.com> (raw)
In-Reply-To: <1198580807-18802-1-git-send-email-arjen@yaph.org>

Add test to check "git log --diff-filter" works correctly with and
without diff generation by git-log; the main purpose of this test is
to check if "git log --diff-filter" filters revisions correctly.

This is a companion test to commit 0faf2da7e5ee5c2f472d8a7afaf8616101f34e80
(Fix "git log --diff-filter" bug) by Arjen Laarhoven.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Junio C Hamano wrote:

> Thanks.  Some tests?

So there it is...


First, either I don't understand what referred to commit was supposed
to fix, or my test is wrong, or the patch doesn't fix the bug.

Second, I have a few questions about the test itself. I'm not that
sure about it's name: t/README tells us to use 4 as a first digit of
test number for testing diff commands, and 8 for commands concerning
forensics. "git log --diff-filter" is a forensics concerning diff
output. Second digit is for command itself: 0 is used for diff, 2 for
log, so perhaps the test should be named t/t4203-log-diff-filter.sh

The style of writing test is not very consistent across git test
suite. I think that the 'setup' step style is all right, and only
perhas the style of those two-liner tests could be changed.

I use "git diff --exit-code expected current" instead of "diff" or
"cmp" utilities; should all (new) test use this... well of course
except ones testing diff output itself?

 t/t4025-diff-filter.sh |  240 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 240 insertions(+), 0 deletions(-)
 create mode 100755 t/t4025-diff-filter.sh

diff --git a/t/t4025-diff-filter.sh b/t/t4025-diff-filter.sh
new file mode 100755
index 0000000..3113786
--- /dev/null
+++ b/t/t4025-diff-filter.sh
@@ -0,0 +1,240 @@
+#!/bin/sh
+
+test_description='git log --diff-filter option
+
+Test --diff-filter option with git-log with and without diff output,
+checking both diff output filtering and revision list filtering.
+'
+
+. ./test-lib.sh
+. ../diff-lib.sh ;# test-lib chdir's into trash
+
+# ----------------------------------------------------------------------
+
+test_expect_success setup '
+
+	rm -f foo &&
+	cat ../../COPYING >foo &&
+	git add foo &&
+	git commit -a -m "1st commit: A" &&
+
+	cp foo bar &&
+	git add bar &&
+	git commit -a -m "2nd commit: C" &&
+
+	git rm foo &&
+	git commit -a -m "3rd commit: D" &&
+
+	echo "First added line" >> bar &&
+	git commit -a -m "4th commit: M" &&
+
+	git mv bar foo &&
+	git commit -a -m "5th commit: R" &&
+
+	rm -f foo &&
+	cat ../../Makefile >foo &&
+	git commit -a -m "6th commit: B" &&
+
+	rm -f bar &&
+	echo "bar" > bar &&
+	git add bar &&
+	echo "Second added line" >> foo &&
+	git commit -a -m "7th commit: AM"
+
+	rm -f bar &&
+	ln -s foo bar &&
+	git commit -a -m "8th commit: T"
+
+'
+
+# ----------------------------------------------------------------------
+
+cat >expected <<\EOF
+7th commit: AM
+:000000 100644 0000000000000000000000000000000000000000 5716ca5987cbf97d6bb54920bea6adde242d87e6 A	bar
+
+1st commit: A
+:000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A	foo
+EOF
+
+test_expect_success 'git log --raw --diff-filter=A' '
+	git log --raw --no-abbrev --pretty=format:%s -B -C -C --diff-filter=A >current &&
+	compare_diff_raw expected current
+'
+
+
+cat >expected <<\EOF
+3rd commit: D
+:100644 000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0000000000000000000000000000000000000000 D	foo
+EOF
+
+test_expect_success 'git log --raw --diff-filter=D' '
+	git log --raw --no-abbrev --pretty=format:%s -B -C -C --diff-filter=D >current &&
+	compare_diff_raw expected current
+'
+
+
+cat >expected <<\EOF
+7th commit: AM
+:100644 100644 21c80e6bf73163b9770cba5331cd48172fa6d43e a892bacce2a80efc14eef1c316e827575a96e5c9 M	foo
+
+4th commit: M
+:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 915b225a6c9984e645a8061e05002f8cbd2ce46c M	bar
+EOF
+
+test_expect_success 'git log --raw --diff-filter=M' '
+	git log --raw --no-abbrev --pretty=format:%s -B -C -C --diff-filter=M >current &&
+	compare_diff_raw expected current
+'
+
+
+cat >expected <<\EOF
+5th commit: R
+:100644 100644 915b225a6c9984e645a8061e05002f8cbd2ce46c 915b225a6c9984e645a8061e05002f8cbd2ce46c R100	bar	foo
+EOF
+
+test_expect_success 'git log --raw --diff-filter=R' '
+	git log --raw --no-abbrev --pretty=format:%s -B -C -C --diff-filter=R >current &&
+	compare_diff_raw expected current
+'
+
+
+cat >expected <<\EOF
+2nd commit: C
+:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 C100	foo	bar
+EOF
+
+test_expect_success 'git log --raw --diff-filter=C' '
+	git log --raw --no-abbrev --pretty=format:%s -B -C -C --diff-filter=C >current &&
+	compare_diff_raw expected current
+'
+
+
+cat >expected <<\EOF
+6th commit: B
+:100644 100644 915b225a6c9984e645a8061e05002f8cbd2ce46c 21c80e6bf73163b9770cba5331cd48172fa6d43e M098	foo
+EOF
+
+test_expect_success 'git log --raw --diff-filter=B' '
+	git log --raw --no-abbrev --pretty=format:%s -B -C -C --diff-filter=B >current &&
+	compare_diff_raw expected current
+'
+
+
+cat >expected <<\EOF
+8th commit: T
+:100644 120000 5716ca5987cbf97d6bb54920bea6adde242d87e6 19102815663d23f8b75a47e7a01965dcdc96468c T	bar
+EOF
+
+test_expect_success 'git log --raw --diff-filter=T' '
+	git log --raw --no-abbrev --pretty=format:%s -B -C -C --diff-filter=T >current &&
+	compare_diff_raw expected current
+'
+
+cat >expected <<\EOF
+7th commit: AM
+:000000 100644 0000000000000000000000000000000000000000 5716ca5987cbf97d6bb54920bea6adde242d87e6 A	bar
+:100644 100644 21c80e6bf73163b9770cba5331cd48172fa6d43e a892bacce2a80efc14eef1c316e827575a96e5c9 M	foo
+
+1st commit: A
+:000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A	foo
+EOF
+
+test_expect_success 'git log --raw --diff-filter=A*' '
+	git log --raw --no-abbrev --pretty=format:%s -B -C -C --diff-filter=A* >current &&
+	compare_diff_raw expected current
+'
+
+# ----------------------------------------------------------------------
+
+cat >expected <<\EOF
+8th commit: T
+7th commit: AM
+6th commit: B
+5th commit: R
+4th commit: M
+3rd commit: D
+2nd commit: C
+1st commit: A
+EOF
+
+test_expect_success 'git log (no filter)' '
+	git log --pretty=format:%s -B -C -C >current &&
+	git diff --exit-code expected current
+'
+
+
+cat >expected <<\EOF
+7th commit: AM
+1st commit: A
+EOF
+
+test_expect_success 'git log --diff-filter=A' '
+	git log --pretty=format:%s -B -C -C --diff-filter=A >current &&
+	git diff --exit-code expected current
+'
+
+
+cat >expected <<\EOF
+3rd commit: D
+EOF
+
+test_expect_success 'git log --diff-filter=D' '
+	git log --pretty=format:%s -B -C -C --diff-filter=D >current &&
+	git diff --exit-code expected current
+'
+
+
+cat >expected <<\EOF
+7th commit: AM
+4th commit: M
+EOF
+
+test_expect_success 'git log --diff-filter=M' '
+	git log --pretty=format:%s -B -C -C --diff-filter=M >current &&
+	git diff --exit-code expected current
+'
+
+
+cat >expected <<\EOF
+5th commit: R
+EOF
+
+test_expect_success 'git log --diff-filter=R' '
+	git log --pretty=format:%s -B -C -C --diff-filter=R >current &&
+	git diff --exit-code expected current
+'
+
+
+cat >expected <<\EOF
+2nd commit: C
+EOF
+
+test_expect_success 'git log --diff-filter=C' '
+	git log --pretty=format:%s -B -C -C --diff-filter=C >current &&
+	git diff --exit-code expected current
+'
+
+
+cat >expected <<\EOF
+6th commit: B
+EOF
+
+test_expect_success 'git log --diff-filter=B' '
+	git log --pretty=format:%s -B -C -C --diff-filter=A >current &&
+	git diff --exit-code expected current
+'
+
+
+cat >expected <<\EOF
+8th commit: T
+EOF
+
+test_expect_success 'git log --diff-filter=T' '
+	git log --pretty=format:%s -B -C -C --diff-filter=T >current &&
+	git diff --exit-code expected current
+'
+
+# ----------------------------------------------------------------------
+
+test_done
-- 
1.5.3.7

  parent reply	other threads:[~2008-01-05 22:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-25 11:06 [PATCH] Fix "git log --diff-filter" bug Arjen Laarhoven
2007-12-25 22:44 ` Jakub Narebski
2007-12-26 19:41 ` Junio C Hamano
2008-01-05 22:20 ` Jakub Narebski [this message]
2008-01-05 22:34   ` [PATCH] Test "git log --diff-filter" Junio C Hamano
2008-01-05 23:33     ` Jakub Narebski
2008-01-06  2:26       ` Junio C Hamano
2008-01-07  0:31         ` Jakub Narebski
2008-01-07  1:58           ` 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=1199571622-12953-1-git-send-email-jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=arjen@yaph.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).