From: Jens Lehmann <Jens.Lehmann@web.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] Teach checkout the -n|--dry-run option
Date: Sun, 08 May 2011 22:50:08 +0200 [thread overview]
Message-ID: <4DC70200.1080201@web.de> (raw)
In-Reply-To: <4DC67CF4.80901@web.de>
Am 08.05.2011 13:22, schrieb Jens Lehmann:
> Am 07.05.2011 21:24, schrieb Junio C Hamano:
>> We may also want to add "read-tree -n" so that you do not have to specify
>> a dummy index output only to prevent from writing the real index over,
>> though.
>
> Hmm, wouldn't using "read-tree --index-output=/dev/null" be equivalent to
> "read-tree -n"? But nonetheless it might make sense to add the -n option.
No idea how I could manage to test "read-tree --index-output=/dev/null"
successfully without getting an "unable to write new index file" error.
But using read-tree works for me, so what about something like this,
maybe with some more tests?
-------------8<---------------
Subject: [PATCH] Teach read-tree the -n|--dry-run option
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 it.
As using --dry-run is expected to have no side effects, this option makes
no sense together with "-u".
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
---
Documentation/git-read-tree.txt | 5 +++++
builtin/read-tree.c | 7 +++++--
t/t1000-read-tree-m-3way.sh | 2 ++
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-read-tree.txt b/Documentation/git-read-tree.txt
index 26fdadc..a35849f 100644
--- a/Documentation/git-read-tree.txt
+++ b/Documentation/git-read-tree.txt
@@ -53,6 +53,11 @@ OPTIONS
trees that are not directly related to the current
working tree status into a temporary index file.
+-n::
+--dry-run::
+ Don't write the index file. This option isn't allowed together
+ with -u.
+
-v::
Show the progress of checking files out.
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 93c9281..693576f 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -98,7 +98,7 @@ static struct lock_file lock_file;
int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
{
- int i, newfd, stage = 0;
+ int i, newfd, stage = 0, dry_run = 0;
unsigned char sha1[20];
struct tree_desc t[MAX_UNPACK_TREES];
struct unpack_trees_options opts;
@@ -130,6 +130,7 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
PARSE_OPT_NONEG, exclude_per_directory_cb },
OPT_SET_INT('i', NULL, &opts.index_only,
"don't check the working tree after merging", 1),
+ OPT__DRY_RUN(&dry_run, "don't update the index"),
OPT_SET_INT(0, "no-sparse-checkout", &opts.skip_sparse_checkout,
"skip applying sparse checkout filter", 1),
OPT_SET_INT(0, "debug-unpack", &opts.debug_unpack,
@@ -183,6 +184,8 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
die("--exclude-per-directory is meaningless unless -u");
if (opts.merge && !opts.index_only)
setup_work_tree();
+ if (opts.update && dry_run)
+ die("--dry-run contradicts -u");
if (opts.merge) {
if (stage < 2)
@@ -219,7 +222,7 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
if (unpack_trees(nr_trees, t, &opts))
return 128;
- if (opts.debug_unpack)
+ if (opts.debug_unpack || dry_run)
return 0; /* do not write the index out */
/*
diff --git a/t/t1000-read-tree-m-3way.sh b/t/t1000-read-tree-m-3way.sh
index ca8a409..bcfb5e6 100755
--- a/t/t1000-read-tree-m-3way.sh
+++ b/t/t1000-read-tree-m-3way.sh
@@ -259,6 +259,8 @@ test_expect_success \
"rm -f .git/index AA &&
cp .orig-A/AA AA &&
git update-index --add AA &&
+ git read-tree -n -m $tree_O $tree_A $tree_B &&
+ test_must_fail check_result &&
git read-tree -m $tree_O $tree_A $tree_B &&
check_result"
--
1.7.5.1.218.g8af57
next prev parent reply other threads:[~2011-05-08 20:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-06 22:12 [PATCH] Teach checkout the -n|--dry-run option Jens Lehmann
2011-05-06 22:49 ` Junio C Hamano
2011-05-07 19:24 ` Junio C Hamano
2011-05-08 11:22 ` Jens Lehmann
2011-05-08 20:50 ` Jens Lehmann [this message]
2011-05-08 21:30 ` Junio C Hamano
2011-05-08 21:41 ` Jens Lehmann
2011-05-11 21:50 ` [PATCH] Teach read-tree " Jens Lehmann
2011-05-11 22:47 ` 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=4DC70200.1080201@web.de \
--to=jens.lehmann@web.de \
--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).