Download raw body.
improve got log cancellation behaviour
The Git repository at https://github.com/adhn/nanobox-pkgsrc-lite
contains the entire git log of pkgsrc from netbsd embedded in a
single 100MB commit message.
Once 'got log' starts printing such a long message it won't stop
until everything has been printed, even when the user tries to
abort the process with Ctrl-C. This patch fixes this issue.
ok?
diff aa8b5dd032c8cba930e5be67a90069a95e0001b8 /home/stsp/src/got
blob - 71cc16e4b52a05afc8991d3d0c566bd8c200b3d7
file + got/got.c
--- got/got.c
+++ got/got.c
@@ -3697,7 +3697,7 @@ print_commit(struct got_commit_object *commit, struct
const char *custom_refs_str)
{
const struct got_error *err = NULL;
- char *id_str, *datestr, *logmsg0, *logmsg, *line;
+ char *id_str, *datestr, *logmsg0 = NULL, *logmsg, *line;
char datebuf[26];
time_t committer_time;
const char *author, *committer;
@@ -3742,6 +3742,9 @@ print_commit(struct got_commit_object *commit, struct
int n = 1;
parent_ids = got_object_commit_get_parent_ids(commit);
STAILQ_FOREACH(qid, parent_ids, entry) {
+ err = check_cancelled(NULL);
+ if (err)
+ goto done;
err = got_object_id_str(&id_str, qid->id);
if (err)
goto done;
@@ -3757,16 +3760,21 @@ print_commit(struct got_commit_object *commit, struct
logmsg = logmsg0;
do {
+ err = check_cancelled(NULL);
+ if (err)
+ goto done;
line = strsep(&logmsg, "\n");
if (line)
printf(" %s\n", line);
} while (line);
- free(logmsg0);
if (changed_paths) {
struct got_pathlist_entry *pe;
TAILQ_FOREACH(pe, changed_paths, entry) {
struct got_diff_changed_path *cp = pe->data;
+ err = check_cancelled(NULL);
+ if (err)
+ goto done;
printf(" %c %s\n", cp->status, pe->path);
}
printf("\n");
@@ -3780,6 +3788,7 @@ print_commit(struct got_commit_object *commit, struct
if (fflush(stdout) != 0 && err == NULL)
err = got_error_from_errno("fflush");
done:
+ free(logmsg0);
free(id_str);
free(refs_str);
return err;
improve got log cancellation behaviour