Code

Merge branch 'tr/cache-tree' into maint-1.7.8
[git.git] / Documentation / technical / api-strbuf.txt
index a0e0f850f83fe164dd7c1ca87d001fe485ba2ec2..95a8bf3846b30650f3ee089a4fbadfcc5a42da20 100644 (file)
@@ -199,6 +199,10 @@ character if the letter `n` appears after a `%`.  The function returns
 the length of the placeholder recognized and `strbuf_expand()` skips
 over it.
 +
+The format `%%` is automatically expanded to a single `%` as a quoting
+mechanism; callers do not need to handle the `%` placeholder themselves,
+and the callback function will not be invoked for this placeholder.
++
 All other characters (non-percent and not skipped ones) are copied
 verbatim to the strbuf.  If the callback returned zero, meaning that the
 placeholder is unknown, then the percent sign is copied, too.
@@ -214,6 +218,13 @@ which can be used by the programmer of the callback as she sees fit.
        placeholder and replacement string.  The array needs to be
        terminated by an entry with placeholder set to NULL.
 
+`strbuf_addbuf_percentquote`::
+
+       Append the contents of one strbuf to another, quoting any
+       percent signs ("%") into double-percents ("%%") in the
+       destination. This is useful for literal data to be fed to either
+       strbuf_expand or to the *printf family of functions.
+
 `strbuf_addf`::
 
        Add a formatted string to the buffer.
@@ -244,8 +255,24 @@ same behaviour as well.
 
 `strbuf_getline`::
 
-       Read a line from a FILE* pointer. The second argument specifies the line
+       Read a line from a FILE *, overwriting the existing contents
+       of the strbuf. The second argument specifies the line
        terminator character, typically `'\n'`.
+       Reading stops after the terminator or at EOF.  The terminator
+       is removed from the buffer before returning.  Returns 0 unless
+       there was nothing left before EOF, in which case it returns `EOF`.
+
+`strbuf_getwholeline`::
+
+       Like `strbuf_getline`, but keeps the trailing terminator (if
+       any) in the buffer.
+
+`strbuf_getwholeline_fd`::
+
+       Like `strbuf_getwholeline`, but operates on a file descriptor.
+       It reads one character at a time, so it is very slow.  Do not
+       use it unless you need the correct position in the file
+       descriptor.
 
 `stripspace`::