From: Stefan Sperling Subject: Re: Optimized branch switching? To: Christian Weisgerber Cc: gameoftrees@openbsd.org Date: Sun, 11 Sep 2022 10:59:08 +0200 On Sat, Sep 10, 2022 at 10:39:47PM +0200, Christian Weisgerber wrote: > Look at this: > > $ got br > local > $ got log -l1 > ----------------------------------------------- > commit ec5b7def698dac3e452acf7d56900e891c0f47e7 (local, master, origin/master) > from: ajacoutot > date: Sat Sep 10 17:40:52 2022 UTC > > Update to awscli-1.25.71. > > $ time got up -b master > Switching work tree from refs/heads/local to refs/heads/master > Already up-to-date > 0m21.18s real 0m04.48s user 0m09.00s system > > Given that the tip of the branch we're switching from is identical > to the one we're switching to, shouldn't this be faster? Like, > almost a nop? Try measuring again with 'got branch -n'. I suspect the time is spent by the equivalent of 'got update', since 'got branch' implicitly updates the work tree. If time is indeed spent on updating the work tree, then we would need to figure out whether we can speed up the 'got update' code path.