git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gustaf Hendeby <hendeby@isy.liu.se>
To: Miklos Vajna <vmiklos@frugalware.org>
Cc: Junio C Hamano <gitster@pobox.com>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] Make git add -u honor --dry-run
Date: Thu, 15 May 2008 20:46:45 +0200	[thread overview]
Message-ID: <482C8515.6020303@isy.liu.se> (raw)
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 <vmiklos@frugalware.org>
> ---
> 
> On Thu, May 15, 2008 at 06:08:24PM +0200, Gustaf Hendeby <hendeby@isy.liu.se> 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 &&

  reply	other threads:[~2008-05-15 18:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-15 16:08 [BUG] git add -u ignores --dry-run flag Gustaf Hendeby
2008-05-15 16:20 ` [PATCH] Make git add -u honor --dry-run Miklos Vajna
2008-05-15 18:46   ` Gustaf Hendeby [this message]
2008-05-15 23:42   ` Re* " Junio C Hamano
2008-05-16  0:13     ` Miklos Vajna
2008-05-19 22:14     ` Gustaf Hendeby
2008-05-22 18:16       ` Junio C Hamano
2008-05-22 19:34         ` Gustaf Hendeby
2008-05-22 20:38           ` Junio C Hamano
2008-05-22 21:12             ` Gustaf Hendeby
2008-05-22 21:59               ` [PATCH] Make git add -n and git -u -n output consistent Gustaf Hendeby
2008-05-23  4:40                 ` Junio C Hamano
2008-05-23  8:14                   ` Gustaf Hendeby

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=482C8515.6020303@isy.liu.se \
    --to=hendeby@isy.liu.se \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=vmiklos@frugalware.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).