Work both with and without --args arguments that open a particular ref. (cherry picked from commit ad99b203)