From: Johannes Schindelin <johannes.schindelin@gmx.de>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Phillip Wood <phillip.wood@dunelm.org.uk>,
Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Subject: [PATCH] sequencer: assign only free()able strings to gpg_sign
Date: Fri, 22 Dec 2017 12:50:50 +0100 (STD) [thread overview]
Message-ID: <f4420880aa4ee73b7c8e435de1efccf9a969fd41.1513943347.git.johannes.schindelin@gmx.de> (raw)
The gpg_sign member of the replay_opts structure is of type `char *`,
meaning that the sequencer deems the string to which gpg_sign points to
be under its custody, i.e. it needs to be free()d by the sequencer.
Therefore, let's only assign malloc()ed buffers to it.
Reported-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
Phillip, if you want to squash these changes into your patches,
I'd totally fine with that.
Based-On: pw/sequencer-in-process-commit at https://github.com/dscho/git
Fetch-Base-Via: git fetch https://github.com/dscho/git pw/sequencer-in-process-commit
Published-As: https://github.com/dscho/git/releases/tag/sequencer-owns-gpg-sign-v1
Fetch-It-Via: git fetch https://github.com/dscho/git sequencer-owns-gpg-sign-v1
sequencer.c | 2 +-
t/t3404-rebase-interactive.sh | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/sequencer.c b/sequencer.c
index 7051b20b762..1b2599668f5 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -160,7 +160,7 @@ static int git_sequencer_config(const char *k, const char *v, void *cb)
}
if (!strcmp(k, "commit.gpgsign")) {
- opts->gpg_sign = git_config_bool(k, v) ? "" : NULL;
+ opts->gpg_sign = git_config_bool(k, v) ? xstrdup("") : NULL;
return 0;
}
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 9ed0a244e6c..040ef1a4dbc 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -1318,6 +1318,16 @@ test_expect_success 'editor saves as CR/LF' '
SQ="'"
test_expect_success 'rebase -i --gpg-sign=<key-id>' '
+ test_when_finished "test_might_fail git rebase --abort" &&
+ set_fake_editor &&
+ FAKE_LINES="edit 1" git rebase -i --gpg-sign="\"S I Gner\"" HEAD^ \
+ >out 2>err &&
+ test_i18ngrep "$SQ-S\"S I Gner\"$SQ" err
+'
+
+test_expect_success 'rebase -i --gpg-sign=<key-id> overrides commit.gpgSign' '
+ test_when_finished "test_might_fail git rebase --abort" &&
+ test_config commit.gpgsign true &&
set_fake_editor &&
FAKE_LINES="edit 1" git rebase -i --gpg-sign="\"S I Gner\"" HEAD^ \
>out 2>err &&
base-commit: 28d6daed4f119940ace31e523b3b272d3d153d04
--
2.15.1.windows.2
next reply other threads:[~2017-12-22 11:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-22 11:50 Johannes Schindelin [this message]
2017-12-22 12:58 ` [PATCH] sequencer: assign only free()able strings to gpg_sign phillip.wood
2017-12-22 17:20 ` Johannes Schindelin
2017-12-22 18:40 ` Junio C Hamano
2017-12-22 21:36 ` 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
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=f4420880aa4ee73b7c8e435de1efccf9a969fd41.1513943347.git.johannes.schindelin@gmx.de \
--to=johannes.schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=kaartic.sivaraam@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
/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).