Does $\int_a^b f'(\gamma(t))\gamma'(t)\,dt$ depend on the path for meromorphic functions? Given a meromorphic function $f:\mathbb C\to\mathbb C$ and a smooth curve $\gamma:[a,b]\to\Gamma\subset\mathbb C$ with $\gamma(a)\neq\gamma(b)$, I am tempted to think the fundamental theorem of calculus yields
$$\int_a^b\underbrace{f'(\gamma(t))\gamma'(t)\,dt}_{=df} = f(\gamma(t))\Big|_{t=a}^b (*)$$
independently of the chosen path. However, taking a closed integral through both $\gamma(a)$ and $\gamma(b)\neq\gamma(a)$, the residue theorem $\oint f'(\gamma(t))\gamma'(t)\,dt = 2\pi i\sum_k\operatorname{Res}_k(f')$ proves me wrong when the closed curve surrounds a singularity of $f'$ since the two paths connecting $\gamma(a)$ and $\gamma(b)$ would otherwise cancel out the residue. So now my question is:
What correction term needs to be added to $(*)$? Can that be fixed at all, or did I miss something?

The correction term can be given in terms of the winding numbers $n(k,\gamma)$ of the directed curve $\gamma$ about the poles $k$ of $f$.  We have
$$\int_a^b f'(\gamma(t))\gamma'(t) dt = f(\gamma(t)) \bigg\vert_{a}^b +2\pi i \sum_k n(k,\gamma)\mathrm{Res}_k(f').$$
Intuitively, the winding number counts how many times a curve wraps around a single point.  For simple closed curves, this number will always be $0$, $1$, or $-1$, depending on whether or not the curve encloses the given point, and what direction the parametrization is given in.  Note that this formula recovers the Residue theorem (these results are pretty much equivalent, if you throw some topology under the rug), if we suppose that $\gamma$ is a closed curve.
