From: Gustaf Hendeby Date: Thu, 15 May 2008 18:46:45 GMT Subject: Re: [PATCH] Make git add -u honor --dry-run Message-ID: <482C8515.6020303@isy.liu.se> In-Reply-To: <1210868459-9511-1-git-send-email-vmiklos@frugalware.org> On 2008-05-15 18:20, Miklos Vajna wrote: > Signed-off-by: Miklos Vajna > --- > > On Thu, May 15, 2008 at 06:08:24PM +0200, Gustaf Hendeby wrote: >> I'm not familiar enough with the code to see how to best fix it. > > Something like this? This fixes part of the problem. Nothing gets written to the index now, however, I get no list of what files would have been added. That is what I would have suspected. Am I reading the docs incorrectly? > > builtin-add.c | 3 ++- > t/t2200-add-update.sh | 7 +++++++ > 2 files changed, 9 insertions(+), 1 deletions(-) > > diff --git a/builtin-add.c b/builtin-add.c > index 4a91e3e..222497d 100644 > --- a/builtin-add.c > +++ b/builtin-add.c > @@ -212,7 +212,8 @@ int cmd_add(int argc, const char **argv, const char *prefix) > if (read_cache() < 0) > die("index file corrupt"); > pathspec = get_pathspec(prefix, argv); > - add_files_to_cache(verbose, prefix, pathspec); > + if(!show_only) > + add_files_to_cache(verbose, prefix, pathspec); > goto finish; > } Since the other code path for show_only, does not end up in finish but returns 0 directly, I'm assuming the same could be done here (after printing the changed files) to save some cycles. > > diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh > index b664341..13ad975 100755 > --- a/t/t2200-add-update.sh > +++ b/t/t2200-add-update.sh > @@ -88,6 +88,13 @@ test_expect_success 'replace a file with a symlink' ' > > ' > > +test_expect_success 'add everything changed with --dry-run' ' > + > + git add -u --dry-run && > + test -n "$(git diff-files)" Don't you need to validate the output from git add -u --dry-run too? /Gustaf > + > +' > + > test_expect_success 'add everything changed' ' > > git add -u &&