summaryrefslogtreecommitdiff
path: root/strbuf.h
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2019-12-13 08:08:00 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-12-13 20:37:14 (GMT)
commitb38dd9e7151f118b989f8c9851bc38a8a8733eaf (patch)
tree442c629074f7e0231d18efde47d214697d021a37 /strbuf.h
parent11f2c0dae8f8889b533455d700121d437f4be19f (diff)
downloadgit-b38dd9e7151f118b989f8c9851bc38a8a8733eaf.zip
git-b38dd9e7151f118b989f8c9851bc38a8a8733eaf.tar.gz
git-b38dd9e7151f118b989f8c9851bc38a8a8733eaf.tar.bz2
strbuf: add a helper function to call the editor "on an strbuf"
This helper supports the scenario where Git has a populated `strbuf` and wants to let the user edit it interactively. In `git add -p`, we will use this to allow interactive hunk editing: the diff hunks are already in memory, but we need to write them out to a file so that an editor can be launched, then read everything back once the user is done editing. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'strbuf.h')
-rw-r--r--strbuf.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/strbuf.h b/strbuf.h
index 84cf969..bfa6656 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -621,6 +621,17 @@ int launch_editor(const char *path, struct strbuf *buffer,
int launch_sequence_editor(const char *path, struct strbuf *buffer,
const char *const *env);
+/*
+ * In contrast to `launch_editor()`, this function writes out the contents
+ * of the specified file first, then clears the `buffer`, then launches
+ * the editor and reads back in the file contents into the `buffer`.
+ * Finally, it deletes the temporary file.
+ *
+ * If `path` is relative, it refers to a file in the `.git` directory.
+ */
+int strbuf_edit_interactively(struct strbuf *buffer, const char *path,
+ const char *const *env);
+
void strbuf_add_lines(struct strbuf *sb,
const char *prefix,
const char *buf,