In topology, the Gluing Lemma states that two continuous functions $f:A\rightarrow X$ and $g:B\rightarrow X$ defined on closed subsets $A$ and $B$ will define a continuous function on the union $A\cup B$, provided that $f$ and $g$ agree on the intersection $A\cap B$. I am curious about what happens if we add smoothness everywhere. Consider the following statement:
If $A$ and $B$ are closed smooth submanifolds, with $f:A\rightarrow N$ and $g:B\rightarrow N$ smooth maps such that $f|_{A\cap B} = g|_{A\cap B}$, then $h:A\cup B\rightarrow N$ defined by $$h(x) = \begin{cases} f(x) & \text{if } x\in A \\ g(x) & \text{if } x\in B \end{cases}$$ is a smooth map.
Obviously this is not true in general, and the notion of a piecewise smooth curve is a fine counterexample. That being said, are there any non-trivial circumstances under which this statement might hold? e.g. what about if I add in the extra condition that $A$ and $B$ are codim-$0$ and $Int(A) \cap Int(B)$ is non-empty?