I want
\begin{equation}
\int\_a^b f(g(x))dg=\int\_{g(a)}^{g(b)} f(t)dt,\tag{$\heartsuit$}\label{heart}
\end{equation}
where $g$ is a continuous but not necessarily monotone (or bounded variation) function of $[a,b]$, both integrals are Riemann–Stieltjes (that is, $\int\_a^b h(x)dg(x)$ is the limit of Riemann–Stieltjes sums $\sum\_{i=0}^{n-1} h(c\_i)(g(x\_{i+1})-g(x\_i))$ where $a=x\_0<x\_1<\dotsb<x\_n=b$ is a partition of $[a,b]$, $c\_i\in [x\_i,x\_{i+1}]$ for $i=0,\dotsc,n-1$, and $\max \lvert x\_{i+1}-x\_i\rvert$ goes to 0).

If both integrals in \eqref{heart} exist, does it follow that they are equal?

Note that without continuity of $g$ this is not necessarily so, even if $g$ is increasing: say, if $a=0$, $b=1$, $g(x)=\chi\_{[1/2,1]}$, and $f(0)=f(1)=0$, then LHS is 0 but RHS may be non-zero. For increasing continuous $g$ this is less or more obvious. But we sometimes would like to have not monotone change of variables (cf. $\int\_a^b f(x^2)x\,dx=\frac12 \int\_{a^2}^{b^2} f(t)dt$ with $a<0<b$).

If not, what are additional conditions under which \eqref{heart} holds?