GetHEADRevision with illegal URL

11 views
Skip to first unread message

Daniel Sahlberg

unread,
Dec 11, 2022, 12:26:29 PM12/11/22
to TortoiseSVN-dev
Hi,

Once again double checking my assumptions regarding the code. In the user group there [1] is a discussion where I believe the error is caused by GetHEADRevision returning a revision even when the URL is invalid.

The following patch is using svn_ra_stat to check if the path exists and it seems to do what it is supposed to do.

[[[
--- C:/Users/danie/AppData/Local/Temp/SVN.cpp-revBASE.svn005.tmp.cpp    tis jun  7 17:38:11 2022
+++ C:/Devel/tortoisesvn_trunk/src/SVN/SVN.cpp    sön dec 11 17:34:23 2022
@@ -2733,0 +2734,13 @@ svn_revnum_t SVN::GetHEADRevision(const CTSVNPath&
+
+        /* Check if path actually exist */
+        svn_dirent_t *dirent;
+        SVNTRACE(
+            svn_ra_stat(raSession, "", rev, &dirent, localPool),
+            urla);
+        if (dirent == nullptr)
+        {
+            CString message(MAKEINTRESOURCE(IDS_SVN_URL_NONEXISTENT_IN_REV));
+            m_err = svn_error_createf(SVN_ERR_RA_ILLEGAL_URL, NULL, CUnicodeUtils::GetUTF8(message).GetString(), urla, rev);
+            return -1;
+        }
+
]]]

Will this break any other assumptions, where GetHEADRevision is assumed to return HEAD for an arbitrary path within the repository? I checked quickly in RepoBrowser but that seemed to work fine.

Kind regards,
Daniel


Stefan

unread,
Dec 14, 2022, 11:38:41 AM12/14/22
to TortoiseSVN-dev
I think this should be ok. Please commit.

Stefan

Daniel Sahlberg

unread,
Dec 15, 2022, 4:10:09 PM12/15/22
to TortoiseSVN-dev
Thanks, r29499.
Reply all
Reply to author
Forward
0 new messages