All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Josh Bleecher Snyder <josharian@gmail.com>
Subject: Re: [RFC/PATCH] log: add log.firstparent option
Date: Fri, 24 Jul 2015 19:05:27 -0700	[thread overview]
Message-ID: <20150725020526.GA8948@peff.net> (raw)
In-Reply-To: <xmqq8ua5oapm.fsf@gitster.dls.corp.google.com>

On Fri, Jul 24, 2015 at 08:07:49AM -0700, Junio C Hamano wrote:

> > I am not entirely convinced this won't bite somebody who gets a sha1
> > from some other source, and then wants to run:
> >
> >   git log $some_other_sha1
> >
> > who might be quite confused to start a first-parent traversal from
> > somewhere other than the tip of "master" or the tip of a topic branch.
> 
> Yeah, you actually convinced me reasonably well that it would
> happen.  I'd never use it myself.  If people want to shoot
> themselves in the foot, be my guest ;-)
> 
> Perhaps we should drop this, and give a shorter synonym to the
> option?

I'm still on the fence to have the config kick in only for HEAD.
Something like (on top of my other patch, and the tests would still need
adjusted):

diff --git a/Documentation/config.txt b/Documentation/config.txt
index e9c3763..f2b6a21 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1802,9 +1802,11 @@ log.mailmap::
 	If true, makes linkgit:git-log[1], linkgit:git-show[1], and
 	linkgit:git-whatchanged[1] assume `--use-mailmap`.
 
-log.firstparent::
-	If true, linkgit:git-log[1] will default to `--first-parent`;
-	can be overridden by supplying `--no-first-parent`.
+log.defaultImpliesFirstParent::
+	If true, linkgit:git-log[1] will default to `--first-parent`
+	when showing the default ref (i.e., if you run only `git
+	log` to show `HEAD`, but not `git log $sha1`). Can be overridden
+	by supplying `--no-first-parent`.
 
 mailinfo.scissors::
 	If true, makes linkgit:git-mailinfo[1] (and therefore
diff --git a/builtin/log.c b/builtin/log.c
index 3e9b034..2bdb3fc 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -31,7 +31,7 @@ static const char *default_date_mode = NULL;
 
 static int default_abbrev_commit;
 static int default_show_root = 1;
-static int default_first_parent;
+static int default_implies_first_parent;
 static int decoration_style;
 static int decoration_given;
 static int use_mailmap_config;
@@ -110,7 +110,6 @@ static void cmd_log_init_defaults(struct rev_info *rev)
 	rev->abbrev_commit = default_abbrev_commit;
 	rev->show_root_diff = default_show_root;
 	rev->subject_prefix = fmt_patch_subject_prefix;
-	rev->first_parent_only = default_first_parent;
 	DIFF_OPT_SET(&rev->diffopt, ALLOW_TEXTCONV);
 
 	if (default_date_mode)
@@ -398,8 +397,8 @@ static int git_log_config(const char *var, const char *value, void *cb)
 		use_mailmap_config = git_config_bool(var, value);
 		return 0;
 	}
-	if (!strcmp(var, "log.firstparent")) {
-		default_first_parent = git_config_bool(var, value);
+	if (!strcmp(var, "log.defaultimpliesfirstparent")) {
+		default_implies_first_parent = git_config_bool(var, value);
 		return 0;
 	}
 
@@ -504,6 +503,8 @@ static int show_tree_object(const unsigned char *sha1,
 
 static void show_rev_tweak_rev(struct rev_info *rev, struct setup_revision_opt *opt)
 {
+	if (default_implies_first_parent && !rev->pending.nr)
+		rev->first_parent_only = 1;
 	if (rev->ignore_merges) {
 		/* There was no "-m" on the command line */
 		rev->ignore_merges = 0;


It feels somewhat magical, but at least the config option name makes it
painfully clear exactly when it would kick in. I dunno. I am happy
enough for myself to just run "--first-parent" when that is what I want
to see. Giving it a shorter name would not help much, I think. It is not
the number of characters, but the fact that most people do not _know_
that --first-parent exists in the first place, or that it would be
useful in this case. I hoped with a config option it might become
something projects could recommend to their users[1] if the project has a
matching workflow. But maybe we could also rely on those same projects
to educate their users.

-Peff

[1] And if not an official recommendation from a project, this is the
    sort of "tips and tricks" information that may spread informally. But in
    theory so could knowledge of --first-parent.

  reply	other threads:[~2015-07-25  2:05 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-23  1:23 [RFC/PATCH] log: add log.firstparent option Jeff King
2015-07-23  4:40 ` Config variables and scripting // was " David Aguilar
2015-07-23  5:14   ` Jeff King
2015-07-23  5:48     ` Jeff King
2015-07-23  6:32       ` Jacob Keller
2015-07-23  6:53         ` Jeff King
2015-07-23  6:55           ` Jacob Keller
2015-07-23  9:53             ` Michael J Gruber
2015-07-23 17:35               ` Jeff King
2015-07-23 17:37     ` Junio C Hamano
2015-07-23 22:14 ` Stefan Beller
2015-07-24  7:40   ` Jeff King
2015-07-24  7:46     ` Jacob Keller
2015-07-24  8:17       ` Jeff King
2015-07-24 15:31     ` Junio C Hamano
2015-07-25  1:36       ` Jeff King
2015-07-25  1:47         ` Jeff King
2015-07-25 17:18           ` Junio C Hamano
2015-07-27  4:43             ` Jeff King
2015-07-23 22:46 ` Junio C Hamano
2015-07-24  6:07   ` Jacob Keller
2015-07-24  7:34     ` Jeff King
2015-07-24  7:44       ` Jacob Keller
2015-07-24 15:04       ` Junio C Hamano
2015-07-24 18:13         ` Jeff King
2015-07-24  7:21   ` Jeff King
2015-07-24  7:23   ` Jeff King
2015-07-24 15:07     ` Junio C Hamano
2015-07-25  2:05       ` Jeff King [this message]
2015-07-25 17:41         ` Junio C Hamano
2015-07-25 22:41           ` Jacob Keller
2015-07-27  4:55           ` Jeff King

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=20150725020526.GA8948@peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=josharian@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.