From: Junio C Hamano <gitster@pobox.com>
To: Jens Lehmann <Jens.Lehmann@web.de>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] Teach read-tree the -n|--dry-run option
Date: Wed, 25 May 2011 15:30:02 -0700 [thread overview]
Message-ID: <7vaaea1kid.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: 4DDD6241.8070908@web.de
Jens Lehmann <Jens.Lehmann@web.de> writes:
> Using this option tells read-tree to not update the index. That makes it
> possible to check if updating the index would be successful without
> changing anything. Using this option will silently ignore -u but still
> test if updating the work tree would succeed.
I'll reword the above to de-stress "the index" when I queue this patch, as
this is not about the index anymore. Also I do not think you "silently
ignore" the "-u" option. Don't you check what would happen when "-u" is
given and checking out the merge result would overwrite the file in the
working tree? In that scenario, "-u" actively participates in the dry-run
check you implemented.
> diff --git a/t/lib-read-tree.sh b/t/lib-read-tree.sh
> new file mode 100644
> index 0000000..435d19c
> --- /dev/null
> +++ b/t/lib-read-tree.sh
> @@ -0,0 +1,43 @@
> +#!/bin/sh
> +#
> +# Helper functions to check if read-tree would succeed/fail as expected with
> +# and without the dry-run option. They also test that the dry-run does not
> +# write the index and that together with -u it doesn't touch the work tree.
> +#
> ...
> +read_tree_u_must_succeed () {
> + git ls-files -s >pre-dry-run &&
> + git diff-files >pre-dry-run-wt &&
> + git read-tree -n "$@" &&
> + git ls-files -s >post-dry-run &&
> + git diff-files >post-dry-run-wt &&
> + test_cmp pre-dry-run post-dry-run &&
> + test_cmp pre-dry-run-wt post-dry-run-wt &&
As the RHS of diff-files output that represent the working tree status
indicates "contents indeterminate" with 0{40}, this comparison is the same
as comparing what is in the index before and after the dry-run.
> ...
> +read_tree_u_must_fail () {
> + git ls-files -s >pre-dry-run &&
> + git diff-files >pre-dry-run-wt &&
> + test_must_fail git read-tree -n "$@" &&
> + git ls-files -s >post-dry-run &&
> + git diff-files >post-dry-run-wt &&
> + test_cmp pre-dry-run post-dry-run &&
> + test_cmp pre-dry-run-wt post-dry-run-wt &&
> + test_must_fail git read-tree "$@"
> +}
Same here. A few additions of -p will trivially fix them, though.
diff --git a/t/lib-read-tree.sh b/t/lib-read-tree.sh
index 435d19c..abc2c6f 100644
--- a/t/lib-read-tree.sh
+++ b/t/lib-read-tree.sh
@@ -22,10 +22,10 @@ read_tree_must_fail () {
read_tree_u_must_succeed () {
git ls-files -s >pre-dry-run &&
- git diff-files >pre-dry-run-wt &&
+ git diff-files -p >pre-dry-run-wt &&
git read-tree -n "$@" &&
git ls-files -s >post-dry-run &&
- git diff-files >post-dry-run-wt &&
+ git diff-files -p >post-dry-run-wt &&
test_cmp pre-dry-run post-dry-run &&
test_cmp pre-dry-run-wt post-dry-run-wt &&
git read-tree "$@"
@@ -33,10 +33,10 @@ read_tree_u_must_succeed () {
read_tree_u_must_fail () {
git ls-files -s >pre-dry-run &&
- git diff-files >pre-dry-run-wt &&
+ git diff-files -p >pre-dry-run-wt &&
test_must_fail git read-tree -n "$@" &&
git ls-files -s >post-dry-run &&
- git diff-files >post-dry-run-wt &&
+ git diff-files -p >post-dry-run-wt &&
test_cmp pre-dry-run post-dry-run &&
test_cmp pre-dry-run-wt post-dry-run-wt &&
test_must_fail git read-tree "$@"
prev parent reply other threads:[~2011-05-25 22:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-24 21:07 [RFC PATCH] unpack-trees: add the dry_run flag to unpack_trees_options Jens Lehmann
2011-05-24 23:18 ` Junio C Hamano
2011-05-25 20:06 ` [PATCH v2 0/2] Teach read-tree the -n|--dry-run option Jens Lehmann
2011-05-25 20:07 ` [PATCH v2 1/2] unpack-trees: add the dry_run flag to unpack_trees_options Jens Lehmann
2011-05-25 21:36 ` Junio C Hamano
2011-05-25 20:10 ` [PATCH v2 2/2] Teach read-tree the -n|--dry-run option Jens Lehmann
2011-05-25 22:30 ` Junio C Hamano [this message]
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=7vaaea1kid.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=Jens.Lehmann@web.de \
--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).