I'm struggling to understand how conditions on the metric put conditions on the holonomy group and vice-versa. My understanding is that the holonomy principle says that there's a one-to-one correspondence between parallel tensors, constant tensors (i.e. with $\nabla S=0$), and elements of the fibre $E_p$ preserved under the holonomy group.

I'm trying to understand the 2 following examples:

If $(M,g)$ is a manifold and we have a complex structure $J_p:T_pM\to T_pM$ such that $J_p$ is invariant under the holonomy group, I've read that in order to extend $J$ to the whole manifold we need Hol$(g)\subset U(n)$. Why? Isn't all we need that $P_\gamma(J_p)=J_p$. I know that $U(n)=GL(n,\mathbb{C})\cap O(2n)$. So why is the condition $P_\gamma(J_p)=J_p$ equivalent to $P_\gamma$ commuting with $J$ and preserving $g$?

The other example is showing that Hol$(g)\subset SO(n)$ if and only if $M$ is orientable. So to use the holonomy principle, start with non-zero $\alpha_p\in \Lambda^n(T^\ast_pM)$. We want $\alpha_p$ to be preserved under Hol$(g)$ so that it can be extended, by the holonomy principle, to a nowhere vanishing form. Again, we just need $\alpha_p$ to be fixed by the holonomy group. How does this happen if and only if the group is contained in SO$(n)$.

I apologize for asking 2 questions but I feel the concept I am missing is the same in both.

Thanks very much.

There are two issues here: On the one hand, if you have given the value of a tensor in one point $p\in M$, you can try to extend this to a parallel tensor over all of $M$. If $M$ is connected, then this is equivalent to the fact that this value is invariant under the holonomy group. The point here is that to define your extension in $x\in M$ you choose a curve connecting $p$ to $x$, and then transport your tensor parallely along this curve. The result is independent of the choice of the curve if and only if the value is invariant under the holonomy group. (Transporting there along one curve and back along the other means translating along a loop.)
The second issue is that usually the statements about holonomy groups are not formulated very carefully, since one does not distinguish between conjugated subgroups. In the unitary case, one should more precisely say that "Hol(g) is contained in a subgroup conjugate to $U(n)\subset O(2n)$". (That Hol(g) is contained in $O(n)$ follows immediately since $g$ is preserved by the Levi-Civita connection.) This simply means that "there is a complex structure $J_p$ on $T_pM$ for which $g(p)$ is Hermitian and which is invariant under Hol(g)". (The standard language comes from the fact that you just use this complex structure to identify $(T_pM,J_p,g(p))$ with $\mathbb C^n$ with the standard Hermitian inner product, and then Hol(g) really becomes a subgroup of $U(n)$. Then the condition exactly means that you can extend $J_p$ to a parallel tensor field on $M$. The facts that $J^2=-id$ and that $g$ is Hermitian for $J$ are preserved by parallel transport, this gives you an almost complex structure for which $g$ is Hermitian. Then $J$ has to be complex (integrable) since it is preserved by the torsion-free Levi-Civita connection of $g$.
Likewise, a subgroup of $O(n)$ preserves a non-zero element of $\Lambda^n\mathbb R^{n*}$ if and only if it is contained in $SO(n)$ (here there is no issue of conjugation).
I also realized that $J_p$ can also be thought of as a multilinear map $J_p:T_pM\times T^\ast_PM\to\mathbb{R}$ under the indentification $$J_p(X_p,\alpha_p)=\alpha_p(J_p(X_p)).$$ Parallel transport naturally extends to tensors of any type. In particular for a $k$-form $\sigma_p$ we would have $(P_\gamma\sigma_p)(X_1,\dots,X_q)=\sigma_p(P_\gamma^{-1}(X_1),\dots,P_\gamma^{-1}(X_k)$, where $X_1,\dots, X_k\in T_qM$ and $\gamma$ is a curve from $p$ to $q$. So working with the $(1,1)$-tensor $J_p$, and a curve $\gamma$ from $p$ to $q$, we have $$(P_\gamma J_p)(X_q,\alpha_q)=J_p(P_\gamma^{-1}X_q,P_\gamma^{-1}(\alpha_q))=P_\gamma^{-1}(\alpha_q)(J_p(P_\gamma^{-1}(X_q)))=\alpha_q(P_\gamma J_pP_\gamma^{-1}(X_q)).$$On the other hand $$J_q(X_q,\alpha_q)=\alpha_q(J_q(X_q)).$$So for these two to be equal we would need $$P_\gamma J_pP_\gamma^{-1}=J_q,$$that is $P_\gamma\in GL(m,\mathbb{C})$.