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

Re: [PATCH RFC] diff: add SUBMODULE_DIFF format to display submodule diff

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 9, 2016, 22:40 UTC
Message-ID
<xmqq37md8t2a.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160809223219.17982-1-jacob.e.keller@intel.com>
Jacob Keller <jacob.e.keller@intel.com> writes:
Show 23 quoted lines
> +static int prepare_submodule_diff(struct strbuf *buf, const char *path,
> +		unsigned char one[20], unsigned char two[20])
> +{
> +	struct child_process cp = CHILD_PROCESS_INIT;
> +	cp.git_cmd = 1;
> +	cp.dir = path;
> +	cp.out = -1;
> +	cp.no_stdin = 1;
> +	argv_array_push(&cp.args, "diff");
> +	argv_array_push(&cp.args, sha1_to_hex(one));
> +	argv_array_push(&cp.args, sha1_to_hex(two));
> +
> +	if (start_command(&cp))
> +		return -1;
> +
> +	if (strbuf_read(buf, cp.out, 0) < 0)
> +		return -1;
> +
> +	if (finish_command(&cp))
> +		return -1;
> +
> +	return 0;
> +}

It is a good idea to keep the submodule data isolated from the main process by going through run-command/start-command interface (I think the call to add_submodule_odb() should be rethought and removed if possible).

I however wonder if you want to use src/dst-prefix to make the path to the submodule appear there? That is, if your superproject has a submodule at "dir/" and two versions of the submodule changes a file "doc/README", wouldn't you rather want to see

	diff --git a/dir/doc/README b/dir/doc/README
instead of comparison between a/doc/README and b/doc/README?
Previous: Jacob KellerNext: Stefan Beller
Message 2 of 7 in “diff: add SUBMODULE_DIFF format to display submodule diff”
  1. diff: add SUBMODULE_DIFF format to display submodule diffJacob Keller, Aug 9, 2016
  2. Junio C HamanoAug 9, 2016
  3. Stefan BellerAug 9, 2016
  4. Jacob KellerAug 9, 2016
  5. Stefan BellerAug 9, 2016
  6. Stefan BellerAug 9, 2016
  7. Johannes SixtAug 10, 2016

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.