Thread (8 messages) flat view 8 messages, 3 authors, 2016-06-15

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

From: Gustaf Hendeby <hidden>
Date: 2016-06-15 22:44:37

On 2008-05-15 18:20, Miklos Vajna wrote:
Signed-off-by: Miklos Vajna <redacted>
---

On Thu, May 15, 2008 at 06:08:24PM +0200, Gustaf Hendeby [off-list ref] wrote:
quoted
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?
quoted hunk ↗ jump to hunk
 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.
quoted hunk ↗ jump to hunk
 
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 &&
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help