[PATCH v3 5/7] notes copy --stdin: read lines with strbuf_getline()
- From
- Moritz Neeb <lists@moritzneeb.de>
- Date
- Feb 28, 2016, 05:13 UTC
- Message-ID
- <56D28211.5060101@moritzneeb.de>
- In-Reply-To
- <56D28092.9090209@moritzneeb.de>
The format of a line that is expected when copying notes via stdin is "sha1 sha1". As this is text-only, strbuf_getline() can be used instead of strbuf_getline_lf().
When reading with strbuf_getline() the trimming can be removed. It was necessary before to remove potential CRs inserted through a dos editor.
Signed-off-by: Moritz Neeb <lists@moritzneeb.de> --- builtin/notes.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/builtin/notes.c b/builtin/notes.c index 22909c7..660c0b7 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -290,12 +290,11 @@ static int notes_copy_from_stdin(int force, const char *rewrite_cmd) t = &default_notes_tree; } - while (strbuf_getline_lf(&buf, stdin) != EOF) { + while (strbuf_getline(&buf, stdin) != EOF) { unsigned char from_obj[20], to_obj[20]; struct string_list split = STRING_LIST_INIT_DUP; int err; - strbuf_rtrim(&buf); string_list_split(&split, buf.buf, ' ', -1); if (split.nr != 2)
-- 2.4.3