git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Haggerty <mhagger@alum.mit.edu>
To: David Turner <dturner@twopensource.com>
Cc: "Eric Sunshine" <sunshine@sunshineco.com>,
	"Git List" <git@vger.kernel.org>,
	"Christian Couder" <chriscool@tuxfamily.org>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
	"Jacob Keller" <jacob.keller@gmail.com>
Subject: Re: [PATCH v3 3/4] refs: make refs/worktree/* per-worktree
Date: Fri, 14 Aug 2015 10:18:13 +0200	[thread overview]
Message-ID: <55CDA445.9090503@alum.mit.edu> (raw)
In-Reply-To: <1439497946.8855.22.camel@twopensource.com>

On 08/13/2015 10:32 PM, David Turner wrote:
> On Thu, 2015-08-13 at 22:16 +0200, Michael Haggerty wrote:
>> On 08/13/2015 07:41 PM, David Turner wrote:
>>> On Thu, 2015-08-13 at 13:15 -0400, Eric Sunshine wrote:
>>>> On Wed, Aug 12, 2015 at 5:57 PM, David Turner <dturner@twopensource.com> wrote:
>>>>> diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
>>>>> index 93605f4..28e6dff 100755
>>>>> --- a/t/t0060-path-utils.sh
>>>>> +++ b/t/t0060-path-utils.sh
>>>>> +test_expect_success 'handle per-worktree refs in refs/worktree' '
>>>>> +       git commit --allow-empty -m "initial commit" &&
>>>>> +       git worktree add -b branch worktree &&
>>>>> +       (
>>>>> +               cd worktree &&
>>>>> +               git commit --allow-empty -m "test commit"  &&
>>>>> +               git for-each-ref | test_must_fail grep refs/worktree &&
>>>>
>>>> s/test_must_fail/!/
>>>>
>>>> From t/README:
>>>>
>>>>    On the other hand, don't use test_must_fail for running regular
>>>>    platform commands; just use '! cmd'.  We are not in the business
>>>>    of verifying that the world given to us sanely works.
>>>
>>> When I make that change, my test fails with:
>>>
>>> FATAL: Unexpected exit with code 2
>>>
>>> Apparently, you can't use ! in pipelines like that.  So that's why I
>>> used test_must_fail.
>>
>> You would have to negate the whole pipeline, like
>>
>>     ! git for-each-ref | grep refs/worktree
>>
>> The result of a pipeline is taken from the last command.
> 
> Yes, but that would pass if for-each-ref fails, which I do not want.  
> 
> Jacob's suggestion of parentheses around (! grep refs/worktree) seems to
> work.

I don't see how that can help. The result of a pipeline is taken from
the last command. The exit codes of earlier commands in the pipeline are
lost in the sands of time:

    $ false | true
    $ echo $?
    0
    $ false | ( ! false )
    $ echo $?
    0

Working around this POSIX shell limitation is surprisingly awkward in a
general-purpose script. But in this case you could use a temporary file:

    git for-each-ref >refs-actual &&
    ! grep refs/worktree <refs-actual && [...]

Michael

-- 
Michael Haggerty
mhagger@alum.mit.edu

  reply	other threads:[~2015-08-14  8:18 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-12 21:57 [PATCH v3 1/4] refs: clean up common_list David Turner
2015-08-12 21:57 ` [PATCH v3 2/4] path: optimize common dir checking David Turner
2015-08-12 22:48   ` Junio C Hamano
2015-08-13  9:05   ` Michael Haggerty
2015-08-14 17:04     ` Junio C Hamano
2015-08-14 20:04       ` David Turner
2015-08-14 20:27         ` Junio C Hamano
2015-08-14 20:54           ` David Turner
2015-08-15 18:20         ` Michael Haggerty
2015-08-15 18:12       ` Michael Haggerty
2015-08-17 15:55         ` Junio C Hamano
2015-08-15  7:59   ` Duy Nguyen
2015-08-16  5:04     ` David Turner
2015-08-16 12:20       ` Duy Nguyen
2015-08-12 21:57 ` [PATCH v3 3/4] refs: make refs/worktree/* per-worktree David Turner
2015-08-13 17:15   ` Eric Sunshine
2015-08-13 17:41     ` David Turner
2015-08-13 20:16       ` Michael Haggerty
2015-08-13 20:32         ` David Turner
2015-08-14  8:18           ` Michael Haggerty [this message]
2015-08-14 17:10             ` Junio C Hamano
2015-08-15  8:04   ` Duy Nguyen
2015-08-12 21:57 ` [PATCH v3 4/4] bisect: make bisection refs per-worktree David Turner
2015-08-15  7:44 ` [PATCH v3 1/4] refs: clean up common_list Duy Nguyen

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=55CDA445.9090503@alum.mit.edu \
    --to=mhagger@alum.mit.edu \
    --cc=chriscool@tuxfamily.org \
    --cc=dturner@twopensource.com \
    --cc=git@vger.kernel.org \
    --cc=jacob.keller@gmail.com \
    --cc=pclouds@gmail.com \
    --cc=sunshine@sunshineco.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.
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).