Re: [RFC PATCH v4 2/3] Show the call history when an alias is looping
From: Jeff King <hidden>
Date: 2018-09-08 16:29:12
On Sat, Sep 08, 2018 at 03:34:34PM +0200, Duy Nguyen wrote:
On Sat, Sep 8, 2018 at 12:44 AM Tim Schumacher [off-list ref] wrote:quoted
Just printing the command that the user entered is not particularly helpful when trying to find the alias that causes the loop. Print the history of substituted commands to help the user find the offending alias. Mark the entrypoint of the loop with "<==" and the last command (which looped back to the entrypoint) with "==>".An even simpler way to give this information is simply suggest the user tries again with GIT_TRACE=1. All alias expansion is shown there and we teach the user about GIT_TRACE. But your approach is probably more user friendly.
Good point. I'm OK with the amount of code here for the nicer message
(but would be happy either way).
If we were going to track cross-process loops like Ævar suggested, I
think I'd rather go with a simple counter and just ask the user to run
with GIT_TRACE when it exceeds some maximum sanity value. For two
reasons:
1. Passing a counter through the environment is way simpler than
an arbitrarily-sized list.
2. When you get into multiple processes, there's potentially more
going on than just Git commands. You might have a git command which
runs a hook which runs a third party script which runs a git
command, which runs a hook, and so on. That full dump is going to
be more useful.
-Peff