git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] mergetool: Skip autoresolved paths

From
Charles Bailey <charles@hashpling.org>
Date
Aug 20, 2010, 09:57 UTC
Message-ID
<4C6E519E.1080700@hashpling.org>
In-Reply-To
<20100820035236.GA18267@gmail.com>
On 20/08/2010 04:52, David Aguilar wrote:
Show 32 quoted lines
>
> 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.
Previous: David AguilarNext: Jonathan Nieder
Message 10 of 16 in “Status of conflicted files resolved with rerere”
  1. Magnus BäckAug 12, 2010
  2. Avery PennarunAug 12, 2010
  3. Jay SoffianAug 13, 2010
  4. David AguilarAug 15, 2010
  5. Junio C HamanoAug 15, 2010
  6. Magnus BäckAug 15, 2010
  7. mergetool: Skip autoresolved pathsDavid Aguilar, Aug 17, 2010
  8. Thomas RastAug 19, 2010
  9. David AguilarAug 20, 2010
  10. Charles BaileyAug 20, 2010
  11. Jonathan NiederAug 20, 2010
  12. mergetool: Remove explicit references to /dev/ttyCharles Bailey, Aug 20, 2010
  13. Jonathan NiederAug 20, 2010
  14. Charles BaileyAug 20, 2010
  15. Jonathan NiederAug 20, 2010
  16. mergetool: Remove explicit references to /dev/ttyCharles Bailey, Aug 20, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.