Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
builtin/am: make sure state files are text
author
Junio C Hamano
<gitster@pobox.com>
Mon, 24 Aug 2015 16:43:41 +0000
(09:43 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 24 Aug 2015 20:01:59 +0000
(13:01 -0700)
We forgot to terminate the payload given to write_file() with LF,
resulting in files that end with an incomplete line. Teach the
wrappers builtin/am uses to make sure it adds LF at the end as
necessary.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/am.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
25b763b
)
diff --git
a/builtin/am.c
b/builtin/am.c
index 4d34dc5f74bf756caa1b973196259c6f5d42b199..f0a046bdc05fa91e6d21016e6a0b246149fe3802 100644
(file)
--- a/
builtin/am.c
+++ b/
builtin/am.c
@@
-199,13
+199,19
@@
static inline const char *am_path(const struct am_state *state, const char *path
static int write_state_text(const struct am_state *state,
const char *name, const char *string)
{
static int write_state_text(const struct am_state *state,
const char *name, const char *string)
{
- return write_file(am_path(state, name), 1, "%s", string);
+ const char *fmt;
+
+ if (*string && string[strlen(string) - 1] != '\n')
+ fmt = "%s\n";
+ else
+ fmt = "%s";
+ return write_file(am_path(state, name), 1, fmt, string);
}
static int write_state_count(const struct am_state *state,
const char *name, int value)
{
}
static int write_state_count(const struct am_state *state,
const char *name, int value)
{
- return write_file(am_path(state, name), 1, "%d", value);
+ return write_file(am_path(state, name), 1, "%d
\n
", value);
}
static int write_state_bool(const struct am_state *state,
}
static int write_state_bool(const struct am_state *state,