feat(branches): show branch source in create popup

This commit is contained in:
2026-06-18 23:42:41 -05:00
parent 2c7cabb0f9
commit 6214c97b28

View File

@@ -65,6 +65,7 @@ std::array<char, 128> g_create_repository_branch{};
std::array<char, 1024> g_clone_repository_parent{};
std::array<char, 1024> g_clone_repository_url{};
std::string g_git_target;
std::string g_git_target_label;
std::array<char, 256> g_inline_branch_name{};
std::string g_inline_branch_target;
std::string g_requested_branch_checkout;
@@ -650,8 +651,8 @@ bool sidebar_section_header(const char* label, int count, const char* add_toolti
if (section.find("LOCAL") != std::string::npos) {
if (repo().commits.empty()) g_notice = "Create an initial commit before creating a branch";
else {
const int commit_index = repo().selected_commit >= 0 ? repo().selected_commit : 0;
g_git_target = oid_string(repo().commits[static_cast<size_t>(commit_index)].oid);
g_git_target = repo().branch;
g_git_target_label = repo().branch.empty() ? "HEAD" : repo().branch;
g_branch_create_popup = true;
}
}
@@ -1513,6 +1514,7 @@ void draw_commit_table() {
}
if (ImGui::MenuItem(ICON_TB_CODE_BRANCH " Create branch here")) {
g_git_target = commit_hash;
g_git_target_label = std::string("commit ") + commit.short_id;
g_branch_create_popup = true;
}
ImGui::Separator();
@@ -2607,6 +2609,9 @@ void draw_git_action_popups() {
const bool submit_with_enter = ImGui::InputText("##local_branch_name",
g_git_name.data(), g_git_name.size(), ImGuiInputTextFlags_EnterReturnsTrue);
text_height_checkbox("Check out after creating", &checkout_new_branch);
ImGui::TextDisabled("Branching off: %s", g_git_target_label.empty()
? (repo().branch.empty() ? "HEAD" : repo().branch.c_str())
: g_git_target_label.c_str());
ImGui::TextDisabled("Start point: %.12s", g_git_target.empty() ? "HEAD" : g_git_target.c_str());
const bool can_submit = g_git_name[0] != '\0';
ImGui::BeginDisabled(!can_submit);
@@ -2614,12 +2619,14 @@ void draw_git_action_popups() {
if (submit && can_submit && g_git_manager->createBranch(repo(), g_git_name.data(),
g_git_target, checkout_new_branch, g_notice)) {
g_git_target.clear();
g_git_target_label.clear();
ImGui::CloseCurrentPopup();
}
ImGui::EndDisabled();
ImGui::SameLine();
if (ImGui::Button("Cancel", {ui(90.0f), 0})) {
g_git_target.clear();
g_git_target_label.clear();
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();