All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Christian Couder <christian.couder@gmail.com>,
	Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
	Arjun Sreedharan <arjun024@gmail.com>,
	Philip Oakley <philipoakley@iee.org>, Git <git@vger.kernel.org>
Subject: Re: [PATCH] introduce git root
Date: Tue, 09 Dec 2014 10:17:13 -0800	[thread overview]
Message-ID: <xmqqoarcn0wm.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <20141205092752.GC32112@peff.net> (Jeff King's message of "Fri, 5 Dec 2014 04:27:52 -0500")

Jeff King <peff@peff.net> writes:

> But the one place I do not agree is:
>
>> I think "sequence.editor" and "core.editor" are better because:
>> 
>> - they use the same syntax as the config variables, so they are easier
>> to remember and to discover, and
>
> I really don't like using "core.editor" here, because it has the same
> name as a config variable, but it is _not_ the config variable. It
> happens to use the config variable as one of the inputs to its
> computation, but in many cases:
>
>   git config core.editor
>
> and
>
>   git var core.editor
>
> will produce different values. They are entirely different namespaces.
> Using the same syntax and name seems unnecessarily confusing to me.

I think this is a valid concern.

It is a tangent, the current definition of "git_editor" helper reads
like this:

        git_editor() {
                if test -z "${GIT_EDITOR:+set}"
                then
                        GIT_EDITOR="$(git var GIT_EDITOR)" || return $?
                fi

                eval "$GIT_EDITOR" '"$@"'
        }

If "git var editor" were to compute a reasonable value from the
various user settings, and because GIT_EDITOR is among the sources
of user settings, I wonder if the surrounding "if test -z then...fi"
should be there.

The pager side seems to do (halfway) "the right thing":

        git_pager() {
                if test -t 1
                then
                        GIT_PAGER=$(git var GIT_PAGER)
                else
                        GIT_PAGER=cat
                fi
                : ${LESS=-FRX}
                : ${LV=-c}
                export LESS LV

                eval "$GIT_PAGER" '"$@"'
        }

The initial "test -t 1" is "we do not page to non-terminal", but we
ask "git var" to take care of PAGER/GIT_PAGER fallback/precedence.

It is tempting to argue that "we do not page to non-terminal" should
also be part of "various user settings" for "git var" to take into
account and fold this "if test -t 1...then...else...fi" also into
"git var", but because a typical command line "git var" will be used
on would look like this:

	GIT_PAGER=$(git var pager)
        eval "$GIT_PAGER" ...

with the standard output stream of "git var" not connected to
terminal, that would not fly very well, and I am not sure what
should be done about it.

This is another tangent that comes back to the original "how to name
them?" question, but I wonder if a convention like this would work.

 * When asking for a feature (e.g. "what editor to use"), if there
   is a git-specific environment variable that can be set to
   override all other settings (e.g. "$GIT_EDITOR" trumps "$EDITOR"
   environment or "core.editor" configuration), "git var" can be
   queried with the name of that "strong" environment variable.

 * All other features without such a strong environment variables
   should not be spelled as if there is such an environment variable
   the user can set in order to avoid confusion.

Here are some consequences that come to my mind, if we adopt such an
approach:

 * We would keep GIT_EDITOR and GIT_PAGER (e.g. "git var
   GIT_EDITOR");

 * GIT_SEQUENCE_EDITOR is an example of an overriding environment
   variable, and as such, "what editor to use when munging the
   rebase insn sheet?", would be "git var GIT_SEQUENCE_EDITOR".

 * We would deprecate GIT_AUTHOR_IDENT and GIT_COMMITTER_IDENT
   because setting such an environment variable would not do
   anything.  Add "git var author-ident" that is clear that it does
   not name an environment variable as its replacement.

 * It is OK to add support for new queries, e.g. GIT_AUTHOR_DATE,
   for existing environment variables that we already take into
   account but that the current "git var" does not support.

Arguably, we could go the other way around.  Instead of adding "git
var author-ident", we actually allow GIT_AUTHOR_IDENT environment
variable to be set and used instead of GIT_AUTHOR_{NAME,EMAIL,DATE}.
If that approach is practical, then we could stick to the syntax
that looks like an environment variable name.  A script could then
instead of doing:

	GIT_AUTHOR_IDENT=$(git var GIT_AUTHOR_IDENT)
        ... parse it into NAME,EMAIL,DATE and ...
        export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE

        ... complicated set of operations to prepare ...

        git commit-tree ...

do this instead:

	GIT_AUTHOR_IDENT=$(git var GIT_AUTHOR_IDENT)
        export GIT_AUTHOR_IDENT

        ... complicated set of operations to prepare ...

        git commit-tree ...

  parent reply	other threads:[~2014-12-09 18:17 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-29 20:00 [PATCH] introduce git root Arjun Sreedharan
2014-11-29 23:08 ` Philip Oakley
2014-11-30  4:35   ` Arjun Sreedharan
2014-11-30 11:58     ` Matthieu Moy
2014-12-01  3:04       ` Junio C Hamano
2014-12-01  4:17         ` Christian Couder
2014-12-01  4:53           ` Junio C Hamano
2014-12-02  7:04           ` Jeff King
2014-12-02 10:05             ` Christian Couder
2014-12-02 17:26             ` Junio C Hamano
2014-12-04  9:22               ` Jeff King
2014-12-04 19:02                 ` Junio C Hamano
2014-12-04 20:00                   ` Matthieu Moy
2014-12-04 20:19                     ` Junio C Hamano
2014-12-04 21:12                   ` Jeff King
2014-12-04 21:30                     ` Junio C Hamano
2014-12-05  2:27                     ` Christian Couder
2014-12-05  9:27                       ` Jeff King
2014-12-07  5:23                         ` Christian Couder
2014-12-09 18:17                         ` Junio C Hamano [this message]
2014-12-10  9:16                           ` Christian Couder
2014-12-10 20:10                           ` Jeff King
2014-12-10 21:08                             ` Junio C Hamano

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=xmqqoarcn0wm.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=arjun024@gmail.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=philipoakley@iee.org \
    /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.