git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Sahil Dua" <sahildua2305@gmail.com>,
	"Jonathan Nieder" <jrnieder@gmail.com>,
	"Michael Haggerty" <mhagger@alum.mit.edu>,
	"Brandon Williams" <bmwill@google.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Ramsay Jones" <ramsay@ramsayjones.plus.com>
Subject: [PATCH v2 1/3] config: create a function to format section headers
Date: Wed,  5 Jul 2017 23:14:52 +0000	[thread overview]
Message-ID: <20170705231454.15666-2-avarab@gmail.com> (raw)
In-Reply-To: <20170705231454.15666-1-avarab@gmail.com>
In-Reply-To: <xmqqeftuh5q7.fsf@gitster.mtv.corp.google.com>

From: Sahil Dua <sahildua2305@gmail.com>

Factor out the logic which creates section headers in the config file,
e.g. the 'branch.foo' key will be turned into '[branch "foo"]'.

This introduces no function changes, but is needed for a later change
which adds support for copying branch sections in the config file.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Sahil Dua <sahildua2305@gmail.com>
---
 config.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/config.c b/config.c
index 4638b0696a..b7afb5941b 100644
--- a/config.c
+++ b/config.c
@@ -2244,10 +2244,10 @@ static int write_error(const char *filename)
 	return 4;
 }
 
-static int store_write_section(int fd, const char *key)
+static struct strbuf store_create_section(const char *key)
 {
 	const char *dot;
-	int i, success;
+	int i;
 	struct strbuf sb = STRBUF_INIT;
 
 	dot = memchr(key, '.', store.baselen);
@@ -2263,6 +2263,15 @@ static int store_write_section(int fd, const char *key)
 		strbuf_addf(&sb, "[%.*s]\n", store.baselen, key);
 	}
 
+	return sb;
+}
+
+static int store_write_section(int fd, const char *key)
+{
+	int success;
+
+	struct strbuf sb = store_create_section(key);
+
 	success = write_in_full(fd, sb.buf, sb.len) == sb.len;
 	strbuf_release(&sb);
 
-- 
2.13.1.611.g7e3b11ae1


  parent reply	other threads:[~2017-07-05 23:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-05 22:35 What's cooking in git.git (Jul 2017, #01; Wed, 5) Junio C Hamano
2017-07-05 23:06 ` Stefan Beller
2017-07-07  2:13   ` Junio C Hamano
2017-07-10 17:27     ` Stefan Beller
2017-07-05 23:14 ` [PATCH v2 0/3] branch: add a --copy to go with --move Ævar Arnfjörð Bjarmason
2017-07-06  0:37   ` Junio C Hamano
2017-09-22  4:57     ` [PATCH 4/3] branch: fix "copy" to never touch HEAD Junio C Hamano
2017-09-22 16:33       ` Brandon Williams
2017-09-26 21:39       ` Ævar Arnfjörð Bjarmason
2017-09-27  2:02         ` Junio C Hamano
2017-09-29 18:30           ` Ævar Arnfjörð Bjarmason
2017-07-05 23:14 ` Ævar Arnfjörð Bjarmason [this message]
2017-07-05 23:14 ` [PATCH v2 2/3] branch: add test for -m renaming multiple config sections Ævar Arnfjörð Bjarmason
2017-07-05 23:14 ` [PATCH v2 3/3] branch: add a --copy (-c) option to go with --move (-m) Ævar Arnfjörð Bjarmason
  -- strict thread matches above, loose matches on Subject: below --
2017-06-13 16:17 [PATCH 1/3] config: create a function to format section headers Sahil Dua
2017-06-18 21:16 ` [PATCH v2 " Sahil Dua
2017-06-19 12:08   ` Ramsay Jones
2017-06-19 14:51     ` Sahil Dua

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20170705231454.15666-2-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=mhagger@alum.mit.edu \
    --cc=ramsay@ramsayjones.plus.com \
    --cc=sahildua2305@gmail.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).