summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ace9c2a)
raw | patch | inline | side by side (parent: ace9c2a)
author | Linus Torvalds <torvalds@linux-foundation.org> | |
Tue, 11 Dec 2007 04:08:06 +0000 (20:08 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 11 Dec 2007 08:38:46 +0000 (00:38 -0800) |
Commit 396865859918e9c7bf8ce74aae137c57da134610 broke signed tags using
the "-u" flag when it made builtin-tag.c use parse_options() to parse its
arguments (but it quite possibly was broken even before that, by the
builtin rewrite).
It used to be that passing the signing ID with the -u parameter also
(obviously!) implied that you wanted to sign and annotate the tag, but
that logic got dropped. It also totally ignored the actual key ID that was
passed in.
This reinstates it all.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
the "-u" flag when it made builtin-tag.c use parse_options() to parse its
arguments (but it quite possibly was broken even before that, by the
builtin rewrite).
It used to be that passing the signing ID with the -u parameter also
(obviously!) implied that you wanted to sign and annotate the tag, but
that logic got dropped. It also totally ignored the actual key ID that was
passed in.
This reinstates it all.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-tag.c | patch | blob | history | |
t/t7004-tag.sh | patch | blob | history |
diff --git a/builtin-tag.c b/builtin-tag.c
index 517419fd3d885d677e8c2eeb533fc14f3df501f5..274901a408fa0d1d988da35d637ead7ca565552e 100644 (file)
--- a/builtin-tag.c
+++ b/builtin-tag.c
"# Write a tag message\n"
"#\n";
+static void set_signingkey(const char *value)
+{
+ if (strlcpy(signingkey, value, sizeof(signingkey)) >= sizeof(signingkey))
+ die("signing key value too long (%.10s...)", value);
+}
+
static int git_tag_config(const char *var, const char *value)
{
if (!strcmp(var, "user.signingkey")) {
if (!value)
die("user.signingkey without value");
- if (strlcpy(signingkey, value, sizeof(signingkey))
- >= sizeof(signingkey))
- die("user.signingkey value too long");
+ set_signingkey(value);
return 0;
}
argc = parse_options(argc, argv, options, git_tag_usage, 0);
+ if (keyid) {
+ sign = 1;
+ set_signingkey(keyid);
+ }
if (sign)
annotate = 1;
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index c7130c4dcc31dda1f70160c81804096676943af4..09d56e0839f042a74bee5c13ab251f19fcc2c76e 100755 (executable)
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
git diff expect actual
'
+get_tag_header u-signed-tag $commit commit $time >expect
+echo 'Another message' >>expect
+echo '-----BEGIN PGP SIGNATURE-----' >>expect
+test_expect_success 'sign with a given key id' '
+
+ git tag -u committer@example.com -m "Another message" u-signed-tag &&
+ get_tag_msg u-signed-tag >actual &&
+ git diff expect actual
+
+'
+
+test_expect_success 'sign with an unknown id (1)' '
+
+ ! git tag -u author@example.com -m "Another message" o-signed-tag
+
+'
+
+test_expect_success 'sign with an unknown id (2)' '
+
+ ! git tag -u DEADBEEF -m "Another message" o-signed-tag
+
+'
+
+cat >fakeeditor <<'EOF'
+#!/bin/sh
+test -n "$1" && exec >"$1"
+echo A signed tag message
+echo from a fake editor.
+EOF
+chmod +x fakeeditor
+
+get_tag_header implied-sign $commit commit $time >expect
+./fakeeditor >>expect
+echo '-----BEGIN PGP SIGNATURE-----' >>expect
+test_expect_success '-u implies signed tag' '
+ GIT_EDITOR=./fakeeditor git-tag -u CDDE430D implied-sign &&
+ get_tag_msg implied-sign >actual &&
+ git diff expect actual
+'
+
cat >sigmsgfile <<EOF
Another signed tag
message in a file.
git diff expect actual
'
-cat >fakeeditor <<'EOF'
-#!/bin/sh
-test -n "$1" && exec >"$1"
-echo A signed tag message
-echo from a fake editor.
-EOF
-chmod +x fakeeditor
get_tag_header implied-annotate $commit commit $time >expect
./fakeeditor >>expect
echo '-----BEGIN PGP SIGNATURE-----' >>expect