Download raw body.
blame file stream
When looking for got_opentempfd in blame, i missed a teensy weensy
little file stream. whoops ...
ok?
--
Tracey Emery
diff /home/tracey/src/got
commit - f9d376997dd2e84bf84c3c9a4da842d1b5565e9d
path + /home/tracey/src/got
blob - 6332563c1a68c343f8f860c77299ff6dbe5f18f3
file + got/got.c
--- got/got.c
+++ got/got.c
@@ -5363,6 +5363,7 @@ cmd_blame(int argc, char *argv[])
int ch, obj_type, i, fd = -1, fd1 = -1;
off_t filesize;
int *pack_fds = NULL;
+ FILE *f;
fd = got_opentempfd();
if (fd == -1)
@@ -5554,8 +5555,13 @@ cmd_blame(int argc, char *argv[])
error = got_error_from_errno("got_opentempfd");
goto done;
}
+ f = got_opentemp();
+ if (f == NULL) {
+ error = got_error_from_errno("got_opentemp");
+ goto done;
+ }
error = got_blame(link_target ? link_target : in_repo_path, commit_id,
- repo, blame_cb, &bca, check_cancelled, NULL, fd1);
+ repo, blame_cb, &bca, check_cancelled, NULL, fd1, f);
done:
free(in_repo_path);
free(link_target);
blob - eb1c8f8f3ddec6a14375a8af819bc150fecf1abc
file + gotweb/gotweb.c
--- gotweb/gotweb.c
+++ gotweb/gotweb.c
@@ -4085,6 +4085,7 @@ gw_output_file_blame(struct gw_trans *gw_trans, struct
struct gw_blame_cb_args bca;
int i, obj_type, fd = -1, fd1 = -1;
off_t filesize;
+ FILE *f;
fd = got_opentempfd();
if (fd == -1)
@@ -4172,8 +4173,14 @@ gw_output_file_blame(struct gw_trans *gw_trans, struct
goto done;
}
+ f = got_opentemp();
+ if (f == NULL) {
+ error = got_error_from_errno("got_opentempfd");
+ goto done;
+ }
+
error = got_blame(in_repo_path, commit_id, gw_trans->repo, gw_blame_cb,
- &bca, NULL, NULL, fd1);
+ &bca, NULL, NULL, fd1, f);
done:
free(in_repo_path);
free(commit_id);
blob - 56e2d804dc17e77e5b5660bcd248453a942fcbb4
file + include/got_blame.h
--- include/got_blame.h
+++ include/got_blame.h
@@ -36,4 +36,4 @@ typedef const struct got_error *(*got_blame_cb)(void *
*/
const struct got_error *got_blame(const char *,
struct got_object_id *, struct got_repository *,
- got_blame_cb, void *, got_cancel_cb, void *, int);
+ got_blame_cb, void *, got_cancel_cb, void *, int, FILE *);
blob - 68e7392e8e977dcd4362e7961374a990f1dba55c
file + lib/blame.c
--- lib/blame.c
+++ lib/blame.c
@@ -509,7 +509,7 @@ static const struct got_error *
blame_open(struct got_blame **blamep, const char *path,
struct got_object_id *start_commit_id, struct got_repository *repo,
got_blame_cb cb, void *arg, got_cancel_cb cancel_cb, void *cancel_arg,
- int fd)
+ int fd, FILE *f)
{
const struct got_error *err = NULL;
struct got_commit_object *start_commit = NULL, *last_commit = NULL;
@@ -551,7 +551,7 @@ blame_open(struct got_blame **blamep, const char *path
goto done;
}
- blame->f2 = got_opentemp();
+ blame->f2 = f;
if (blame->f2 == NULL) {
err = got_error_from_errno("got_opentemp");
goto done;
@@ -660,7 +660,7 @@ done:
const struct got_error *
got_blame(const char *path, struct got_object_id *commit_id,
struct got_repository *repo, got_blame_cb cb, void *arg,
- got_cancel_cb cancel_cb, void* cancel_arg, int fd)
+ got_cancel_cb cancel_cb, void* cancel_arg, int fd, FILE *f)
{
const struct got_error *err = NULL, *close_err = NULL;
struct got_blame *blame;
@@ -670,7 +670,7 @@ got_blame(const char *path, struct got_object_id *comm
return got_error_from_errno2("asprintf", path);
err = blame_open(&blame, abspath, commit_id, repo, cb, arg,
- cancel_cb, cancel_arg, fd);
+ cancel_cb, cancel_arg, fd, f);
free(abspath);
if (blame)
close_err = blame_close(blame);
blob - 3ec7da1db803f36693a814f77125861f3ac2095e
file + tog/tog.c
--- tog/tog.c
+++ tog/tog.c
@@ -4681,24 +4681,32 @@ blame_thread(void *arg)
struct tog_blame_thread_args *ta = arg;
struct tog_blame_cb_args *a = ta->cb_args;
int errcode, fd = -1;
+ FILE *f;
fd = got_opentempfd();
if (fd == -1)
return (void *)got_error_from_errno("got_opentempfd");
+ f = got_opentemp();
+ if (f == NULL) {
+ err = (void *)got_error_from_errno("got_opentemp");
+ goto done;
+ }
+
err = block_signals_used_by_main_thread();
if (err)
- return (void *)err;
+ goto done;
err = got_blame(ta->path, a->commit_id, ta->repo,
- blame_cb, ta->cb_args, ta->cancel_cb, ta->cancel_arg, fd);
+ blame_cb, ta->cb_args, ta->cancel_cb, ta->cancel_arg, fd, f);
if (err && err->code == GOT_ERR_CANCELLED)
err = NULL;
errcode = pthread_mutex_lock(&tog_mutex);
- if (errcode)
- return (void *)got_error_set_errno(errcode,
- "pthread_mutex_lock");
+ if (errcode) {
+ err = got_error_set_errno(errcode, "pthread_mutex_lock");
+ goto done;
+ }
close_err = got_repo_close(ta->repo);
if (err == NULL)
@@ -4710,6 +4718,7 @@ blame_thread(void *arg)
if (errcode && err == NULL)
err = got_error_set_errno(errcode, "pthread_mutex_unlock");
+done:
if (fd != -1 && close(fd) == -1 && err == NULL)
err = got_error_from_errno("close");
blame file stream