[PATCH v2 3/4] builtin/commit: suggest update-ref for pseudoref removal

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

 



From: Han-Wen Nienhuys <hanwen@xxxxxxxxxx>

When pseudorefs move to a different ref storage mechanism, pseudorefs no longer
can be removed with 'rm'. Instead, suggest a "update-ref -d" command, which will
work regardless of ref storage backend.

Signed-off-by: Han-Wen Nienhuys <hanwen@xxxxxxxxxx>
---
 builtin/commit.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 69ac78d5e5..a4e5e395ba 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -844,24 +844,24 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		struct ident_split ci, ai;
 
 		if (whence != FROM_COMMIT) {
+			const char *pseudoref = (whence == FROM_MERGE) ?
+							      "MERGE_HEAD" :
+							      "CHERRY_PICK_HEAD";
+			const char *what = (whence == FROM_MERGE) ?
+							 "merge" :
+							 "cherry-pick";
+
 			if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS &&
 				!merge_contains_scissors)
 				wt_status_add_cut_line(s->fp);
-			status_printf_ln(s, GIT_COLOR_NORMAL,
-			    whence == FROM_MERGE
-				? _("\n"
-					"It looks like you may be committing a merge.\n"
-					"If this is not correct, please remove the file\n"
-					"	%s\n"
-					"and try again.\n")
-				: _("\n"
-					"It looks like you may be committing a cherry-pick.\n"
-					"If this is not correct, please remove the file\n"
-					"	%s\n"
-					"and try again.\n"),
-				whence == FROM_MERGE ?
-					git_path_merge_head(the_repository) :
-					git_path_cherry_pick_head(the_repository));
+			status_printf_ln(
+				s, GIT_COLOR_NORMAL,
+				_("\n"
+				  "It looks like you may be committing a %s.\n"
+				  "If this is not correct, please remove %s with\n"
+				  "	git update-ref -d %s\n"
+				  "and try again.\n"),
+				what, pseudoref, pseudoref);
 		}
 
 		fprintf(s->fp, "\n");
-- 
gitgitgadget




[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]

  Powered by Linux