Teach read-tree the -n|--dry-run option
The option can be used to check if read-tree with the same set of other options like "-m" and "-u" would succeed without actually changing either the index or the working tree. The relevant tests in the t10?? range were extended to do a read-tree -n before the real read-tree to make sure neither the index nor any local files were changed with -n and the same exit code as without -n is returned. The helper functions added for that purpose reside in the new t/lib-read-tree.sh file. The only exception is #13 in t1004 ("unlinking an un-unlink-able symlink"). As this is an issue of wrong directory permissions it is not detected with -n. Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
2c9078d05b
commit
ea5070c91f
@ -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(&opts.dry_run, "don't update the index or the work tree"),
|
||||
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,
|
||||
@ -219,7 +220,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 || opts.dry_run)
|
||||
return 0; /* do not write the index out */
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user