All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 1/3] commit/status: check $GIT_DIR/MERGE_HEAD only once
Date: Sat, 12 Dec 2009 01:02:01 -0800	[thread overview]
Message-ID: <1260608523-15579-2-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1260608523-15579-1-git-send-email-gitster@pobox.com>

The code checked for the MERGE_HEAD file to see if we were about
to commit a merge twice in the codepath; also one of them used a
variable merge_head_sha1[] which was set but was never used.

Just check it once, but do so also in "git status", too, as
we will be using this for status generation in the next patch.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin-commit.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/builtin-commit.c b/builtin-commit.c
index b39295f..17dd462 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -36,7 +36,7 @@ static const char * const builtin_status_usage[] = {
 	NULL
 };
 
-static unsigned char head_sha1[20], merge_head_sha1[20];
+static unsigned char head_sha1[20];
 static char *use_message_buffer;
 static const char commit_editmsg[] = "COMMIT_EDITMSG";
 static struct lock_file index_lock; /* real index */
@@ -319,7 +319,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
 	 */
 	commit_style = COMMIT_PARTIAL;
 
-	if (file_exists(git_path("MERGE_HEAD")))
+	if (in_merge)
 		die("cannot do a partial commit during a merge.");
 
 	memset(&partial, 0, sizeof(partial));
@@ -758,9 +758,6 @@ static int parse_and_validate_options(int argc, const char *argv[],
 	if (get_sha1("HEAD", head_sha1))
 		initial_commit = 1;
 
-	if (!get_sha1("MERGE_HEAD", merge_head_sha1))
-		in_merge = 1;
-
 	/* Sanity check options */
 	if (amend && initial_commit)
 		die("You have nothing to amend.");
@@ -951,6 +948,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
 
 	wt_status_prepare(&s);
 	git_config(git_status_config, &s);
+	in_merge = file_exists(git_path("MERGE_HEAD"));
 	argc = parse_options(argc, argv, prefix,
 			     builtin_status_options,
 			     builtin_status_usage, 0);
@@ -1057,10 +1055,10 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 
 	wt_status_prepare(&s);
 	git_config(git_commit_config, &s);
+	in_merge = file_exists(git_path("MERGE_HEAD"));
 
 	if (s.use_color == -1)
 		s.use_color = git_use_color_default;
-
 	argc = parse_and_validate_options(argc, argv, builtin_commit_usage,
 					  prefix, &s);
 	if (dry_run) {
-- 
1.6.6.rc2.5.g49666

  reply	other threads:[~2009-12-12  9:02 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-10 23:56 How to selectively recreate merge state? Jay Soffian
2009-12-11  0:04 ` Junio C Hamano
2009-12-11  0:28   ` Jakub Narebski
2009-12-11  1:11     ` Junio C Hamano
2009-12-11  1:33       ` Jakub Narebski
2009-12-11 10:44         ` Michael J Gruber
2009-12-11 11:09           ` Björn Steinbrink
2009-12-11 12:51             ` Thomas Rast
2009-12-11 11:20           ` Jakub Narebski
2009-12-11 12:33             ` Michael J Gruber
2009-12-11 14:00               ` Jakub Narebski
2009-12-11 14:57                 ` Michael J Gruber
2009-12-11 15:35                   ` Junio C Hamano
2009-12-11 19:24                 ` Junio C Hamano
2009-12-11 22:18                   ` Jay Soffian
2009-12-11 23:46                     ` Junio C Hamano
2009-12-12  9:02                       ` [PATCH 0/3] Update advice in commit/status output Junio C Hamano
2009-12-12  9:02                         ` Junio C Hamano [this message]
2009-12-12  9:02                           ` [PATCH 2/3] commit/status: "git add <path>" is not necessarily how to resolve Junio C Hamano
2009-12-12  9:02                             ` [PATCH 3/3] status/commit: do not suggest "reset HEAD <path>" while merging Junio C Hamano
2009-12-12  9:15                             ` [PATCH 2/3] commit/status: "git add <path>" is not necessarily how to resolve Jeff King
2009-12-12  9:24                               ` Junio C Hamano
2009-12-12  9:19                             ` Nanako Shiraishi
2009-12-12 16:13                         ` [PATCH 0/3] Update advice in commit/status output Sverre Rabbelier
2009-12-12 18:27                           ` Junio C Hamano
2009-12-12 22:06                         ` Jay Soffian
2009-12-11 20:38             ` How to selectively recreate merge state? Paolo Bonzini
2009-12-11 21:14               ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1260608523-15579-2-git-send-email-gitster@pobox.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.