git: Recover branch refs when metadata lookup fails#57285
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
I had the pairing session with Cole on this one, so this PR was created for the pairing session and I will adjust it based on the conclusion. |
|
Appreciate the context, was obviously unaware of that. |
ccb6a96 to
99fd825
Compare
99fd825 to
457e431
Compare
457e431 to
9be8d76
Compare
|
@cole-miller I investigated the original git source code here for the actual implementation of If you look here at the "valid atoms" ("fields" in our terminology) you can see that There is a logic in which if it is if (*atom == '*')
oi_deref.info.contentp = &oi_deref.content;
else
oi.info.contentp = &oi.content;
}And then it will decide based on those fields whether it should call if (!memcmp(&oi.info, &empty, sizeof(empty)) &&
!memcmp(&oi_deref.info, &empty, sizeof(empty)))
return 0;So, those 3 fields does not require the same object-loading path: If you still think we shouldn't do this second command I can remove it but IMO it makes the fix robust and is "safe enough" to use (as your original concern was "why it will not fail again if the first one failed" -> because it will not go into the same path in the git's code 😄 ) |
1a66250 to
897c5a5
Compare
|
Thanks for the additional research @GoldStrikeArch. However, I still think it's better here not to call a fallback command. I think if a user has some git refs that are broken in this way (which seems rare), it's okay for the branch picker to be degraded, and not worth the complexity of a second command invocation to try to recover some of the refs we couldn't get before (especially because interacting with those refs might not work for the same reason we couldn't process them here). I think a better path forward would be to try to surface errors on this codepath better in the UI, so that people don't have to check their logs to see what went wrong. (And parsing whatever lines we can from the output of the existing command still seems reasonable too, since we can do that without much additional complexity.) |
|
@cole-miller Alright, so I reverted the changes and now we are doing exactly that:
|
|
@GoldStrikeArch Thanks! I tweaked the UI slightly but this looks good otherwise--merging. |
…7285) cc @cole-miller Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Fixed branch enumeration when a broken Git ref prevents commit metadata from being read. --------- Co-authored-by: Cole Miller <cole@zed.dev>

cc @cole-miller
Self-Review Checklist:
Release Notes: