diff options
| author | Elijah Newren <newren@gmail.com> | 2023-04-11 00:41:57 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2023-04-11 08:52:10 -0700 |
| commit | 4e120823a345cf348a052683d726c90bc4b256ca (patch) | |
| tree | 6453f1bbf0b5fc757689b0b0060cb1fe3141a815 /strbuf.c | |
| parent | treewide: remove cache.h inclusion due to object.h changes (diff) | |
| download | git-4e120823a345cf348a052683d726c90bc4b256ca.tar.gz git-4e120823a345cf348a052683d726c90bc4b256ca.zip | |
editor: move editor-related functions and declarations into common file
cache.h and strbuf.[ch] had editor-related functions. Move these into
editor.[ch].
Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'strbuf.c')
| -rw-r--r-- | strbuf.c | 28 |
1 files changed, 0 insertions, 28 deletions
@@ -1180,34 +1180,6 @@ int strbuf_normalize_path(struct strbuf *src) return 0; } -int strbuf_edit_interactively(struct strbuf *buffer, const char *path, - const char *const *env) -{ - char *path2 = NULL; - int fd, res = 0; - - if (!is_absolute_path(path)) - path = path2 = xstrdup(git_path("%s", path)); - - fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666); - if (fd < 0) - res = error_errno(_("could not open '%s' for writing"), path); - else if (write_in_full(fd, buffer->buf, buffer->len) < 0) { - res = error_errno(_("could not write to '%s'"), path); - close(fd); - } else if (close(fd) < 0) - res = error_errno(_("could not close '%s'"), path); - else { - strbuf_reset(buffer); - if (launch_editor(path, buffer, env) < 0) - res = error_errno(_("could not edit '%s'"), path); - unlink(path); - } - - free(path2); - return res; -} - void strbuf_strip_file_from_path(struct strbuf *sb) { char *path_sep = find_last_dir_sep(sb->buf); |
