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

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

From
Miklos Vajna <vmiklos@frugalware.org>
Date
May 15, 2008, 16:20 UTC
Message-ID
<1210868459-9511-1-git-send-email-vmiklos@frugalware.org>
In-Reply-To
<482C5FF8.1060200@isy.liu.se>
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?
 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;
 	}
 
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)"
+
+'
+
 test_expect_success 'add everything changed' '
 
 	git add -u &&
-- 
1.5.5.1.211.g65ea3.dirty
Previous: Gustaf HendebyNext: Gustaf Hendeby
Message 2 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.