diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2016-08-24 14:23:39 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-09-11 14:47:46 -0700 |
commit | b9e62f60115c75c5be5de593862925c8b8d7e683 (patch) | |
tree | e40451c0ce8274ff14063aa6c91173aeb4c9d661 /t | |
parent | cat-file: fix a grammo in the man page (diff) | |
download | tgif-b9e62f60115c75c5be5de593862925c8b8d7e683.tar.xz |
cat-file: introduce the --filters option
The --filters option applies the convert_to_working_tree() filter for
the path when showing the contents of a regular file blob object;
the contents are written out as-is for other types of objects.
This feature comes in handy when a 3rd-party tool wants to work with
the contents of files from past revisions as if they had been checked
out, but without detouring via temporary files.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t8010-cat-file-filters.sh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/t/t8010-cat-file-filters.sh b/t/t8010-cat-file-filters.sh new file mode 100755 index 0000000000..e466634732 --- /dev/null +++ b/t/t8010-cat-file-filters.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +test_description='git cat-file filters support' +. ./test-lib.sh + +test_expect_success 'setup ' ' + echo "*.txt eol=crlf diff=txt" >.gitattributes && + echo "hello" | append_cr >world.txt && + git add .gitattributes world.txt && + test_tick && + git commit -m "Initial commit" +' + +has_cr () { + tr '\015' Q <"$1" | grep Q >/dev/null +} + +test_expect_success 'no filters with `git show`' ' + git show HEAD:world.txt >actual && + ! has_cr actual + +' + +test_expect_success 'no filters with cat-file' ' + git cat-file blob HEAD:world.txt >actual && + ! has_cr actual +' + +test_expect_success 'cat-file --filters converts to worktree version' ' + git cat-file --filters HEAD:world.txt >actual && + has_cr actual +' + +test_done |