git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Make git add -u honor --dry-run

From
Gustaf Hendeby <hendeby@isy.liu.se>
Date
May 15, 2008, 18:46 UTC
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:
Show 7 quoted lines
> 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?

Show 18 quoted lines
> 
>  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.

Show 13 quoted lines
>  
> 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
Show 6 quoted lines
> +
> +'
> +
>  test_expect_success 'add everything changed' '
>  
>  	git add -u &&
Previous: Miklos VajnaNext: Junio C Hamano
Message 3 of 13 in “[BUG] git add -u ignores --dry-run flag”
  1. Gustaf HendebyMay 15, 2008
  2. Make git add -u honor --dry-runMiklos Vajna, May 15, 2008
  3. Gustaf HendebyMay 15, 2008
  4. Re* [PATCH] Make git add -u honor --dry-runJunio C Hamano, May 15, 2008
  5. Miklos VajnaMay 16, 2008
  6. Gustaf HendebyMay 19, 2008
  7. Junio C HamanoMay 22, 2008
  8. Gustaf HendebyMay 22, 2008
  9. Junio C HamanoMay 22, 2008
  10. Gustaf HendebyMay 22, 2008
  11. Make git add -n and git -u -n output consistentGustaf Hendeby, May 22, 2008
  12. Junio C HamanoMay 23, 2008
  13. Gustaf HendebyMay 23, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.