Re: [PATCH 3/6] branch: teach --edit-description option
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Sep 23, 2011, 09:47 UTC
- Message-ID
- <20110923094721.GA8397@duynguyen-vnpc>
- In-Reply-To
- <1316729362-7714-4-git-send-email-gitster@pobox.com>
On Thu, Sep 22, 2011 at 03:09:19PM -0700, Junio C Hamano wrote:
Show 8 quoted lines
> + if (launch_editor(git_path(edit_description), &buf, NULL)) {
> + strbuf_release(&buf);
> + return -1;
> + }
> + stripspace(&buf, 1);
> +
> + strbuf_addf(&name, "branch.%s.description", branch_name);
> + status = git_config_set(name.buf, buf.buf);I suppose a Windows editor mave save the description with \r\n ending. Perhaps a patch like this to avoid messing up config file?
--8<-- Subject: [PATCH] config: quote \r in value
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> --- config.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/config.c b/config.c index 4183f80..2e238ac 100644 --- a/config.c +++ b/config.c @@ -165,6 +165,9 @@ static char *parse_value(void) case 'b': c = '\b'; break; + case 'r': + c = '\r'; + break; case 'n': c = '\n'; break; @@ -1048,6 +1051,9 @@ static int store_write_pair(int fd, const char *key, const char *value) for (i = 0; value[i]; i++) switch (value[i]) { + case '\r': + strbuf_addstr(&sb, "\\r"); + break; case '\n': strbuf_addstr(&sb, "\\n"); break;
-- 1.7.3.1.256.g2539c.dirty --8<--