Re: Clearing logic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/03, Rohit Ashiwal wrote:
> On 2019-03-03 13:33 UTC Junio C Hamano <gitster@xxxxxxxxx> wrote:
> 
> > test -s <path> makes sure <path> is file; if it is not a file, then
> > it won't yield true.
> 
> > On 2019-03-03 13:20 UTC Rohit Ashiwal <rohit.ashiwal265@xxxxxxxxx> wrote:
> > > test_path_is_file "$1" &&
> > > 	if ! test -s "$1"
> 
> According to the conditional if the path is not a file then we will get
> the error "file does not exist" and then we will shortcircuit without checking
> the second conditional, on the other hand, if path is a file then we will
> again check if it has a size greater than zero, then error will be different
> (if any).

I do agree that the better error message is probably worth the
additional 'test_path_is_file' before the 'test -s'.  Although it may
be better to only make that distinction in the 'if' (and then maybe
just using 'test -f', which would explain better why we have an
additional call.

Either way it would be nice to describe that reasoning in the commit
message, as it's not 100% clear from the code what is going on here,
which also lead to Junio's question.

> Regards
> Rohit
> 



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux