summaryrefslogtreecommitdiff
path: root/src/reflog.c
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2011-07-10 07:48:52 +0200
committernulltoken <emeric.fermas@gmail.com>2011-07-10 19:17:07 +0200
commit7757be33a249097e6f6a5d9c0065aff5e083ad2e (patch)
tree01375a0b7d7f90728fc8a768a264c26357d52b59 /src/reflog.c
parentd37ba6720de36b5121f4e978f65ab5703d12523f (diff)
downloadlibgit2-7757be33a249097e6f6a5d9c0065aff5e083ad2e.tar.gz
reflog: Fix reflog writer/reader
- Use a space to separate oids and signature - Enforce test coverage - Make test run in a temporary folder in order not to alter the test repository
Diffstat (limited to 'src/reflog.c')
-rw-r--r--src/reflog.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/reflog.c b/src/reflog.c
index ce88c101e..da61fd7d6 100644
--- a/src/reflog.c
+++ b/src/reflog.c
@@ -74,9 +74,11 @@ static int reflog_write(git_repository *repo, const char *ref_name,
return git__throw(GIT_ERROR, "Failed to write reflog. `%s` is directory", log_path);
git_buf_puts(&log, oid_old);
+ git_buf_putc(&log, ' ');
+
git_buf_puts(&log, oid_new);
- git_signature__writebuf(&log, NULL, committer);
+ git_signature__writebuf(&log, " ", committer);
log.size--; /* drop LF */
if (msg) {
@@ -122,10 +124,10 @@ static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size)
return GIT_ENOMEM;
entry->oid_old = git__strndup(buf, GIT_OID_HEXSZ);
- seek_forward(GIT_OID_HEXSZ+1);
+ seek_forward(GIT_OID_HEXSZ + 1);
entry->oid_cur = git__strndup(buf, GIT_OID_HEXSZ);
- seek_forward(GIT_OID_HEXSZ+1);
+ seek_forward(GIT_OID_HEXSZ + 1);
ptr = buf;
@@ -137,7 +139,7 @@ static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size)
if (entry->committer == NULL)
return GIT_ENOMEM;
- if ((error = git_signature__parse(entry->committer, &ptr, buf + buf_size, NULL)) < GIT_SUCCESS)
+ if ((error = git_signature__parse(entry->committer, &ptr, buf + 1, NULL, *buf)) < GIT_SUCCESS)
goto cleanup;
if (*buf == '\t') {