git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Charles Bailey <charles@hashpling.org>
To: David Aguilar <davvid@gmail.com>
Cc: "Thomas Rast" <trast@student.ethz.ch>,
	"Junio C Hamano" <gitster@pobox.com>,
	git@vger.kernel.org, "Magnus Bäck" <magnus.back@sonyericsson.com>,
	"Avery Pennarun" <apenwarr@gmail.com>,
	"Theodore Ts'o" <tytso@mit.edu>
Subject: Re: [PATCH] mergetool: Skip autoresolved paths
Date: Fri, 20 Aug 2010 10:57:50 +0100	[thread overview]
Message-ID: <4C6E519E.1080700@hashpling.org> (raw)
In-Reply-To: <20100820035236.GA18267@gmail.com>

On 20/08/2010 04:52, David Aguilar wrote:
>
> git-mergetool lines 295-307:
>
>      files_to_merge |
>      while IFS= read i
>      do
> 	if test $last_status -ne 0; then
> 	    prompt_after_failed_merge<  /dev/tty || exit 1
> 	fi
> 	printf "\n"
> 	merge_file "$i"<  /dev/tty>  /dev/tty
> 	last_status=$?
> 	if test $last_status -ne 0; then
> 	    rollup_status=1
> 	fi
>      done
>
> The reason the test fails without a tty is that we've never
> exercised this code in the past.
>
> This commit did not introduce the "<  /dev/tty>  /dev/tty"
> idiom.  It was introduced in b0169d84 by Charles Bailey.
> What this commit did do was add test coverage to it,
> which is good because it uncovered this problem :-)
>
> Charles, is there another way we can write this?
> Is there a reason why we need the tty redirection?
> Can we drop it or is there a portability concern?
>
> FWIW, the merge_file call in the else clause that follows
> this section does not use tty redirection.
>

Actually, it's been like this since c4b4a5af which is when mergetool was 
introduced.

(b0169d84 didn't change this line, 0eea3451 but made only whitespace 
changes, it comes from the original mergetool code.)

When you say "drop it" what are you proposing to replace it with? We're 
in the middle of a shell pipe which has replaced stdin and merge_file 
needs access to the human on it's stdin; hence the </dev/tty. Strictly. 
I believe that the >/dev/tty isn't needed.

Is there some way of juggling file descriptors in shell? I had a quick 
play with this but suspect it's a bashism (and it might make mergetool 
less readable!).

echo hidden | { echo lost | cat 0<&3- ; } 3<&0

mergetool has never really been very approachable for automatic testing 
as it's fundamentally an interactive script. It would be nice if 
sufficient of the guts of mergetool were in testable library code and 
mergetool was just an obviously correct slim shell UI.

merge_file in the 'else' doesn't need the redirection as nobody has 
redirected the original stdin.

Charles.

  reply	other threads:[~2010-08-20 10:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-12 21:28 Status of conflicted files resolved with rerere Magnus Bäck
2010-08-12 21:36 ` Avery Pennarun
2010-08-13 17:19   ` Jay Soffian
2010-08-15  2:24   ` David Aguilar
2010-08-15  6:59     ` Junio C Hamano
2010-08-15 16:00       ` Magnus Bäck
2010-08-17  9:22       ` [PATCH] mergetool: Skip autoresolved paths David Aguilar
2010-08-19 10:02         ` Thomas Rast
2010-08-20  3:52           ` David Aguilar
2010-08-20  9:57             ` Charles Bailey [this message]
2010-08-20 10:09               ` Jonathan Nieder
2010-08-20 11:17             ` [PATCH] mergetool: Remove explicit references to /dev/tty Charles Bailey
2010-08-20 12:27               ` Jonathan Nieder
2010-08-20 13:50                 ` Charles Bailey
2010-08-20 14:19                   ` Jonathan Nieder
2010-08-20 15:25                 ` [PATCH v2] " Charles Bailey

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=4C6E519E.1080700@hashpling.org \
    --to=charles@hashpling.org \
    --cc=apenwarr@gmail.com \
    --cc=davvid@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=magnus.back@sonyericsson.com \
    --cc=trast@student.ethz.ch \
    --cc=tytso@mit.edu \
    /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).