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

Re: [PATCH] Support long format for log-based submodule diff

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 7, 2018, 21:41 UTC
Message-ID
<xmqqefkvzhqq.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180307211140.19272-1-rcdailey@gmail.com>
Robert Dailey <rcdailey.lists@gmail.com> writes:
Show 13 quoted lines
> I could have gone through the effort to make this more configurable, but
> before doing that level of work I wanted to get some discussion going to
> understand first if this is a useful change and second how it should be
> configured. For example, we could allow:
>
> $ git diff --submodule=long-log
>
> Or a supplementary option such as:
>
> $ git diff --submodule=log --submodule-log-detail=(long|short)
>
> I'm not sure what makes sense here. I welcome thoughts/discussion and
> will provide follow-up patches.

My quick looking around reveals that prepare_submodule_summary() is called only by show_submodule_summary(), which in turn is called only from builtin_diff() in a codepath like this:

	if (o->submodule_format == DIFF_SUBMODULE_LOG &&
	    (!one->mode || S_ISGITLINK(one->mode)) &&
	    (!two->mode || S_ISGITLINK(two->mode))) {
		show_submodule_summary(o, one->path ? one->path : two->path,
				&one->oid, &two->oid,
				two->dirty_submodule);
		return;
	} else if (o->submodule_format == DIFF_SUBMODULE_INLINE_DIFF &&
		   (!one->mode || S_ISGITLINK(one->mode)) &&
		   (!two->mode || S_ISGITLINK(two->mode))) {
		show_submodule_inline_diff(o, one->path ? one->path : two->path,
				&one->oid, &two->oid,
				two->dirty_submodule);
		return;
	}

It looks like introducing a new value to o->submodule_format (enum diff_submodule_format defined in diff.h) would be one natural way to extend this codepath, at least to me from a quick glance.

It also looks to me that the above may become far easier to read if the common "are we dealing with a filepair <one, two> that involves submodules?" check in the above if/else if cascade is factored out, perhaps like this as a preliminary clean-up step, before adding a new value:

	if ((!one->mode || S_ISGITLINK(one->mode)) &&
	    (!two->mode || S_ISGITLINK(two->mode))) {
		switch (o->submodule_format) {
		case DIFF_SUBMODULE_LOG:
			... do the "log" thing ...
			return;
		case DIFF_SUBMODULE_INLINE_DIFF:
			... do the "inline" thing ...
			return;
		default:
			break;
		}
	}

Then the place to add a new format would be trivially obvious, i.e. just add a new case arm to call a new function to give the summary.

Previous: Robert DaileyNext: Stefan Beller
Message 2 of 7 in “Support long format for log-based submodule diff”
  1. Support long format for log-based submodule diffRobert Dailey, Mar 7, 2018
  2. Junio C HamanoMar 7, 2018
  3. Stefan BellerMar 9, 2018
  4. Junio C HamanoMar 9, 2018
  5. Stefan BellerMar 27, 2018
  6. Robert DaileyApr 2, 2018
  7. Stefan BellerApr 2, 2018

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.