From: Duy Nguyen Date: Tue, 26 Jan 2016 12:50:41 GMT Subject: Re: [BUG] typo DWIMery with alias broken (cd to random dir) Message-ID: In-Reply-To: <56A72235.9080602@drmicha.warpmail.net> On Tue, Jan 26, 2016 at 2:37 PM, Michael J Gruber wrote: > Hi there, > > with current next (989ee58 plus local additions) it seems that typo > DWIMery with aliases is broken, see below. > > It appears that the typo DWIMery is broken only when there is a unique > automatic DWIM substitution for a mistyped alias. > > I haven't bisected yet, but I suspect this to be related to recent > changes regarding the environment in which commands/aliases are started > (though this happens without extra work trees), so I'm cc'ing an expert > in that area. Funny, though, that my user name shows up... > > I think the reason is that git.c's handle_alias() (or something else) > calls restore_env() multiple times, and restore_env frees orig_cwd such > that subsequent restore_env(0) with external_alias=0 tries to cd to a > random location. > > I have no idea whether orig_cwd=0 after freeing or something else would > be the proper fix. I think the key is to reset saved_env_before_alias to zero in restore_env(). With that flag remains set, the second save_env turns no-op. orig_cwd should be reset too, but that's minor. It's working for me. I'll send a patch later. -- Duy