[PATCH 8/9] commit --dry-run: give advice on empty amend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Share code from the non-dry-run case to ensure the output from
"commit --amend --dry-run" matches that from "commit --amend"
on attempts to amend away a commit.  The output had fallen
out of synch in v1.7.1.1~16^2 (2010-06-06).

The only change in output is some extra text to stderr.

Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx>
---
 builtin/commit.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index febefee..9a4ea34 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1016,7 +1016,14 @@ static int dry_run_commit(int argc, const char **argv, const char *prefix,
 	const char *index_file;
 
 	index_file = prepare_index(argc, argv, prefix, 1);
-	commitable = run_status(stdout, index_file, prefix, 0, s);
+
+	/*
+	 * Give extra advice when faced with attempts to amend away a commit.
+	 */
+	if (!something_is_staged() && !empty_commit_ok(index_file, prefix, s))
+		commitable = 0;
+	else
+		commitable = run_status(stdout, index_file, prefix, 0, s);
 	rollback_index_files();
 
 	return commitable ? 0 : 1;
-- 
1.7.2.9.ge3789.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]