Re: Don't show context menu for paths
Stefan via TortoiseSVN-dev <[email protected]> Sun, 15 Sep 2024 10:24:21 -0700 (PDT)
| Newsgroups | gmane.comp.version-control.subversion.tortoisesvn.devel |
|---|---|
| Message-ID | <[email protected]> |
------=_Part_143394_25657575.1726421061901
Content-Type: multipart/alternative;
boundary="----=_Part_143395_886761339.1726421061901"
------=_Part_143395_886761339.1726421061901
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
On Sunday, September 15, 2024 at 4:13:52=E2=80=AFPM UTC+2 daniel.l...@gmail=
.com=20
wrote:
This is handled in ShellCache::IsContextPathAllowed(LPCWSTR path). If=20
right-clicking the folder itself, path will be c:\temp\wc
I'm considering to check the list of ignored paths for a trailing \* as=20
follows (adding the ternary operator to check for \\).
if (!I->empty() && I->at(I->size() - 1) =3D=3D '*')
{
std::wstring str =3D I->substr(0, I->size() - *(I->at(I->size()=
-=20
2) =3D=3D '\\' ? 2 : *1*)*);
but first check that the string has at least two chars, otherwise a -2=20
would make it crash.
=20
Then c:\temp\wc\* would work, but it might crash on a single * (didn't=20
check yet).
Or to check separately for trailing \:
else if (!I->empty() && I->at(I->size() - 1) =3D=3D '\')
{
std::wstring str =3D I->substr(0, I->size() - 1);
if (_wcsnicmp(str.c_str(), path, str.size()) =3D=3D 0)
return FALSE;
}
that would work too. I don't really have a preference here.
=20
Basically treating \ as a wildcard character - then you could add=20
c:\temp\wc\ as "ignore the wc folder and everything below".
What do you think? Any risk of regressions?
No, no risk of regressions.
=20
While I was at it, I'd suggest to remove the check for !I->empty() in the=
=20
if statement. There is already a separate statement:
if (I->empty())
continue;
just above. So we KNOW that I->empty() is false. Do I miss something here?=
=20
(For comparison, TortoiseGit don't have that !I->empty() check).
yes, you can remove that.
Stefan
--=20
You received this message because you are subscribed to the Google Groups "=
TortoiseSVN-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/=
tortoisesvn-dev/e3b1f0ee-16c3-44e5-8fa4-dbf6e168da07n%40googlegroups.com.
------=_Part_143395_886761339.1726421061901
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div><div dir=3D"auto">On Sunday, September 15, 2024 at 4:13:52=E2=80=AFPM =
UTC+2 [email protected] wrote:<br /></div><blockquote style=3D"margin: =
0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left:=
1ex;"><div>This is handled in ShellCache::IsContextPathAllowed(LPCWSTR pat=
h). If right-clicking the folder itself, path will be c:\temp\wc<br /></div=
><div><br /></div><div>I'm considering to check the list of ignored paths f=
or a trailing \* as follows (adding the ternary operator to check for \\).<=
/div><div><br /></div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (!I->empty() &&=
amp; I->at(I->size() - 1) =3D=3D '*')<br />=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 {<br /><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 std::wstring str =
=3D I->substr(0, I->size() - <b>(I->at(I->size() - 2) =3D=3D '\=
\' ? 2 : </b>1<b>)</b>);<br /></div></blockquote><div><br /></div><div>but =
first check that the string has at least two chars, otherwise a -2 would ma=
ke it crash.</div><div>=C2=A0</div><blockquote style=3D"margin: 0px 0px 0px=
0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div=
></div><div>Then c:\temp\wc\* would work, but it might crash on a single * =
(didn't check yet).<br /></div><div><br /></div><div>Or to check separately=
for trailing \:</div><div><br /></div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 els=
e if (!I->empty() && I->at(I->size() - 1) =3D=3D '\')<br /=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 {<br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 std::wstring str =3D I->substr(0, I->size() - 1);<br />=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (_wcsnicmp(str.c_str(), path, str.size()=
) =3D=3D 0)<br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 re=
turn FALSE;<br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br /></div><div><br /></div>=
</blockquote><div><br /></div><div>that would work too. I don't really have=
a preference here.</div><div>=C2=A0</div><blockquote style=3D"margin: 0px =
0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex=
;"><div></div><div>Basically treating \ as a wildcard character - then you =
could add c:\temp\wc\ as "ignore the wc folder and everything below".</div>=
<div><br /></div><div>What do you think? Any risk of regressions?</div></bl=
ockquote><div><br /></div><div>No, no risk of regressions.</div><div>=C2=A0=
</div><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px soli=
d rgb(204, 204, 204); padding-left: 1ex;"><div><br /></div><div>While I was=
at it, I'd suggest to remove the check for !I->empty() in the if statem=
ent. There is already a separate statement:</div><div><br /></div><div>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 if (I->empty())<br />=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 continue;<br /></div><div><br /></div><div>just above. So=
we KNOW that I->empty() is false. Do I miss something here? (For compar=
ison, TortoiseGit don't have that !I->empty() check).</div><div><br /></=
div></blockquote><div><br /></div><div>yes, you can remove that.</div><div>=
<br /></div><div>Stefan</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;TortoiseSVN-dev" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">tor=
[email protected]</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/d/msgid/tortoisesvn-dev/e3b1f0ee-16c3-44e5-8fa4-dbf6e168da07n%40googlegr=
oups.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/=
d/msgid/tortoisesvn-dev/e3b1f0ee-16c3-44e5-8fa4-dbf6e168da07n%40googlegroup=
s.com</a>.<br />
------=_Part_143395_886761339.1726421061901--
------=_Part_143394_25657575.1726421061901--