git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: kusmabite@gmail.com
Cc: git@vger.kernel.org
Subject: Re: [PATCH] merge: use editor by default in interactive sessions
Date: Thu, 23 Feb 2012 12:26:18 -0800	[thread overview]
Message-ID: <7vlint2t5h.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <7vd3954ame.fsf@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Thu, 23 Feb 2012 11:23:37 -0800")

Junio C Hamano <gitster@pobox.com> writes:

> Erik Faye-Lund <kusmabite@gmail.com> writes:
>
>>> +       /* Use editor if stdin and stdout are the same and is a tty */
>>> +       return (!fstat(0, &st_stdin) &&
>>> +               !fstat(1, &st_stdout) &&
>>> +               isatty(0) &&
>>> +               st_stdin.st_dev == st_stdout.st_dev &&
>>> +               st_stdin.st_ino == st_stdout.st_ino &&
>>> +               st_stdin.st_mode == st_stdout.st_mode);
>>
>> I just stumbled over this code, and I got a bit worried; the
>> stat-implementation we use on Windows sets st_ino to 0, so
>> "st_stdin.st_ino == st_stdout.st_ino" will always evaluate to true.
>>
>> Perhaps we should add a check for isatty(1) here as well? ...
>> Or is there something I'm missing here?
>
> No, the intention was ...

s/No,/No, you are not missing anything./;

I'll queue it with this explanation:

    merge: do not trust fstat(2) too much when checking interactiveness
    
    The heuristic used by "git merge" to decide if it automatically gives an
    editor upon clean automerge is to see if the standard input and the
    standard output is the same device and is a tty, we are in an interactive
    session.  "The same device" test was done by comparing fstat(2) result on
    the two file descriptors (and they must match), and we asked isatty() only
    for the standard input (we insist that they are the same device and there
    is no point asking tty-ness of the standard output).
    
    The stat(2) emulation on Windows port however does not give a usable value
    in st_ino field, so even if the standard output is connected to something
    different from the standard input, "The same device" test may incorrectly
    return true. To accomodate it, add another isatty() check for the standard
    output stream as well.
    
    Reported-by: Erik Faye-Lund <kusmabite@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>

Thanks.

  reply	other threads:[~2012-02-23 20:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-23 22:18 [PATCH] merge: use editor by default in interactive sessions Junio C Hamano
2012-01-23 22:27 ` Michael Haggerty
2012-01-23 22:34   ` Junio C Hamano
2012-01-30 17:06 ` Thomas Rast
2012-01-30 18:17   ` Junio C Hamano
2012-01-30 20:25     ` [PATCH] merge: add instructions to the commit message when editing Thomas Rast
2012-01-30 21:03       ` Junio C Hamano
2012-01-30 21:43         ` Thomas Rast
2012-01-30 21:52           ` Junio C Hamano
2012-01-31  7:46             ` Thomas Rast
2012-02-23 12:43 ` [PATCH] merge: use editor by default in interactive sessions Erik Faye-Lund
2012-02-23 19:23   ` Junio C Hamano
2012-02-23 20:26     ` Junio C Hamano [this message]
2012-02-23 20:31       ` Erik Faye-Lund

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vlint2t5h.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=kusmabite@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).