git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kacper Kornet <draenog@pld-linux.org>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Aaron Schrab <aaron@schrab.com>,
	Kacper Kornet <draenog@pld-linux.org>
Subject: [PATCH v2 2/3] Allow for MERGE_MODE to specify more then one mode
Date: Wed, 28 Nov 2012 00:00:16 +0100	[thread overview]
Message-ID: <1354057217-65886-3-git-send-email-draenog@pld-linux.org> (raw)
In-Reply-To: <1354057217-65886-1-git-send-email-draenog@pld-linux.org>

Presently only one merge mode exists: non-fast-forward. But in future
the second one (transpose-parents) will be added, so the need to read
all lines of MERGE_MODE.

Signed-off-by: Kacper Kornet <draenog@pld-linux.org>
---
 builtin/commit.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 273332f..ee0e884 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1427,7 +1427,6 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	unsigned char sha1[20];
 	struct ref_lock *ref_lock;
 	struct commit_list *parents = NULL, **pptr = &parents;
-	struct stat statbuf;
 	int allow_fast_forward = 1;
 	struct commit *current_head = NULL;
 	struct commit_extra_header *extra = NULL;
@@ -1481,11 +1480,12 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 
 		if (!reflog_msg)
 			reflog_msg = "commit (merge)";
-		if (!stat(git_path("MERGE_MODE"), &statbuf)) {
-			if (strbuf_read_file(&sb, git_path("MERGE_MODE"), 0) < 0)
-				die_errno(_("could not read MERGE_MODE"));
-			if (!strcmp(sb.buf, "no-ff"))
-				allow_fast_forward = 0;
+		if((fp = fopen(git_path("MERGE_MODE"), "r"))) {
+			while (strbuf_getline(&m, fp, '\n') != EOF) {
+				if (!strcmp(m.buf, "no-ff"))
+					allow_fast_forward = 0;
+			}
+			fclose(fp);
 		}
 		pptr = &commit_list_insert(current_head, pptr)->next;
 		fp = fopen(git_path("MERGE_HEAD"), "r");
-- 
1.8.0.1

  parent reply	other threads:[~2012-11-27 23:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-27 23:00 [PATCH v2 0/3] Add option to change order of parents in merge commit Kacper Kornet
2012-11-27 23:00 ` [PATCH v2 1/3] Process MERGE_MODE before MERGE_HEAD Kacper Kornet
2012-11-27 23:00 ` Kacper Kornet [this message]
2012-11-28  2:17   ` [PATCH v2 2/3] Allow for MERGE_MODE to specify more then one mode Junio C Hamano
2012-11-28  4:36     ` Kacper Kornet
2012-11-28  7:30       ` Junio C Hamano
2012-11-27 23:00 ` [PATCH v2 3/3] Add option to transpose parents of merge commit Kacper Kornet
2012-11-28  2:18   ` Junio C Hamano
2012-11-28  4:43     ` Kacper Kornet
2012-11-28  6:56   ` Johannes Sixt
2012-11-28 16:52     ` 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=1354057217-65886-3-git-send-email-draenog@pld-linux.org \
    --to=draenog@pld-linux.org \
    --cc=aaron@schrab.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).