Integral of partial derivative

Given that $$\frac{\partial g_1}{\partial x_2} = \frac{\partial g_2}{\partial x_1}$$ How can I simplify the following? $$\int_0^{x_2}\frac{\partial g_2(x_1,y)}{\partial x_1}\,\mathrm dy.$$

Note: If I just rewrite it as $$\int_0^{x_2}\frac{\partial g_1(x_1,y)}{\partial x_2} \,\mathrm dy.$$ Doesn't it become zero? Because seems like $\frac{\partial g_1(x_1,y)}{\partial x_2}$ should be zero, as $g_1$ is not a function of $x_2$.

If it is not zero, then can I write $$\int_0^{x_2}\frac{\partial g_1(x_1,y)}{\partial x_2} \,\mathrm dy = \frac{\partial}{\partial x_2}\int_0^{x_2} g_1(x_1,y) \,\mathrm dy$$ ?

Your omission of the arguments in the first line has led to great confusion. I believe the first line should read $$\frac{\partial g_1(x_1,x_2)}{\partial x_2} = \frac{\partial g_2(x_1,x_2)}{\partial x_1}.$$
So we have $$\int_0^{x_2}\frac{\partial g_2(x_1,y)}{\partial x_1}\,dy = \int_0^{x_2}\frac{\partial g_1(x_1,y)}{\partial y}\,dy= \dots$$ I left the problem for you to finish.