You could customize the
whitespace-global-modes variable to be:
Edit: In fact, as pointed out by Julian Kniephoff in the comments, this would have to be a more complete list of magit modes, which is pretty cumbersome, and would need maintaining. Something like:
magit-mode magit-cherry-mode magit-diff-mode magit-log-mode
magit-process-mode magit-reflog-mode magit-refs-mode
magit-repolist-mode magit-revision-mode magit-stash-mode
magit-stashes-mode magit-status-mode magit-submodule-list-mode)
With that in mind, I couldn't really recommend this approach.
Edit 2: I don't recommend the following either (it's way too fiddly compared to just using advice), but if you particularly wanted to keep this variable populated dynamically using only hooks...
(setq whitespace-global-modes '(not magit-mode))
(defun my-inhibit-whitespace-mode-maybe ()
"Inhibit `global-whitespace-mode' for certain modes.
Used in `after-change-major-mode-hook', but before the global
mode is processed."
(when (derived-mode-p 'magit-mode)
(add-to-list 'whitespace-global-modes major-mode :append)))
(defun my-global-whitespace-mode-hook ()
"Custom behaviours for `global-whitespace-mode'."
;; n.b. We need `my-inhibit-whitespace-mode-maybe' to act before
;; `whitespace-turn-on-if-enabled' in `after-change-major-mode-hook'.
(remove-hook 'after-change-major-mode-hook 'my-inhibit-whitespace-mode-maybe)
(add-hook 'after-change-major-mode-hook 'my-inhibit-whitespace-mode-maybe)))
(add-hook 'global-whitespace-mode-hook 'my-global-whitespace-mode-hook)