Skip to content

Commit

Permalink
unpack-trees: add the dry_run flag to unpack_trees_options
Browse files Browse the repository at this point in the history
Until now there was no way to test if unpack_trees() with update=1 would
succeed without really updating the work tree. The reason for that is that
setting update to 0 does skip the tests for new files and deactivates the
sparse handling, thereby making that unsuitable as a dry run.

Add the new dry_run flag to struct unpack_trees_options unpack_trees().
Setting that together with the update flag will check if the work tree
update would be successful without doing it for real.

The only class of problems that is not detected at the moment are file
system conditions like ENOSPC or missing permissions. Also the index
entries of updated files are not as they would be after a real checkout
because lstat() isn't run as the files aren't updated for real.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
jlehmann authored and gitster committed May 25, 2011
1 parent 5df3e2b commit 2c9078d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions unpack-trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ static int check_updates(struct unpack_trees_options *o)

if (ce->ce_flags & CE_WT_REMOVE) {
display_progress(progress, ++cnt);
if (o->update)
if (o->update && !o->dry_run)
unlink_entry(ce);
continue;
}
Expand All @@ -217,7 +217,7 @@ static int check_updates(struct unpack_trees_options *o)
if (ce->ce_flags & CE_UPDATE) {
display_progress(progress, ++cnt);
ce->ce_flags &= ~CE_UPDATE;
if (o->update) {
if (o->update && !o->dry_run) {
errs |= checkout_entry(ce, &state, NULL);
}
}
Expand Down
3 changes: 2 additions & 1 deletion unpack-trees.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ struct unpack_trees_options {
debug_unpack,
skip_sparse_checkout,
gently,
show_all_errors;
show_all_errors,
dry_run;
const char *prefix;
int cache_bottom;
struct dir_struct *dir;
Expand Down

0 comments on commit 2c9078d

Please sign in to comment.