If the $HOME environment variable is set, prefer that to the entry in
/etc/passwd.
This brings us in line with almost every other utility and library on
UNIX-like systems while avoiding some of the more complicated
possibilities that have been suggested.
This incompatible change has been petitioned for quite some time by
many, and in particular from the Debian world, which carries a patch
that adds a new G_HOME environment variable with the same meaning as
this patch now assigns to HOME.
The primary motivation for the change was to increase the testability of
GLib-based programs from 'make check' types of frameworks: it is now
possible to set HOME to a temp directory to avoid the testsuite
modifying the user's real home directory.
The change also brings us increased compliance with the XDG Base
Directory Specification. The specification specifically states that the
default values should be computed based on the HOME environment
variable, whereas we were basing them on the value from /etc/passwd.
The change was agreed to by all in attendence at the November 29 Gtk+
developer meeting.
https://bugzilla.gnome.org/show_bug.cgi?id=142568