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?