git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: John Keeping <john@keeping.me.uk>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, David Aguilar <davvid@gmail.com>,
	Matt McClure <matthewlmcclure@gmail.com>,
	Tim Henigan <tim.henigan@gmail.com>,
	John Keeping <john@keeping.me.uk>
Subject: [PATCH 2/2] entry: fix filter lookup
Date: Thu, 14 Mar 2013 20:00:51 +0000	[thread overview]
Message-ID: <bede6d48dd44f7ed4a11da5821bb112b700475d5.1363291173.git.john@keeping.me.uk> (raw)
In-Reply-To: <cover.1363291173.git.john@keeping.me.uk>
In-Reply-To: <cover.1363291173.git.john@keeping.me.uk>

When looking up the stream filter, write_entry() should be passing the
path of the file in the repository, not the path to which the content is
going to be written.  This allows the file to be correctly looked up
against the .gitattributes files in the working tree.

This change makes the streaming case match the non-streaming case which
passes ce->name to convert_to_working_tree later in the same function.

The two tests added here test the different paths through write_entry
since the CRLF filter is a streaming filter but the user-defined smudge
filter is not streamed.

Signed-off-by: John Keeping <john@keeping.me.uk>
---
 entry.c                         |  2 +-
 t/t2003-checkout-cache-mkdir.sh | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/entry.c b/entry.c
index 17a6bcc..63c52ed 100644
--- a/entry.c
+++ b/entry.c
@@ -145,7 +145,7 @@ static int write_entry(struct cache_entry *ce, char *path, const struct checkout
 	struct stat st;
 
 	if (ce_mode_s_ifmt == S_IFREG) {
-		struct stream_filter *filter = get_stream_filter(path, ce->sha1);
+		struct stream_filter *filter = get_stream_filter(ce->name, ce->sha1);
 		if (filter &&
 		    !streaming_write_entry(ce, path, filter,
 					   state, to_tempfile,
diff --git a/t/t2003-checkout-cache-mkdir.sh b/t/t2003-checkout-cache-mkdir.sh
index 63fd0a8..4c97468 100755
--- a/t/t2003-checkout-cache-mkdir.sh
+++ b/t/t2003-checkout-cache-mkdir.sh
@@ -90,4 +90,30 @@ test_expect_success SYMLINKS 'use --prefix=tmp- where tmp-path1 is a symlink' '
 	test -f tmp-path1/file1
 '
 
+test_expect_success 'apply filter from working tree .gitattributes with --prefix' '
+	rm -fr path0 path1 path2 tmp* &&
+	mkdir path1 &&
+	mkdir tmp &&
+	git config filter.replace-all.smudge "sed -e s/./=/g" &&
+	git config filter.replace-all.clean cat &&
+	git config filter.replace-all.required true &&
+	echo "file1 filter=replace-all" >path1/.gitattributes &&
+	git checkout-index --prefix=tmp/ -f -a &&
+	echo frotz >expected &&
+	test_cmp expected tmp/path0 &&
+	echo ====== >expected &&
+	test_cmp expected tmp/path1/file1
+'
+
+test_expect_success 'apply CRLF filter from working tree .gitattributes with --prefix' '
+	rm -fr path0 path1 path2 tmp* &&
+	mkdir path1 &&
+	mkdir tmp &&
+	echo "file1 eol=crlf" >path1/.gitattributes &&
+	git checkout-index --prefix=tmp/ -f -a &&
+	echo rezrovQ >expected &&
+	tr \\015 Q <tmp/path1/file1 >actual &&
+	test_cmp expected actual
+'
+
 test_done
-- 
1.8.2.rc2.4.g7799588

  parent reply	other threads:[~2013-03-14 20:01 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-26 20:23 difftool -d symlinks, under what conditions Matt McClure
2012-11-27  6:20 ` David Aguilar
2012-11-27 21:10   ` Matt McClure
     [not found]   ` <CAJELnLEL8y0G3MBGkW+YDKtVxX4n4axJG7p0oPsXsV4_FRyGDg@mail.gmail.com>
2013-03-12 18:12     ` Matt McClure
2013-03-12 19:09       ` John Keeping
2013-03-12 19:23         ` David Aguilar
2013-03-12 19:43           ` John Keeping
2013-03-12 20:39             ` Junio C Hamano
2013-03-12 21:06               ` John Keeping
2013-03-12 21:26                 ` Junio C Hamano
2013-03-12 21:43                 ` Matt McClure
2013-03-12 22:11                   ` Matt McClure
2013-03-12 22:16                   ` Junio C Hamano
2013-03-12 22:48                     ` Matt McClure
2013-03-13  0:17                       ` John Keeping
2013-03-13  0:56                         ` Matt McClure
2013-03-13  8:24                         ` David Aguilar
2013-03-13 15:30                           ` Junio C Hamano
2013-03-13 16:45                             ` Junio C Hamano
2013-03-13 17:08                               ` John Keeping
2013-03-13 17:40                                 ` Junio C Hamano
2013-03-13 18:01                                   ` John Keeping
2013-03-13 19:28                                     ` Junio C Hamano
2013-03-13 20:33                                       ` [PATCH 0/2] difftool --dir-diff: symlink all files matching the working tree John Keeping
2013-03-13 20:33                                         ` [PATCH 1/2] git-difftool(1): fix formatting of --symlink description John Keeping
2013-03-13 20:33                                         ` [PATCH 2/2] difftool --dir-diff: symlink all files matching the working tree John Keeping
2013-03-14  3:41                                           ` David Aguilar
2013-03-14  9:36                                             ` John Keeping
2013-03-14 15:18                                           ` Junio C Hamano
2013-03-14 20:19                                         ` [PATCH v2 0/3] " John Keeping
2013-03-14 20:19                                           ` [PATCH v2 1/3] git-difftool(1): fix formatting of --symlink description John Keeping
2013-03-14 20:19                                           ` [PATCH v2 2/3] difftool: avoid double slashes in symlink targets John Keeping
2013-03-14 21:19                                             ` Junio C Hamano
2013-03-14 20:19                                           ` [PATCH v2 3/3] difftool --dir-diff: symlink all files matching the working tree John Keeping
2013-03-14 21:28                                             ` Junio C Hamano
2013-03-14 22:24                                               ` John Keeping
2013-03-14 22:31                                                 ` Junio C Hamano
2013-03-14  9:43                               ` difftool -d symlinks, under what conditions John Keeping
2013-03-14 17:25                                 ` John Keeping
2013-03-14 17:33                                   ` Junio C Hamano
2013-03-14 20:00                                     ` [PATCH 0/2] checkout-index: fix .gitattributes handling with --prefix John Keeping
2013-03-14 20:00                                       ` [PATCH 1/2] t2003: modernize style John Keeping
2013-03-14 20:00                                       ` John Keeping [this message]
2013-03-14 21:50                                         ` [PATCH 2/2] entry: fix filter lookup Junio C Hamano
2013-03-12 20:38           ` difftool -d symlinks, under what conditions Junio C Hamano
2013-03-12 19:24         ` [PATCH] difftool: Make directory diff symlink work tree John Keeping
2013-03-12 23:12           ` Matt McClure
2013-03-12 23:40             ` John Keeping
2013-03-13  0:26           ` Matt McClure
2013-03-13  9:11             ` John Keeping

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bede6d48dd44f7ed4a11da5821bb112b700475d5.1363291173.git.john@keeping.me.uk \
    --to=john@keeping.me.uk \
    --cc=davvid@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=matthewlmcclure@gmail.com \
    --cc=tim.henigan@gmail.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).