From: Johannes Sixt <j6t@kdbg.org>
To: dturner@twopensource.com
Cc: git@vger.kernel.org, David Turner <dturner@twitter.com>
Subject: Re: [PATCH v3 3/3] cat-file: add --follow-symlinks to --batch
Date: Sun, 10 May 2015 09:06:32 +0200 [thread overview]
Message-ID: <554F0378.2070803@kdbg.org> (raw)
In-Reply-To: <1431203769-11855-3-git-send-email-dturner@twopensource.com>
Am 09.05.2015 um 22:36 schrieb dturner@twopensource.com:
> diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
> index ab36b1e..dd80c08 100755
> --- a/t/t1006-cat-file.sh
> +++ b/t/t1006-cat-file.sh
> @@ -189,6 +189,13 @@ do
> '
> done
>
> +for opt in t s e p
> +do
> + test_expect_success "Passing -$opt with --follow-symlinks fails" '
> + test_must_fail git cat-file --follow-symlinks -$opt $hello_sha1
> + '
> +done
> +
> test_expect_success "--batch-check for a non-existent named object" '
> test "foobar42 missing
> foobar84 missing" = \
> @@ -296,4 +303,187 @@ test_expect_success '%(deltabase) reports packed delta bases' '
> }
> '
>
> +# Tests for git cat-file --follow-symlinks
> +test_expect_success 'prep for symlink tests' '
> + echo_without_newline "$hello_content" > morx &&
> + ln -s morx same-dir-link &&
> + ln -s ../fleem out-of-repo-link &&
> + ln -s .. out-of-repo-link-dir &&
> + ln -s same-dir-link link-to-link &&
> + ln -s nope broken-same-dir-link &&
> + mkdir dir &&
> + ln -s ../morx dir/parent-dir-link &&
> + ln -s .. dir/link-dir &&
> + ln -s ../../escape dir/out-of-repo-link &&
> + ln -s ../.. dir/out-of-repo-link-dir &&
> + ln -s nope dir/broken-link-in-dir &&
> + mkdir dir/subdir &&
> + ln -s ../../morx dir/subdir/grandparent-dir-link &&
> + ln -s ../../../great-escape dir/subdir/out-of-repo-link &&
> + ln -s ../../.. dir/subdir/out-of-repo-link-dir &&
> + ln -s ../../../ dir/subdir/out-of-repo-link-dir-trailing &&
> + ln -s ../parent-dir-link dir/subdir/parent-dir-link-to-link &&
> + echo_without_newline "$hello_content" >dir/subdir/ind2 &&
> + echo_without_newline "$hello_content" >dir/ind1 &&
> + ln -s dir dirlink &&
> + ln -s dir/subdir subdirlink &&
> + ln -s subdir/ind2 dir/link-to-child &&
> + ln -s dir/link-to-child link-to-down-link &&
> + ln -s dir/.. up-down &&
> + ln -s dir/../ up-down-trailing &&
> + ln -s dir/../morx up-down-file &&
> + ln -s dir/../../morx up-up-down-file &&
> + ln -s subdirlink/../../morx up-two-down-file &&
> + ln -s loop1 loop2 &&
> + ln -s loop2 loop1 &&
> + git add . &&
> + git commit -am "test"
> +'
These tests will fail on a file system that does not support symbolic
links, such as on Windows. Would you please separate the test cases
(that come after the setup) into two groups:
1. Those that inspect the filesystem and expect a symbolic link. Protect
these tests with a SYMLINKS prerequisite.
2. Those that look only at repository or index contents and do not
require a symbolic link on the file system. These do not need to be
protected.
Note that you do not require a symlink enabled file system to generate a
repository with symlinks, i.e., you don't have to protect the setup code
with SYMLINKS. For this, you can use 'test_ln_s_add' instead of the
above sequence of 'ln -s' followed by a single 'git add .'.
> +
> +echo $hello_sha1 blob $hello_size > found
This seems to be used only in the next test. Please move it inside
test_expect_success.
> +
> +test_expect_success 'git cat-file --batch-check --follow-symlinks works for non-links' '
> + echo HEAD:morx | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp found actual &&
> + echo HEAD:nope missing > expect &&
> + echo HEAD:nope | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'git cat-file --batch-check --follow-symlinks works for in-repo, same-dir links' '
> + echo HEAD:same-dir-link | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp found actual
> +'
> +
> +test_expect_success 'git cat-file --batch-check --follow-symlinks works for broken in-repo, same-dir links' '
> + echo HEAD:broken-same-dir-link missing > expect &&
> + echo HEAD:broken-same-dir-link | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'git cat-file --batch-check --follow-symlinks works for same-dir links-to-links' '
> + echo HEAD:link-to-link | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp found actual
> +'
> +
> +test_expect_success 'git cat-file --batch-check --follow-symlinks works for parent-dir links' '
> + echo HEAD:dir/parent-dir-link | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp found actual &&
> + echo HEAD:dir/parent-dir-link/nope missing > expect &&
> + echo HEAD:dir/parent-dir-link/nope | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'git cat-file --batch-check --follow-symlinks works for .. links' '
> + echo HEAD:dir/link-dir/nope missing > expect &&
> + echo HEAD:dir/link-dir/nope | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual &&
> + echo HEAD:dir/link-dir/morx | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp found actual &&
> + echo HEAD:dir/broken-link-in-dir missing > expect &&
> + echo HEAD:dir/broken-link-in-dir | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'git cat-file --batch-check --follow-symlinks works for ../.. links' '
> + echo HEAD:dir/subdir/grandparent-dir-link/nope missing > expect &&
> + echo HEAD:dir/subdir/grandparent-dir-link/nope | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual &&
> + echo HEAD:dir/subdir/grandparent-dir-link | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp found actual &&
> + echo HEAD:dir/subdir/parent-dir-link-to-link | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp found actual
> +'
> +
> +test_expect_success 'git cat-file --batch-check --follow-symlinks works for dir/ links' '
> + echo HEAD:dirlink/morx missing > expect &&
> + echo HEAD:dirlink/morx | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual &&
> + echo $hello_sha1 blob $hello_size > expect &&
> + echo HEAD:dirlink/ind1 | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'git cat-file --batch-check --follow-symlinks works for dir/subdir links' '
> + echo HEAD:subdirlink/morx missing > expect &&
> + echo HEAD:subdirlink/morx | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual &&
> + echo HEAD:subdirlink/ind2 | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp found actual
> +'
> +
> +test_expect_success 'git cat-file --batch-check --follow-symlinks works for dir -> subdir links' '
> + echo HEAD:dir/link-to-child/morx missing > expect &&
> + echo HEAD:dir/link-to-child/morx | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual &&
> + echo HEAD:dir/link-to-child | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp found actual &&
> + echo HEAD:link-to-down-link | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp found actual
> +'
> +
> +test_expect_success 'git cat-file --batch-check --follow-symlinks works for out-of-repo symlinks' '
> + echo symlink 8 > expect &&
> + echo ../fleem >> expect &&
> + echo HEAD:out-of-repo-link | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual &&
> + echo symlink 2 > expect &&
> + echo .. >> expect &&
> + echo HEAD:out-of-repo-link-dir | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'git cat-file --batch-check --follow-symlinks works for out-of-repo symlinks in dirs' '
> + echo symlink 9 > expect &&
> + echo ../escape >> expect &&
> + echo HEAD:dir/out-of-repo-link | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual &&
> + echo symlink 2 > expect &&
> + echo .. >> expect &&
> + echo HEAD:dir/out-of-repo-link-dir | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'git cat-file --batch-check --follow-symlinks works for out-of-repo symlinks in subdirs' '
> + echo symlink 15 > expect &&
> + echo ../great-escape >> expect &&
> + echo HEAD:dir/subdir/out-of-repo-link | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual &&
> + echo symlink 2 > expect &&
> + echo .. >> expect &&
> + echo HEAD:dir/subdir/out-of-repo-link-dir | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual &&
> + echo symlink 3 > expect &&
> + echo ../ >> expect &&
> + echo HEAD:dir/subdir/out-of-repo-link-dir-trailing | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'git cat-file --batch-check --follow-symlinks works for symlinks with internal ..' '
> + echo HEAD: | git cat-file --batch-check > expect &&
> + echo HEAD:up-down | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual &&
> + echo HEAD:up-down-trailing | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual &&
> + echo HEAD:up-down-file | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp found actual &&
> + echo symlink 7 > expect &&
> + echo ../morx >> expect &&
> + echo HEAD:up-up-down-file | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual &&
> + echo HEAD:up-two-down-file | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp found actual
> +'
> +
> +test_expect_success 'git cat-file --batch-check --follow-symlink breaks loops' '
> + echo HEAD:loop1 missing > expect &&
> + echo HEAD:loop1 | git cat-file --batch-check --follow-symlinks > actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'git cat-file --batch --follow-symlink returns correct sha and mode' '
> + echo HEAD:morx | git cat-file --batch > expect &&
> + echo HEAD:morx | git cat-file --batch --follow-symlinks > actual &&
> + test_cmp expect actual
> +'
> test_done
>
-- Hannes
next prev parent reply other threads:[~2015-05-10 7:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-09 20:36 [PATCH v3 1/3] tree-walk: learn get_tree_entry_follow_symlinks dturner
2015-05-09 20:36 ` [PATCH v3 2/3] sha1_name: get_sha1_with_context learns to follow symlinks dturner
2015-05-10 17:47 ` Junio C Hamano
2015-05-09 20:36 ` [PATCH v3 3/3] cat-file: add --follow-symlinks to --batch dturner
2015-05-10 7:06 ` Johannes Sixt [this message]
2015-05-11 17:03 ` David Turner
2015-05-11 17:45 ` Junio C Hamano
2015-05-10 17:42 ` [PATCH v3 1/3] tree-walk: learn get_tree_entry_follow_symlinks 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=554F0378.2070803@kdbg.org \
--to=j6t@kdbg.org \
--cc=dturner@twitter.com \
--cc=dturner@twopensource.com \
--cc=git@vger.kernel.org \
/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).