Antiderivatives in complex analysis

Let $U$ be an open set in $\mathbb{C}$ and $f: U \to E$ be holomorphic on $U.$ Let now $\gamma$ be a path in $U$ that begins with $z_1\in U$ and ends with $z_2 \in U.$ I wonder for which assumptions the following formula $$\int_\gamma \frac{d f}{dz}(z) = f(z_2)-f(z_1)$$ is true ?

I have found many counterexamples (such as $f'(z) = \frac 1z$) where the above formula fails if the set $U$ is not simply connected. Here is a related result.

Another question, if $f$ is well defined on $\bar{U}$ and $z_1 \in \partial U$ is the above formula also true ?

If $f$ is holomorphic in $U \subset \Bbb C$ and $\gamma$ is a (piecewise differentiable) path in $U$ joining $z_1$ and $z_2$ then $$\int_\gamma f'(z)\, dz = \int_0^1 f'(\gamma(t)) \gamma'(t) \, dt = \bigl [ f(\gamma(t))\bigr ]_{t=0}^{t=1} = f(z_2) - f(z_1)$$
$$\int_{|z|=1} \frac 1z \, dz = 2 \pi i \ne 0$$ is not a counter-example, because $1/z$ is not the derivative of a holomorphic function $f$ in any domain containing the unit circle.
• Thank you for this answer. Is it true for points in $\partial U := \bar{U}\backslash U$ ? – A. PI Nov 15 '17 at 13:22
• @A.MONNET: If both $f$ and $f'$ extend continuously to the boundary then a limiting argument should work. – Martin R Nov 15 '17 at 13:26