darcs

Issue 2702 darcs log -t '' fails with "This is a bug!"

Title darcs log -t '' fails with "This is a bug!"
Priority Status resolved
Milestone Resolved in 2.18.1
Superseder Nosy List falsifian
Assigned To
Topics

Created on 2023-05-18.16:34:58 by falsifian, last changed 2023-06-24.20:29:44 by noreply.

Messages
msg23267 (view) Author: falsifian Date: 2023-05-18.16:34:54
1. Summarise the issue (what were doing, what went wrong?)

In a darcs repo, run:
    darcs log -t ''

Output:

This is a bug! Please report it at http://bugs.darcs.net or via email to bugs@darcs.net:
Explict error in module Text.Regex.TDFA.String : Text.Regex.TDFA.String died: parseRegex for Text.Regex.TDFA.String failed:(line 1, column 1):
unexpected end of input
expecting empty () or anchor ^ or $ or an atom
CallStack (from HasCallStack):
  error, called at lib/Text/Regex/TDFA/Common.hs:29:3 in regex-tdfa-1.3.1.2-inplace:Text.Regex.TDFA.Common


2. What behaviour were you expecting instead?

I was hoping this would show a log with just tags. I worked around it with
    darcs log -t .

3. What darcs version are you using? (Try: darcs --exact-version)

From OpenBSD ports:

darcs compiled on May  8 2023, at 07:59:54

Weak Hash: not available

Context:

[TAG 2.16.5
Ganesh Sittampalam <ganesh@earth.li>**20220220083531
 Ignore-this: 51417cb5dd488dc0d962ffb051f63ee1
] 

4. What operating system are you running?

OpenBSD-current on amd64
msg23281 (view) Author: bfrk Date: 2023-05-28.22:36:07
The only bug here is that darcs falsely claims it is a bug. The empty 
string is not a valid regular expression and you get similar errors when 
using e.g. '['. This should be reported as a regular failure, not as a 
bug in darcs.

The problem is that the code in Darcs.Util.Regex calls makeRegexOpts 
which in turn calls error if the argument is not a valid regular 
expression.

This should be easy to fix by using makeRegexOptsM instead, which has a 
MonadFail constraint and calls out to fail. We just need a suitable 
Monad where fail throws an exception other than ErrorCall.
msg23282 (view) Author: falsifian Date: 2023-05-28.22:44:14
> The only bug here is that darcs falsely claims it is a bug. The empty 
> string is not a valid regular expression and you get similar errors when 
> using e.g. '['. This should be reported as a regular failure, not as a 
> bug in darcs.
> 
> The problem is that the code in Darcs.Util.Regex calls makeRegexOpts 
> which in turn calls error if the argument is not a valid regular 
> expression.

Oh, that's interesting! I expected the empty string to work. For
example, the Unix command "grep ''" works fine on my system (just echoes
every line of input).

It would be nice if there were a less-hacky way to see a log of tags. My
"-t ." workaround bugs me a tiny bit because I don't know whether or not
a tag's message can be empty. Anyway, probably not worth worrying about.
Thanks for the diagnosis.
msg23284 (view) Author: bfrk Date: 2023-05-29.09:56:44
You can also use `darcs show tags` to see all tags, though this 
shows only the tag names, not the patch hashes, date, author etc.

Recording an empty tag is probably difficult as we guard against 
that in various places nowadays, but we can't exclude the 
possibility that old repos may contain such a tag. To be on the safe 
side, use `darcs log -t '.*'.
msg23285 (view) Author: bfrk Date: 2023-05-29.10:19:00
We use regex-tdfa which is very strict regarding the POSIX regex 
standard. My grep also accepts '' and then acts like cat. This is an 
ad-hoc GNU extension: you can clearly see the difference in behavior 
between '' and '.*' with --color=auto.
msg23405 (view) Author: noreply Date: 2023-06-24.20:29:41
The following patch sent by Ben Franksen <ben.franksen@online.de> updated issue issue2702 with
status=resolved;resolvedin=2.18.1

Hash: 5d5116ed7d0cc2ca6efc91828e729b6c5e6ab833
Author: Ben Franksen <ben.franksen@online.de>
* resolve issue2702: invalid regex is treated like a bug in darcs

  The only tricky part here is that before ghc-8.8/base-4.13.0 regex-tdfa
  calls the 'fail' from class Monad, not the one from class MonadFail.
History
Date User Action Args
2023-05-18 16:34:58falsifiancreate
2023-05-28 22:36:07bfrksetmessages: + msg23281
2023-05-28 22:44:14falsifiansetmessages: + msg23282
2023-05-29 09:56:45bfrksetmessages: + msg23284
2023-05-29 10:19:00bfrksetmessages: + msg23285
2023-06-24 20:29:44noreplysetstatus: unknown -> resolved
messages: + msg23405
resolvedin: 2.18.1