commit 65084dad1e0e79f61fa736536c15cb512df73d1d from: Stefan Sperling date: Thu Aug 08 14:52:12 2019 UTC in revert_file(), only construct on-disk path when actually needed commit - 2163d960632af6a11c5650d227ff007b8697e4f6 commit + 65084dad1e0e79f61fa736536c15cb512df73d1d blob - a1e3533fd1c0c1a23ecd02bbf8b270a1400875fa blob + 092546cdf650ee446d066428524ec86d90630a74 --- lib/worktree.c +++ lib/worktree.c @@ -2706,16 +2706,10 @@ revert_file(void *arg, unsigned char status, unsigned char *tree_path = NULL, *te_name; char *ondisk_path = NULL; struct got_blob_object *blob = NULL; - - if (asprintf(&ondisk_path, "%s/%s", - got_worktree_get_root_path(a->worktree), relpath) == -1) - return got_error_from_errno("asprintf"); ie = got_fileindex_entry_get(a->fileindex, relpath, strlen(relpath)); - if (ie == NULL) { - err = got_error(GOT_ERR_BAD_PATH); - goto done; - } + if (ie == NULL) + return got_error(GOT_ERR_BAD_PATH); if (status == GOT_STATUS_DELETE && staged_status != GOT_STATUS_NO_CHANGE) { @@ -2804,7 +2798,14 @@ revert_file(void *arg, unsigned char status, unsigned SHA1_DIGEST_LENGTH); err = got_object_open_as_blob(&blob, a->repo, &id, 8192); if (err) + goto done; + + if (asprintf(&ondisk_path, "%s/%s", + got_worktree_get_root_path(a->worktree), relpath) == -1) { + err = got_error_from_errno("asprintf"); goto done; + } + err = install_blob(a->worktree, ondisk_path, ie->path, te ? te->mode : GOT_DEFAULT_FILE_MODE, got_fileindex_perms_to_st(ie), blob, 0, 1,