bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#37189: 25.4.1: vc-hg-ignore implementation is missing


From: Eli Zaretskii
Subject: bug#37189: 25.4.1: vc-hg-ignore implementation is missing
Date: Fri, 14 Feb 2020 11:23:19 +0200

> Cc: address@hidden
> From: Dmitry Gutov <address@hidden>
> Date: Fri, 14 Feb 2020 01:40:31 +0200
> 
> I think the first thing I'll have to do is revert a part of an earlier 
> patch to vc-default-ignore which changed its semantics a little, because 
> it doesn't look like this discussion is going to culminate in a patch 
> small enough for emacs-27 anyway.

Which part?  Can you show a proposed patch?

> Then, naturally, we'll have to look for small changes that improve the 
> situation but provide as little breakage as possible.

Agreed.

> > I did arrive at a few conclusions after studying the issues raised in
> > the discussions, so if you want, I can post those conclusions FTR, if
> > for nothing else.
> 
> Yes, of course, please go ahead.

OK, here goes:

1) vc-dir-ignore:

It calculates the file name for the entry into the ignore file, and
thus must escape any characters in the file name that are special in
ignore files -- which is backend-specific.

The file name should also be "anchored", at least ideally, so that no
other file is accidentally ignored.  This is also backend-specific.

VC's support for directory-specific ignore files is inconsistent: they
are supported for CVS (and actually mandatory there) and maybe SVN,
but not for Git/Bazaar/Mercurial/Monotone -- for the latter we only
support ignore files in the repository root.  This could be improved
in the future, but for now I don't see an immediate need.

The fact that vc-dir-ignore calls vc-ignore produces contradictions,
because vc-ignore is supposed to handle file-name patterns (whether
wildcards or regexps), whereas vc-dir-ignore never sends patterns, and
also because with vc-ignore the user should get to decide whether to
anchor the file name or pattern.  So I think vc-dir-ignore's
implementation should be eventually rewritten to call the backends
directly instead of relying on vc-ignore.

2) vc-ignore:

Prompts the user for the file name or pattern to add to the ignore
file, and therefore the escaping and anchoring is the user's
responsibility.  It should basically just find the ignore file and
add/remove an entry to/from there.

It should not assume the argument is a simple file name, therefore
using the likes of expand-file-name and file-name-nondirectory is not
a good idea.  For example, Git patterns that are "anchored" start with
a slash, which will cause unexpected results if used in a "file name".
As another example, backslashes used for escaping special characters
will be interpreted on Windows as directory separators, again leading
to unexpected results.  Therefore, vc-default-ignore should not use
file-name related primitives, but instead use concat and substring (if
needed).

For the same reason, using read-file-name here is too naïve, as well
as yielding an absolute file name from what the user types.

If you agree with the above, we then need to decide what, if anything,
of this should be fixed for Emacs 27.  E.g., vc-dir-ignore seems to be
OK if the file name doesn't include special characters, does it?

Thanks.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]