From: Jeff King <peff@peff.net>
To: Tay Ray Chuan <rctay89@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
Git Mailing List <git@vger.kernel.org>,
Thomas Rast <trast@student.ethz.ch>
Subject: Re: [PATCH v2 4/4] allow recovery from command name typos
Date: Thu, 26 Jul 2012 13:26:30 -0400 [thread overview]
Message-ID: <20120726172630.GD13942@sigill.intra.peff.net> (raw)
In-Reply-To: <CALUzUxp91zubHEkWMC1z2xp7kJCRYrtznQS_=pVSZoNkZMihig@mail.gmail.com>
On Fri, Jul 27, 2012 at 01:08:34AM +0800, Tay Ray Chuan wrote:
> > Perhaps we should audit "isatty()" calls and replace them with a
> > helper function that does this kind of thing consistently in a more
> > robust way (my recent favorite is Linus's somewhat anal logic used
> > in builtin/merge.c::default_edit_option()).
>
> Any specific callers to isatty() you have in mind? A quick grep shows
> that a significant portion of the "offenders" are isatty(2) calls to
> determine whether to display progress, I think those are ok.
Yeah, those are probably fine. Grep reveals that besides isatty(2) and
the merge default_edit_option check, we have:
- isatty(1) for checking auto-output munging, including auto-colors,
auto-columns, and the pager. These are all fine, as they are not
about interactivity, but specifically about whether stdout is a tty.
- isatty(0) in commit.c to print a message when reading "-F -" from
stdin. OK.
- isatty(0) in pack-redundant to avoid reading stdin when it is a
terminal (a questionable choice, perhaps, but not really something
that would want a full interactivity check).
- isatty(0) check in cmd_revert to set opts.edit automatically. This
one should match merge's behavior.
- isatty(0) in shortlog; this is a compatibility hack as shortlog
traditionally accepted log output on stdin, but can now be used
stand-alone. OK.
So I think the only one that could be improved is the one in cmd_revert.
> The credential helper has some prompting functionality that is close
> to what I intend to do here, but I think it can make some assumptions
> about stdin/stdout that we can't, as you have pointed out. So that
> leaves merge-edit and this patch as the beneficiaries of a
> builtin/merge.c::default_edit_option() refactor. That's just off the
> top of my head.
The credential code uses git_terminal_prompt, which actually opens
/dev/tty directly. So it is probably sane to use for your new prompt,
but it does not (and should not) rely on isatty.
> Perhaps the helper function could be named "git_can_prompt()" and
> placed in prompt.c?
Please don't. The isatty() checks have nothing to do with whether
git_prompt can run. The only thing such a git_can_prompt function should
do is see if we can open /dev/tty.
The isatty check in merge.c is more about "are we interactive, so that
it is sane to run $EDITOR".
-Peff
next prev parent reply other threads:[~2012-07-26 17:26 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-06 6:55 [PATCH 0/4] allow recovery from command name typos Tay Ray Chuan
2012-05-06 6:55 ` [PATCH 1/4] help.c::uniq: plug a leak Tay Ray Chuan
2012-05-06 6:55 ` [PATCH 2/4] help.c::exclude_cmds: " Tay Ray Chuan
2012-05-06 6:55 ` [PATCH 3/4] help.c: plug a leak when help.autocorrect is set Tay Ray Chuan
2012-05-06 6:55 ` [PATCH 4/4] allow recovery from command name typos Tay Ray Chuan
2012-05-06 8:21 ` Jeff King
2012-05-06 16:07 ` Tay Ray Chuan
2012-05-07 9:43 ` Thomas Rast
2012-05-07 15:49 ` Tay Ray Chuan
2012-05-07 17:41 ` Junio C Hamano
2012-05-09 15:06 ` Tay Ray Chuan
2012-05-09 17:03 ` Junio C Hamano
[not found] ` <CAOBOgRaDEgAqXWmdC6hrudkL5OwzeMffbj2RtKMxf2TsYWzotA@mail.gmail.com>
2012-05-06 16:04 ` Tay Ray Chuan
2012-05-06 8:12 ` [PATCH 1/4] help.c::uniq: plug a leak Jeff King
2012-05-06 15:54 ` Tay Ray Chuan
2012-05-07 7:30 ` Jeff King
2012-07-25 16:16 ` [PATCH v2 0/4] allow recovery from command name typos Tay Ray Chuan
2012-07-25 16:16 ` [PATCH v2 1/4] help.c::uniq: plug a leak Tay Ray Chuan
2012-07-25 16:16 ` [PATCH v2 2/4] help.c::exclude_cmds: realloc() before copy, " Tay Ray Chuan
2012-07-25 16:16 ` [PATCH v2 3/4] help.c: plug leaks with(out) help.autocorrect Tay Ray Chuan
2012-07-25 16:16 ` [PATCH v2 4/4] allow recovery from command name typos Tay Ray Chuan
2012-07-25 17:57 ` Junio C Hamano
2012-07-26 17:08 ` Tay Ray Chuan
2012-07-26 17:26 ` Jeff King [this message]
2012-07-26 17:59 ` Junio C Hamano
2012-07-26 18:37 ` Jeff King
2012-07-26 17:53 ` Junio C Hamano
2012-07-25 17:47 ` [PATCH v2 3/4] help.c: plug leaks with(out) help.autocorrect Junio C Hamano
2012-07-25 17:39 ` [PATCH v2 2/4] help.c::exclude_cmds: realloc() before copy, plug a leak Junio C Hamano
2012-08-05 18:45 ` [PATCH v3 0/2] allow recovery from command name typos Tay Ray Chuan
2012-08-05 18:45 ` [PATCH v3 1/2] add interface for /dev/tty interaction Tay Ray Chuan
2012-08-05 18:45 ` [PATCH v3 2/2] allow recovery from command name typos Tay Ray Chuan
2012-08-06 0:50 ` Junio C Hamano
2012-08-05 20:11 ` [PATCH v3 1/2] add interface for /dev/tty interaction Junio C Hamano
2012-08-06 19:45 ` Jeff King
2012-08-06 19:56 ` Jeff King
2012-08-06 20:01 ` 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=20120726172630.GD13942@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=rctay89@gmail.com \
--cc=trast@student.ethz.ch \
/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).