git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Make verify-tag a builtin.

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 23, 2007, 00:52 UTC
Message-ID
<Pine.LNX.4.64.0707230141080.14781@racer.site>
In-Reply-To
<46A3F43C.3030101@gmail.com>
Hi,
On Mon, 23 Jul 2007, Carlos Rica wrote:
Show 17 quoted lines
> +static int run_gpg_verify(const char *buf, unsigned long size, int verbose)
> +{
> +	struct child_process gpg;
> +	const char *args_gpg[] = {"gpg", "--verify", "FILE", "-", NULL};
> +	char *path, *eol;
> +	size_t len;
> +	int fd, ret;
> +
> +	path = xstrdup(git_path("VTAG_TMP"));
> +	fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
> +	if (fd < 0)
> +		return error("could not create temporary file '%s': %s",
> +						path, strerror(errno));
> +	if (write_in_full(fd, buf, size) < 0)
> +		return error("failed writing temporary file '%s': %s",
> +						path, strerror(errno));
> +	close(fd);

I just tested something like "gpg --verify - - < <filename>" and it worked...

Show 6 quoted lines
> +	/* find the length without signature */
> +	len = 0;
> +	while (len < size && prefixcmp(buf + len, PGP_SIGNATURE "\n")) {
> +		eol = memchr(buf + len, '\n', size - len);
> +		len += eol ? eol - (buf + len) + 1 : size - len;
> +	}
How about this instead:
	const char *sig = strstr(buf, "\n" PGP_SIGNATURE "\n"));
	if (!sig)
		sig = buf + len;
Hmm?

But of course only if gpg does not grok "git cat-file tag <signed-tag> | gpg --verify - -".

> +	remove(path);

I think we use unlink() consistently, since we are sure it is no directory.

Show 5 quoted lines
> +	if (type <= OBJ_NONE)
> +		return error("%s: bad object type.", name);
> +	if (type != OBJ_TAG)
> +		return error("%s: cannot verify a non-tag object of type %s.",
> +				name, typename(type));
These two can be unified into one, right?
Show 10 quoted lines
> +int cmd_verify_tag(int argc, const char **argv, const char *prefix)
> +{
> +	int i, verbose = 0, had_error = 0;
> +
> +	git_config(git_default_config);
> +
> +	if (argc == 1)
> +		usage(builtin_verify_tag_usage);
> +
> +	i = 1;
You can initialise i above.
Show 8 quoted lines
> +	if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--verbose")) {
> +		verbose = 1;
> +		i++;
> +	}
> +
> +	signal(SIGPIPE, SIG_IGN);
> +	while (i < argc)
> +		if (verify_tag(argv[i++], verbose))

Heh. I thought that you only made this a separate function to help building it into builtin-tag...

That was quick!

Ciao, Dscho

Previous: Carlos RicaNext: Carlos Rica
Message 2 of 6 in “Make verify-tag a builtin.”
  1. Make verify-tag a builtin.Carlos Rica, Jul 23, 2007
  2. Johannes SchindelinJul 23, 2007
  3. Carlos RicaJul 23, 2007
  4. Johannes SchindelinJul 23, 2007
  5. Carlos RicaJul 23, 2007
  6. Johannes SchindelinJul 23, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.