added ability to open gg dd without any changes, and added pulling commits

this is a change that makes it able to have this view open without having any changes in the code. also makes it able to go into the commits pane and hit p to pull that commit
This commit is contained in:
2025-06-06 16:12:29 +02:00
parent 2519a4f871
commit d9ec095206
4 changed files with 43 additions and 7 deletions

View File

@@ -779,6 +779,36 @@ int push_commit(NCursesDiffViewer *viewer, int commit_index) {
return 0;
}
/**
* Pull commits from remote
*/
int pull_commits(NCursesDiffViewer *viewer) {
if (!viewer) return 0;
// Start syncing animation (reuse the fetching animation)
viewer->sync_status = SYNC_STATUS_SYNCING_APPEARING;
viewer->animation_frame = 0;
viewer->text_char_count = 0;
// Do the actual pull work
int result = system("git pull origin 2>/dev/null >/dev/null");
if (result == 0) {
// Refresh everything after pull
get_ncurses_changed_files(viewer);
get_commit_history(viewer);
// Reload current file if any
if (viewer->file_count > 0 && viewer->selected_file < viewer->file_count) {
load_full_file_with_diff(viewer, viewer->files[viewer->selected_file].filename);
}
return 1;
}
return 0;
}
/**
* Render the file list window
*/
@@ -1040,7 +1070,7 @@ void render_status_bar(NCursesDiffViewer *viewer) {
if (viewer->current_mode == NCURSES_MODE_FILE_LIST) {
strcpy(keybindings, "Stage: <space> | Stage All: a | Commit: c");
} else if (viewer->current_mode == NCURSES_MODE_COMMIT_LIST) {
strcpy(keybindings, "Push: P | Nav: j/k");
strcpy(keybindings, "Push: P | Pull: p | Nav: j/k");
} else if (viewer->current_mode == NCURSES_MODE_FILE_VIEW) {
strcpy(keybindings, "Scroll: j/k | Page: Ctrl+U/D | Back: Esc");
}
@@ -1426,6 +1456,10 @@ int handle_ncurses_diff_input(NCursesDiffViewer *viewer, int key) {
push_commit(viewer, viewer->selected_commit);
}
break;
case 'p': // Pull commits
pull_commits(viewer);
break;
}
}
@@ -1443,11 +1477,8 @@ int run_ncurses_diff_viewer(void) {
return 1;
}
if (get_ncurses_changed_files(&viewer) == 0) {
cleanup_ncurses_diff_viewer(&viewer);
printf("No changed files found\n");
return 1;
}
// Get changed files (can be 0, that's okay)
get_ncurses_changed_files(&viewer);
// Load commit history
get_commit_history(&viewer);
@@ -1491,7 +1522,7 @@ int run_ncurses_diff_viewer(void) {
} else if (viewer.current_mode == NCURSES_MODE_FILE_VIEW) {
mvprintw(0, 0, "Git Diff Viewer: 1=files 2=view 3=commits | j/k=scroll Ctrl+U/D=30lines | q=quit");
} else {
mvprintw(0, 0, "Git Diff Viewer: 1=files 2=view 3=commits | j/k=nav P=push | q=quit");
mvprintw(0, 0, "Git Diff Viewer: 1=files 2=view 3=commits | j/k=nav P=push p=pull | q=quit");
}
attroff(COLOR_PAIR(3));
refresh();

View File

@@ -157,6 +157,11 @@ int commit_marked_files(NCursesDiffViewer *viewer, const char *commit_title, con
*/
int push_commit(NCursesDiffViewer *viewer, int commit_index);
/**
* Pull commits from remote
*/
int pull_commits(NCursesDiffViewer *viewer);
/**
* Render the commit list window
*/

Binary file not shown.

BIN
shell

Binary file not shown.