git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Robert Dailey <rcdailey.lists@gmail.com>
Cc: git@vger.kernel.org, Stefan Beller <stefanbeller@gmail.com>,
	Brandon Williams <bmwill@google.com>
Subject: Re: [PATCH] Support long format for log-based submodule diff
Date: Wed, 07 Mar 2018 13:41:01 -0800	[thread overview]
Message-ID: <xmqqefkvzhqq.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20180307211140.19272-1-rcdailey@gmail.com> (Robert Dailey's message of "Wed, 7 Mar 2018 15:11:40 -0600")

Robert Dailey <rcdailey.lists@gmail.com> writes:

> 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.

  reply	other threads:[~2018-03-07 21:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-07 21:11 [PATCH] Support long format for log-based submodule diff Robert Dailey
2018-03-07 21:41 ` Junio C Hamano [this message]
2018-03-09  8:53 ` Stefan Beller
2018-03-09 17:42   ` Junio C Hamano
2018-03-27 22:17     ` Stefan Beller
2018-04-02  1:07       ` Robert Dailey
2018-04-02 19:35         ` Stefan Beller

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=xmqqefkvzhqq.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=rcdailey.lists@gmail.com \
    --cc=stefanbeller@gmail.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).