From: Christian Couder <christian.couder@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Patrick Steinhardt <ps@pks.im>,
Luke Shumaker <lukeshu@lukeshu.com>,
Elijah Newren <newren@gmail.com>, Jeff King <peff@peff.net>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Taylor Blau <me@ttaylorr.com>,
"brian m . carlson" <sandals@crustytoothpaste.net>,
Eric Sunshine <sunshine@sunshineco.com>,
Christian Couder <christian.couder@gmail.com>
Subject: [PATCH v5 0/6] fast-export, fast-import: add support for signed-commits
Date: Mon, 24 Feb 2025 15:27:38 +0100 [thread overview]
Message-ID: <20250224142744.279643-1-christian.couder@gmail.com> (raw)
In-Reply-To: <20210430232537.1131641-1-lukeshu@lukeshu.com>
Luke Shumaker sent the first 4 versions of this series in April 2021,
but it looks like he stopped before it got merged. Let's finish
polishing it.
Goal
~~~~
fast-export has an existing --signed-tags= option that controls how to
handle tag signatures. However, there is no equivalent for commit
signatures; it just silently strips the signature out of the commit
(analogously to --signed-tags=strip).
So implement a --signed-commits= flag in fast-export, and implement
the receiving side of it in fast-import.
Overview of the changes since v4
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This revision addresses all the feedback from v4 and has a few small
improvements that I came accross when rebasing it on top of current
master and working on it.
This doesn't address the following (that weren't addressed either by
earlier versions of this series) though:
- Elijah's suggestion to implement a flag on fast-import to validate
signatures. This could be a useful feature, but Luke considered
it was beyond the scope of this work, and I agree with him.
- The added tests still use `test -s err`, as that's still what's
used by the other existing tests. I would be fine with adding a
preparatory patch to address this, if people think it would be
worth it. On the other hand, it could be part of a small separate
series to modernize the whole "t/t9350-fast-export.sh".
Details of the changes since v4
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Rebased on top of b838bf1938 (Merge branch 'master' of
https://github.com/j6t/gitk, 2025-02-20) to fix a few conflicts
and avoid issues with file name changes, as v4 was based on
v2.31.0 which is very old.
- Added patch 2/6 (fast-export: fix missing whitespace after switch)
as a preparatory patch to fix a style issue related to 'switch'
statements in "builtin/fast-export.c".
- In patch 3/6 (fast-export: rename --signed-tags='warn' to
'warn-verbatim'), fixed an "a" vs "an" typo in
"t9350-fast-export.sh".
- In patch 4/6 (git-fast-export.txt: clarify why 'verbatim' may not
be a good idea), fixed a "transformation" vs "transformations"
typo in "git-fast-export.adoc".
- In patch 5/6 (fast-export: do not modify memory from
get_commit_buffer) there are a few small changes in
"builtin/fast-export.c" that were suggested by Junio:
* removed reencode_message() and instead put the encoding code in
the `case REENCODE_YES:` in handle_commit(),
* fixed multi-line comment style,
* fixed potential past end of buffer read by surrounding some code
with `if (*commit_buffer_cursor == '\n') { ... }`.
- In patch 6/6 (fast-export, fast-import: add support for
signed-commits) there are a number of small changes:
* some typo fixes:
- "changes" vs "change" in the commit message,
- "the the" vs "the" in "git-fast-import.adoc",
- "staticly" vs "statically" in a comment in "builtin/fast-export.c",
* some code changes, all suggested by Junio except the last one,
in "builtin/fast-export.c":
- made a 'strbuf' non-static in anonymize_ident_line(),
- fixed potential past end of buffer read by surrounding some code
with `if (*commit_buffer_cursor == '\n') { ... }`,
- added a `free((char *)signature)` call to avoid a memory leak
found by the CI tests,
* some test improvements suggested by Junio in
"t/t9350-fast-export.sh":
- removed whitespace between ">" and "file-sign",
- replaced `unset` with `sane_unset`,
- better indented lines where a `( ... )` subshell is used,
- replaced `{ ... || true }` with `test_might_fail`.
CI tests
~~~~~~~~
All the CI tests passed, see:
https://github.com/chriscool/git/actions/runs/13496792476
Range diff compared to version 4
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1: 53d8dd60ce ! 1: f97247e17d git-fast-import.txt: add missing LF in the BNF
@@ Metadata
Author: Luke Shumaker <lukeshu@datawire.io>
## Commit message ##
- git-fast-import.txt: add missing LF in the BNF
+ git-fast-import.adoc: add missing LF in the BNF
Signed-off-by: Luke Shumaker <lukeshu@datawire.io>
+ Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
- ## Documentation/git-fast-import.txt ##
-@@ Documentation/git-fast-import.txt: change to the project.
+ ## Documentation/git-fast-import.adoc ##
+@@ Documentation/git-fast-import.adoc: change to the project.
original-oid?
('author' (SP <name>)? SP LT <email> GT SP <when> LF)?
'committer' (SP <name>)? SP LT <email> GT SP <when> LF
-: ---------- > 2: b71588563d fast-export: fix missing whitespace after switch
2: 454a58a398 ! 3: 947bc267e6 fast-export: rename --signed-tags='warn' to 'warn-verbatim'
@@ Commit message
deprecated synonym of 'warn-verbatim'.
Signed-off-by: Luke Shumaker <lukeshu@datawire.io>
+ Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
- ## Documentation/git-fast-export.txt ##
-@@ Documentation/git-fast-export.txt: OPTIONS
+ ## Documentation/git-fast-export.adoc ##
+@@ Documentation/git-fast-export.adoc: OPTIONS
Insert 'progress' statements every <n> objects, to be shown by
'git fast-import' during import.
@@ Documentation/git-fast-export.txt: OPTIONS
Specify how to handle signed tags. Since any transformation
after the export can change the tag names (which can also happen
when excluding revisions) the signatures will not match.
-@@ Documentation/git-fast-export.txt: When asking to 'abort' (which is the default), this program will die
+@@ Documentation/git-fast-export.adoc: When asking to 'abort' (which is the default), this program will die
when encountering a signed tag. With 'strip', the tags will silently
be made unsigned, with 'warn-strip' they will be made unsigned but a
warning will be displayed, with 'verbatim', they will be silently
@@ builtin/fast-export.c: static const char *fast_export_usage[] = {
};
static int progress;
--static enum { SIGNED_TAG_ABORT, VERBATIM, WARN, WARN_STRIP, STRIP } signed_tag_mode = SIGNED_TAG_ABORT;
-+static enum { SIGNED_TAG_ABORT, VERBATIM, WARN_VERBATIM, WARN_STRIP, STRIP } signed_tag_mode = SIGNED_TAG_ABORT;
- static enum { TAG_FILTERING_ABORT, DROP, REWRITE } tag_of_filtered_mode = TAG_FILTERING_ABORT;
- static enum { REENCODE_ABORT, REENCODE_YES, REENCODE_NO } reencode_mode = REENCODE_ABORT;
+-static enum signed_tag_mode { SIGNED_TAG_ABORT, VERBATIM, WARN, WARN_STRIP, STRIP } signed_tag_mode = SIGNED_TAG_ABORT;
++static enum signed_tag_mode { SIGNED_TAG_ABORT, VERBATIM, WARN_VERBATIM, WARN_STRIP, STRIP } signed_tag_mode = SIGNED_TAG_ABORT;
+ static enum tag_of_filtered_mode { TAG_FILTERING_ABORT, DROP, REWRITE } tag_of_filtered_mode = TAG_FILTERING_ABORT;
+ static enum reencode_mode { REENCODE_ABORT, REENCODE_YES, REENCODE_NO } reencode_mode = REENCODE_ABORT;
static int fake_missing_tagger;
@@ builtin/fast-export.c: static int parse_opt_signed_tag_mode(const struct option *opt,
- signed_tag_mode = SIGNED_TAG_ABORT;
+ *val = SIGNED_TAG_ABORT;
else if (!strcmp(arg, "verbatim") || !strcmp(arg, "ignore"))
- signed_tag_mode = VERBATIM;
+ *val = VERBATIM;
- else if (!strcmp(arg, "warn"))
-- signed_tag_mode = WARN;
+- *val = WARN;
+ else if (!strcmp(arg, "warn-verbatim") || !strcmp(arg, "warn"))
-+ signed_tag_mode = WARN_VERBATIM;
++ *val = WARN_VERBATIM;
else if (!strcmp(arg, "warn-strip"))
- signed_tag_mode = WARN_STRIP;
+ *val = WARN_STRIP;
else if (!strcmp(arg, "strip"))
@@ builtin/fast-export.c: static void handle_tag(const char *name, struct tag *tag)
die("encountered signed tag %s; use "
@@ t/t9350-fast-export.sh: test_expect_success 'signed-tags=verbatim' '
+
+'
+
-+# 'warn' is an backward-compatibility alias for 'warn-verbatim'; test
++# 'warn' is a backward-compatibility alias for 'warn-verbatim'; test
+# that it keeps working.
+test_expect_success 'signed-tags=warn' '
+
3: ee0d84c34a ! 4: 45087db345 git-fast-export.txt: clarify why 'verbatim' may not be a good idea
@@ Commit message
git-fast-export.txt: clarify why 'verbatim' may not be a good idea
Signed-off-by: Luke Shumaker <lukeshu@datawire.io>
+ Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
- ## Documentation/git-fast-export.txt ##
-@@ Documentation/git-fast-export.txt: OPTIONS
+ ## Documentation/git-fast-export.adoc ##
+@@ Documentation/git-fast-export.adoc: OPTIONS
--signed-tags=(verbatim|warn-verbatim|warn-strip|strip|abort)::
Specify how to handle signed tags. Since any transformation
@@ Documentation/git-fast-export.txt: OPTIONS
-they will be exported, but you will see a warning.
+they will be exported, but you will see a warning. 'verbatim' and
+'warn-verbatim' should only be used if you know that no
-+transformations affecting tags will be performed, or if you do not
++transformation affecting tags will be performed, or if you do not
+care that the resulting tag will have an invalid signature.
--tag-of-filtered-object=(abort|drop|rewrite)::
4: 36463ee3a8 ! 5: 20f085a790 fast-export: do not modify memory from get_commit_buffer
@@ Commit message
`encoding ? encoding + encoding_len : committer_end` expression.
Signed-off-by: Luke Shumaker <lukeshu@datawire.io>
+ Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
## builtin/fast-export.c ##
@@ builtin/fast-export.c: static void show_filemodify(struct diff_queue_struct *q,
@@ builtin/fast-export.c: static void show_filemodify(struct diff_queue_struct *q,
- return bol;
-}
-
- static char *anonymize_ref_component(void *data)
+ static char *anonymize_ref_component(void)
{
static int counter;
-@@ builtin/fast-export.c: static void anonymize_ident_line(const char **beg, const char **end)
- *end = out->buf + out->len;
- }
-
-+static char *reencode_message(const char *in_msg,
-+ const char *in_encoding, size_t in_encoding_len)
-+{
-+ static struct strbuf in_encoding_buf = STRBUF_INIT;
-+
-+ strbuf_reset(&in_encoding_buf);
-+ strbuf_add(&in_encoding_buf, in_encoding, in_encoding_len);
-+
-+ return reencode_string(in_msg, "UTF-8", in_encoding_buf.buf);
-+}
-+
- static void handle_commit(struct commit *commit, struct rev_info *rev,
+@@ builtin/fast-export.c: static void handle_commit(struct commit *commit, struct rev_info *rev,
struct string_list *paths_of_changed_objects)
{
int saved_output_format = rev->diffopt.output_format;
@@ builtin/fast-export.c: static void anonymize_ident_line(const char **beg, const
+ const char *commit_buffer, *commit_buffer_cursor;
const char *author, *author_end, *committer, *committer_end;
- const char *encoding, *message;
-+ const char *encoding;
++ const char *encoding = NULL;
+ size_t encoding_len;
+ const char *message;
char *reencoded = NULL;
@@ builtin/fast-export.c: static void handle_commit(struct commit *commit, struct r
rev->diffopt.output_format = DIFF_FORMAT_CALLBACK;
parse_commit_or_die(commit);
-- commit_buffer = get_commit_buffer(commit, NULL);
+- commit_buffer = repo_get_commit_buffer(the_repository, commit, NULL);
- author = strstr(commit_buffer, "\nauthor ");
-+ commit_buffer_cursor = commit_buffer = get_commit_buffer(commit, NULL);
++ commit_buffer_cursor = commit_buffer = repo_get_commit_buffer(the_repository, commit, NULL);
+
+ author = strstr(commit_buffer_cursor, "\nauthor ");
if (!author)
@@ builtin/fast-export.c: static void handle_commit(struct commit *commit, struct r
- encoding = find_encoding(committer_end, message);
+ commit_buffer_cursor = committer_end = strchrnul(committer, '\n');
+
-+ /* find_commit_header() gets a `+ 1` because
++ /*
++ * find_commit_header() gets a `+ 1` because
+ * commit_buffer_cursor points at the trailing "\n" at the end
+ * of the previous line, but find_commit_header() wants a
-+ * pointer to the beginning of the next line. */
-+ encoding = find_commit_header(commit_buffer_cursor + 1, "encoding", &encoding_len);
-+ if (encoding)
-+ commit_buffer_cursor = encoding + encoding_len;
++ * pointer to the beginning of the next line.
++ */
++ if (*commit_buffer_cursor == '\n') {
++ encoding = find_commit_header(commit_buffer_cursor + 1, "encoding", &encoding_len);
++ if (encoding)
++ commit_buffer_cursor = encoding + encoding_len;
++ }
+
+ message = strstr(commit_buffer_cursor, "\n\n");
if (message)
message += 2;
@@ builtin/fast-export.c: static void handle_commit(struct commit *commit, struct rev_info *rev,
+ if (anonymize) {
+ reencoded = anonymize_commit_message();
} else if (encoding) {
- switch(reencode_mode) {
++ char *buf;
+ switch (reencode_mode) {
case REENCODE_YES:
- reencoded = reencode_string(message, "UTF-8", encoding);
-+ reencoded = reencode_message(message, encoding, encoding_len);
++ buf = xstrfmt("%.*s", (int)encoding_len, encoding);
++ reencoded = reencode_string(message, "UTF-8", buf);
++ free(buf);
break;
case REENCODE_NO:
break;
5: 8ff33e2e88 ! 6: 48e0d4203c fast-export, fast-import: add support for signed-commits
@@ Commit message
option.
On the fast-export side, try to be as much like signed-tags as possible,
- in both implementation and in user-interface. This will changes the
+ in both implementation and in user-interface. This will change the
default behavior to '--signed-commits=abort' from what is now
'--signed-commits=strip'. In order to provide an escape hatch for users
of third-party tools that call fast-export and do not yet know of the
@@ Commit message
'--signed-commits=warn-strip'.
Signed-off-by: Luke Shumaker <lukeshu@datawire.io>
+ Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
- ## Documentation/git-fast-export.txt ##
-@@ Documentation/git-fast-export.txt: they will be exported, but you will see a warning. 'verbatim' and
- transformations affecting tags will be performed, or if you do not
+ ## Documentation/git-fast-export.adoc ##
+@@ Documentation/git-fast-export.adoc: they will be exported, but you will see a warning. 'verbatim' and
+ transformation affecting tags will be performed, or if you do not
care that the resulting tag will have an invalid signature.
+--signed-commits=(verbatim|warn-verbatim|warn-strip|strip|abort)::
@@ Documentation/git-fast-export.txt: they will be exported, but you will see a war
Specify how to handle tags whose tagged object is filtered out.
Since revisions and files to export can be limited by path,
- ## Documentation/git-fast-import.txt ##
-@@ Documentation/git-fast-import.txt: and control the current import process. More detailed discussion
+ ## Documentation/git-fast-import.adoc ##
+@@ Documentation/git-fast-import.adoc: and control the current import process. More detailed discussion
Create or update a branch with a new commit, recording one logical
change to the project.
+////
+Yes, it's intentional that the 'gpgsig' line doesn't have a trailing
-+`LF`; the the definition of `data` has a byte-count prefix, so it
++`LF`; the definition of `data` has a byte-count prefix, so it
+doesn't need an `LF` to act as a terminator (and `data` also already
+includes an optional trailing `LF?` just in case you want to include
+one).
@@ Documentation/git-fast-import.txt: and control the current import process. More
('encoding' SP <encoding> LF)?
data
('from' SP <commit-ish> LF)?
-@@ Documentation/git-fast-import.txt: that was selected by the --date-format=<fmt> command-line option.
+@@ Documentation/git-fast-import.adoc: that was selected by the --date-format=<fmt> command-line option.
See ``Date Formats'' above for the set of supported formats, and
their syntax.
@@ builtin/fast-export.c: static const char *fast_export_usage[] = {
+enum sign_mode { SIGN_ABORT, SIGN_VERBATIM, SIGN_STRIP, SIGN_WARN_VERBATIM, SIGN_WARN_STRIP };
+
static int progress;
--static enum { SIGNED_TAG_ABORT, VERBATIM, WARN_VERBATIM, WARN_STRIP, STRIP } signed_tag_mode = SIGNED_TAG_ABORT;
+-static enum signed_tag_mode { SIGNED_TAG_ABORT, VERBATIM, WARN_VERBATIM, WARN_STRIP, STRIP } signed_tag_mode = SIGNED_TAG_ABORT;
+static enum sign_mode signed_tag_mode = SIGN_ABORT;
+static enum sign_mode signed_commit_mode = SIGN_ABORT;
- static enum { TAG_FILTERING_ABORT, DROP, REWRITE } tag_of_filtered_mode = TAG_FILTERING_ABORT;
- static enum { REENCODE_ABORT, REENCODE_YES, REENCODE_NO } reencode_mode = REENCODE_ABORT;
+ static enum tag_of_filtered_mode { TAG_FILTERING_ABORT, DROP, REWRITE } tag_of_filtered_mode = TAG_FILTERING_ABORT;
+ static enum reencode_mode { REENCODE_ABORT, REENCODE_YES, REENCODE_NO } reencode_mode = REENCODE_ABORT;
static int fake_missing_tagger;
@@ builtin/fast-export.c: static int anonymize;
static struct hashmap anonymized_seeds;
@@ builtin/fast-export.c: static int anonymize;
+static int parse_opt_sign_mode(const struct option *opt,
const char *arg, int unset)
{
+- enum signed_tag_mode *val = opt->value;
+-
- if (unset || !strcmp(arg, "abort"))
-- signed_tag_mode = SIGNED_TAG_ABORT;
-+ enum sign_mode *valptr = opt->value;
+- *val = SIGNED_TAG_ABORT;
++ enum sign_mode *val = opt->value;
+ if (unset)
+ return 0;
+ else if (!strcmp(arg, "abort"))
-+ *valptr = SIGN_ABORT;
++ *val = SIGN_ABORT;
else if (!strcmp(arg, "verbatim") || !strcmp(arg, "ignore"))
-- signed_tag_mode = VERBATIM;
-+ *valptr = SIGN_VERBATIM;
+- *val = VERBATIM;
++ *val = SIGN_VERBATIM;
else if (!strcmp(arg, "warn-verbatim") || !strcmp(arg, "warn"))
-- signed_tag_mode = WARN_VERBATIM;
-+ *valptr = SIGN_WARN_VERBATIM;
+- *val = WARN_VERBATIM;
++ *val = SIGN_WARN_VERBATIM;
else if (!strcmp(arg, "warn-strip"))
-- signed_tag_mode = WARN_STRIP;
-+ *valptr = SIGN_WARN_STRIP;
+- *val = WARN_STRIP;
++ *val = SIGN_WARN_STRIP;
else if (!strcmp(arg, "strip"))
-- signed_tag_mode = STRIP;
-+ *valptr = SIGN_STRIP;
+- *val = STRIP;
++ *val = SIGN_STRIP;
else
- return error("Unknown signed-tags mode: %s", arg);
+ return error("Unknown %s mode: %s", opt->long_name, arg);
@@ builtin/fast-export.c: static void anonymize_ident_line(const char **beg, const
+ * returning the first line of the header.
+ *
+ * The returned string has had the ' ' line continuation markers
-+ * removed, and points to staticly allocated memory (not to memory
++ * removed, and points to statically allocated memory (not to memory
+ * within 'msg'), so it is only valid until the next call to
+ * find_commit_multiline_header.
+ *
@@ builtin/fast-export.c: static void anonymize_ident_line(const char **beg, const
+ const char *key,
+ const char **end)
+{
-+ static struct strbuf val = STRBUF_INIT;
++ struct strbuf val = STRBUF_INIT;
+ const char *bol, *eol;
+ size_t len;
+
-+ strbuf_reset(&val);
-+
+ bol = find_commit_header(msg, key, &len);
+ if (!bol)
+ return NULL;
@@ builtin/fast-export.c: static void anonymize_ident_line(const char **beg, const
+ }
+
+ *end = eol;
-+ return val.buf;
++ return strbuf_detach(&val, NULL);
+}
+
- static char *reencode_message(const char *in_msg,
- const char *in_encoding, size_t in_encoding_len)
+ static void handle_commit(struct commit *commit, struct rev_info *rev,
+ struct string_list *paths_of_changed_objects)
{
@@ builtin/fast-export.c: static void handle_commit(struct commit *commit, struct rev_info *rev,
const char *author, *author_end, *committer, *committer_end;
- const char *encoding;
+ const char *encoding = NULL;
size_t encoding_len;
-+ const char *signature_alg = NULL, *signature;
++ const char *signature_alg = NULL, *signature = NULL;
const char *message;
char *reencoded = NULL;
struct commit_list *p;
@@ builtin/fast-export.c: static void handle_commit(struct commit *commit, struct rev_info *rev,
- committer++;
commit_buffer_cursor = committer_end = strchrnul(committer, '\n');
-- /* find_commit_header() gets a `+ 1` because
+ /*
+- * find_commit_header() gets a `+ 1` because
- * commit_buffer_cursor points at the trailing "\n" at the end
- * of the previous line, but find_commit_header() wants a
-+ /* find_commit_header() and find_commit_multiline_header() get
++ * find_commit_header() and find_commit_multiline_header() get
+ * a `+ 1` because commit_buffer_cursor points at the trailing
+ * "\n" at the end of the previous line, but they want a
- * pointer to the beginning of the next line. */
+ * pointer to the beginning of the next line.
+ */
+
- encoding = find_commit_header(commit_buffer_cursor + 1, "encoding", &encoding_len);
- if (encoding)
- commit_buffer_cursor = encoding + encoding_len;
+ if (*commit_buffer_cursor == '\n') {
+ encoding = find_commit_header(commit_buffer_cursor + 1, "encoding", &encoding_len);
+ if (encoding)
+ commit_buffer_cursor = encoding + encoding_len;
+ }
-+ if ((signature = find_commit_multiline_header(commit_buffer_cursor + 1, "gpgsig", &commit_buffer_cursor)))
-+ signature_alg = "sha1";
-+ else if ((signature = find_commit_multiline_header(commit_buffer_cursor + 1, "gpgsig-sha256", &commit_buffer_cursor)))
-+ signature_alg = "sha256";
++ if (*commit_buffer_cursor == '\n') {
++ if ((signature = find_commit_multiline_header(commit_buffer_cursor + 1, "gpgsig", &commit_buffer_cursor)))
++ signature_alg = "sha1";
++ else if ((signature = find_commit_multiline_header(commit_buffer_cursor + 1, "gpgsig-sha256", &commit_buffer_cursor)))
++ signature_alg = "sha256";
++ }
+
message = strstr(commit_buffer_cursor, "\n\n");
if (message)
@@ builtin/fast-export.c: static void handle_commit(struct commit *commit, struct r
printf("%.*s\n%.*s\n",
(int)(author_end - author), author,
(int)(committer_end - committer), committer);
-+ if (signature)
-+ switch(signed_commit_mode) {
++ if (signature) {
++ switch (signed_commit_mode) {
+ case SIGN_ABORT:
+ die("encountered signed commit %s; use "
+ "--signed-commits=<mode> to handle it",
@@ builtin/fast-export.c: static void handle_commit(struct commit *commit, struct r
+ case SIGN_STRIP:
+ break;
+ }
++ free((char *)signature);
++ }
if (!reencoded && encoding)
printf("encoding %.*s\n", (int)encoding_len, encoding);
printf("data %u\n%s",
@@ builtin/fast-export.c: static void handle_tag(const char *name, struct tag *tag)
"\n-----BEGIN PGP SIGNATURE-----\n");
if (signature)
- switch(signed_tag_mode) {
+ switch (signed_tag_mode) {
- case SIGNED_TAG_ABORT:
+ case SIGN_ABORT:
die("encountered signed tag %s; use "
@@ builtin/fast-export.c: static void handle_tag(const char *name, struct tag *tag)
message_size = signature + 1 - message;
break;
}
-@@ builtin/fast-export.c: static int parse_opt_anonymize_map(const struct option *opt,
-
- int cmd_fast_export(int argc, const char **argv, const char *prefix)
+@@ builtin/fast-export.c: int cmd_fast_export(int argc,
+ const char *prefix,
+ struct repository *repo UNUSED)
{
+ const char *env_signed_commits_noabort;
struct rev_info revs;
- struct object_array commits = OBJECT_ARRAY_INIT;
struct commit *commit;
-@@ builtin/fast-export.c: int cmd_fast_export(int argc, const char **argv, const char *prefix)
+ char *export_filename = NULL,
+@@ builtin/fast-export.c: int cmd_fast_export(int argc,
N_("show progress after <n> objects")),
OPT_CALLBACK(0, "signed-tags", &signed_tag_mode, N_("mode"),
N_("select handling of signed tags"),
@@ builtin/fast-export.c: int cmd_fast_export(int argc, const char **argv, const ch
OPT_CALLBACK(0, "tag-of-filtered-object", &tag_of_filtered_mode, N_("mode"),
N_("select handling of tags that tag filtered objects"),
parse_opt_tag_of_filtered_mode),
-@@ builtin/fast-export.c: int cmd_fast_export(int argc, const char **argv, const char *prefix)
+@@ builtin/fast-export.c: int cmd_fast_export(int argc,
if (argc == 1)
usage_with_options (fast_export_usage, options);
@@ builtin/fast-import.c: static void parse_new_commit(const char *arg)
+ strbuf_addstr(&new_data, "gpgsig-sha256 ");
+ else
+ die("Expected gpgsig algorithm sha1 or sha256, got %s", sig_alg);
-+ string_list_split_in_place(&siglines, sig.buf, '\n', -1);
++ string_list_split_in_place(&siglines, sig.buf, "\n", -1);
+ strbuf_add_separated_string_list(&new_data, "\n ", &siglines);
+ strbuf_addch(&new_data, '\n');
+ }
@@ t/t9350-fast-export.sh: test_expect_success 'signed-tags=warn-strip' '
+ # between the two.
+ test_config i18n.commitEncoding ISO-8859-1 &&
+ git checkout -f -b commit-signing main &&
-+ echo Sign your name > file-sign &&
++ echo Sign your name >file-sign &&
+ git add file-sign &&
+ git commit -S -m "signed commit" &&
+ COMMIT_SIGNING=$(git rev-parse --verify commit-signing)
@@ t/t9350-fast-export.sh: test_expect_success 'signed-tags=warn-strip' '
+
+test_expect_success GPG 'signed-commits default' '
+
-+ unset FAST_EXPORT_SIGNED_COMMITS_NOABORT &&
++ sane_unset FAST_EXPORT_SIGNED_COMMITS_NOABORT &&
+ test_must_fail git fast-export --reencode=no commit-signing &&
+
+ FAST_EXPORT_SIGNED_COMMITS_NOABORT=1 git fast-export --reencode=no commit-signing >output 2>err &&
+ ! grep ^gpgsig output &&
+ grep "^encoding ISO-8859-1" output &&
+ test -s err &&
-+ sed "s/commit-signing/commit-strip-signing/" output |
-+ (cd new &&
-+ git fast-import &&
-+ test $COMMIT_SIGNING != $(git rev-parse --verify refs/heads/commit-strip-signing))
++ sed "s/commit-signing/commit-strip-signing/" output | (
++ cd new &&
++ git fast-import &&
++ STRIPPED=$(git rev-parse --verify refs/heads/commit-strip-signing) &&
++ test $COMMIT_SIGNING != $STRIPPED
++ )
+
+'
+
@@ t/t9350-fast-export.sh: test_expect_success 'signed-tags=warn-strip' '
+ git fast-export --signed-commits=verbatim --reencode=no commit-signing >output &&
+ grep "^gpgsig sha" output &&
+ grep "encoding ISO-8859-1" output &&
-+ (cd new &&
-+ git fast-import &&
-+ test $COMMIT_SIGNING = $(git rev-parse --verify refs/heads/commit-signing)) <output
++ (
++ cd new &&
++ git fast-import &&
++ STRIPPED=$(git rev-parse --verify refs/heads/commit-signing) &&
++ test $COMMIT_SIGNING = $STRIPPED
++ ) <output
+
+'
+
@@ t/t9350-fast-export.sh: test_expect_success 'signed-tags=warn-strip' '
+ grep "^gpgsig sha" output &&
+ grep "encoding ISO-8859-1" output &&
+ test -s err &&
-+ (cd new &&
-+ git fast-import &&
-+ test $COMMIT_SIGNING = $(git rev-parse --verify refs/heads/commit-signing)) <output
++ (
++ cd new &&
++ git fast-import &&
++ STRIPPED=$(git rev-parse --verify refs/heads/commit-signing) &&
++ test $COMMIT_SIGNING = $STRIPPED
++ ) <output
+
+'
+
@@ t/t9350-fast-export.sh: test_expect_success 'signed-tags=warn-strip' '
+ git fast-export --signed-commits=strip --reencode=no commit-signing >output &&
+ ! grep ^gpgsig output &&
+ grep "^encoding ISO-8859-1" output &&
-+ sed "s/commit-signing/commit-strip-signing/" output |
-+ (cd new &&
-+ git fast-import &&
-+ test $COMMIT_SIGNING != $(git rev-parse --verify refs/heads/commit-strip-signing))
++ sed "s/commit-signing/commit-strip-signing/" output | (
++ cd new &&
++ git fast-import &&
++ STRIPPED=$(git rev-parse --verify refs/heads/commit-strip-signing) &&
++ test $COMMIT_SIGNING != $STRIPPED
++ )
+
+'
+
@@ t/t9350-fast-export.sh: test_expect_success 'signed-tags=warn-strip' '
+ ! grep ^gpgsig output &&
+ grep "^encoding ISO-8859-1" output &&
+ test -s err &&
-+ sed "s/commit-signing/commit-strip-signing/" output |
-+ (cd new &&
-+ git fast-import &&
-+ test $COMMIT_SIGNING != $(git rev-parse --verify refs/heads/commit-strip-signing))
++ sed "s/commit-signing/commit-strip-signing/" output | (
++ cd new &&
++ git fast-import &&
++ STRIPPED=$(git rev-parse --verify refs/heads/commit-strip-signing) &&
++ test $COMMIT_SIGNING != $STRIPPED
++ )
+
+'
+
test_expect_success 'setup submodule' '
+ test_config_global protocol.file.allow always &&
git checkout -f main &&
-+ { git update-ref -d refs/heads/commit-signing || true; } &&
++ test_might_fail git update-ref -d refs/heads/commit-signing &&
mkdir sub &&
(
cd sub &&
Christian Couder (1):
fast-export: fix missing whitespace after switch
Luke Shumaker (5):
git-fast-import.adoc: add missing LF in the BNF
fast-export: rename --signed-tags='warn' to 'warn-verbatim'
git-fast-export.txt: clarify why 'verbatim' may not be a good idea
fast-export: do not modify memory from get_commit_buffer
fast-export, fast-import: add support for signed-commits
Documentation/git-fast-export.adoc | 25 +++-
Documentation/git-fast-import.adoc | 20 ++-
builtin/fast-export.c | 189 +++++++++++++++++++++--------
builtin/fast-import.c | 23 ++++
t/t9350-fast-export.sh | 116 ++++++++++++++++++
5 files changed, 317 insertions(+), 56 deletions(-)
--
2.48.1.401.g48e0d4203c
next prev parent reply other threads:[~2025-02-24 14:28 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-22 0:27 [PATCH v2 0/3] fast-export, fast-import: implement signed-commits Luke Shumaker
2021-04-22 0:27 ` [PATCH v2 1/3] git-fast-import.txt: add missing LF in the BNF Luke Shumaker
2021-04-22 0:27 ` [PATCH v2 2/3] fast-export: rename --signed-tags='warn' to 'warn-verbatim' Luke Shumaker
2021-04-22 3:59 ` Eric Sunshine
2021-04-22 4:43 ` Luke Shumaker
2021-04-22 4:50 ` Luke Shumaker
2021-04-22 0:27 ` [PATCH v2 3/3] fast-export, fast-import: implement signed-commits Luke Shumaker
2021-04-23 16:41 ` [PATCH v3 0/3] " Luke Shumaker
2021-04-23 16:41 ` [PATCH v3 1/3] git-fast-import.txt: add missing LF in the BNF Luke Shumaker
2021-04-23 16:41 ` [PATCH v3 2/3] fast-export: rename --signed-tags='warn' to 'warn-verbatim' Luke Shumaker
2021-04-28 3:29 ` Junio C Hamano
2021-04-29 19:02 ` Luke Shumaker
2021-04-30 0:03 ` Junio C Hamano
2021-04-23 16:41 ` [PATCH v3 3/3] fast-export, fast-import: implement signed-commits Luke Shumaker
2021-04-28 4:02 ` Junio C Hamano
2021-04-29 20:06 ` Luke Shumaker
2021-04-29 22:38 ` Elijah Newren
2021-04-29 23:42 ` Junio C Hamano
2021-04-30 2:23 ` Elijah Newren
2021-04-30 3:20 ` Junio C Hamano
2021-04-30 17:07 ` Luke Shumaker
2021-04-30 19:34 ` Luke Shumaker
2021-04-30 19:59 ` Elijah Newren
2021-04-30 22:21 ` Luke Shumaker
2021-04-30 23:25 ` [PATCH v4 0/5] fast-export, fast-import: add support for signed-commits Luke Shumaker
2021-04-30 23:25 ` [PATCH v4 1/5] git-fast-import.txt: add missing LF in the BNF Luke Shumaker
2021-04-30 23:25 ` [PATCH v4 2/5] fast-export: rename --signed-tags='warn' to 'warn-verbatim' Luke Shumaker
2021-04-30 23:25 ` [PATCH v4 3/5] git-fast-export.txt: clarify why 'verbatim' may not be a good idea Luke Shumaker
2021-04-30 23:25 ` [PATCH v4 4/5] fast-export: do not modify memory from get_commit_buffer Luke Shumaker
2021-05-03 4:41 ` Junio C Hamano
2021-04-30 23:25 ` [PATCH v4 5/5] fast-export, fast-import: add support for signed-commits Luke Shumaker
2021-05-03 5:09 ` Junio C Hamano
2025-02-24 14:27 ` Christian Couder [this message]
2025-02-24 14:27 ` [PATCH v5 1/6] git-fast-import.adoc: add missing LF in the BNF Christian Couder
2025-02-24 14:27 ` [PATCH v5 2/6] fast-export: fix missing whitespace after switch Christian Couder
2025-02-24 14:27 ` [PATCH v5 3/6] fast-export: rename --signed-tags='warn' to 'warn-verbatim' Christian Couder
2025-02-24 14:27 ` [PATCH v5 4/6] git-fast-export.txt: clarify why 'verbatim' may not be a good idea Christian Couder
2025-02-24 19:26 ` Elijah Newren
2025-03-10 15:58 ` Christian Couder
2025-02-24 14:27 ` [PATCH v5 5/6] fast-export: do not modify memory from get_commit_buffer Christian Couder
2025-02-24 14:27 ` [PATCH v5 6/6] fast-export, fast-import: add support for signed-commits Christian Couder
2025-02-25 7:35 ` Elijah Newren
2025-02-25 16:25 ` Junio C Hamano
2025-03-10 15:58 ` Christian Couder
2025-02-24 17:01 ` [PATCH v5 0/6] " Junio C Hamano
2025-02-25 7:35 ` Elijah Newren
2025-02-25 7:51 ` Patrick Steinhardt
2025-02-25 16:48 ` Elijah Newren
2025-02-25 16:56 ` Junio C Hamano
2025-03-10 15:59 ` Christian Couder
2025-02-25 14:53 ` Phillip Wood
2025-03-10 15:59 ` Christian Couder
2025-03-10 15:57 ` [PATCH v6 " Christian Couder
2025-03-10 15:57 ` [PATCH v6 1/6] git-fast-import.adoc: add missing LF in the BNF Christian Couder
2025-03-10 15:57 ` [PATCH v6 2/6] fast-export: fix missing whitespace after switch Christian Couder
2025-03-10 15:57 ` [PATCH v6 3/6] fast-export: rename --signed-tags='warn' to 'warn-verbatim' Christian Couder
2025-03-10 15:57 ` [PATCH v6 4/6] git-fast-export.adoc: clarify why 'verbatim' may not be a good idea Christian Couder
2025-03-10 15:57 ` [PATCH v6 5/6] fast-export: do not modify memory from get_commit_buffer Christian Couder
2025-03-10 15:57 ` [PATCH v6 6/6] fast-export, fast-import: add support for signed-commits Christian Couder
2025-03-10 22:36 ` [PATCH v6 0/6] " Elijah Newren
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=20250224142744.279643-1-christian.couder@gmail.com \
--to=christian.couder@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=lukeshu@lukeshu.com \
--cc=me@ttaylorr.com \
--cc=newren@gmail.com \
--cc=peff@peff.net \
--cc=ps@pks.im \
--cc=sandals@crustytoothpaste.net \
--cc=sunshine@sunshineco.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).