AmendHub

Download (as of this amendment):

jcs

/

amend

/

amendments

/

128

committer: If command+period is pressed during diffing, abort

It would be nice to be able to do this while in diffreg but maybe
some other time.

jcs made amendment 128 over 2 years ago
--- committer.c Mon Apr 17 15:35:58 2023 +++ committer.c Thu Jan 11 13:08:25 2024 @@ -440,6 +440,7 @@ committer_generate_diff(struct committer *committer) committer->diff_subs = 0; committer->ndiffed_files = 0; committer->allow_commit = false; + committer->canceled = false; committer->diffed_files = xcalloc(sizeof(struct diffed_file), nselected_files, "committer diffed_files"); committer->diff_too_big = false; @@ -455,6 +456,11 @@ committer_generate_diff(struct committer *committer) committer_diffing = committer; for (i = 0; i < nselected_files; i++) { + if (CommandPeriodPressed()) + committer->canceled = true; + if (committer->canceled) + break; + file = repo_file_with_id(committer->browser->repo, selected_files[i]); if (file == NULL) @@ -483,6 +489,9 @@ committer_generate_diff(struct committer *committer) } committer_diffing = NULL; + + if (committer->canceled) + committer->allow_commit = false; HUnlock(committer->diff_te); InvalRect(&committer->win->portRect); @@ -496,8 +505,9 @@ done_diffing: xfree(&selected_files); SetCursor(&arrow); - if (!committer->allow_commit) { - warnx("No changes detected"); + if (committer->diff_adds == 0 && committer->diff_subs == 0) { + if (!committer->canceled) + warnx("No changes detected"); browser_close_committer(committer->browser); } } @@ -658,6 +668,9 @@ diff_append_line(char *str, size_t len, bool flush) if (flush) diff_chunk_write(); + + if (CommandPeriodPressed()) + committer_diffing->canceled = true; } void --- committer.h Sat Mar 4 22:39:58 2023 +++ committer.h Thu Jan 11 11:32:44 2024 @@ -41,6 +41,7 @@ struct committer { short ndiffed_files; struct diffed_file *diffed_files; bool allow_commit; + bool canceled; short diff_adds; short diff_subs; bool diff_too_big;