diff options
author | Vicent Martà <tanoku@gmail.com> | 2011-07-10 18:02:33 -0700 |
---|---|---|
committer | Vicent Martà <tanoku@gmail.com> | 2011-07-10 18:02:33 -0700 |
commit | 283eeefb0988f2981c846773e715b7e67a559b39 (patch) | |
tree | 62eaa9ac84469a423e56380fd8b5469dbbeb6b79 /src | |
parent | 5f35d0ce771d8d16bb1180ea0d4362a8836b4a99 (diff) | |
parent | 7757be33a249097e6f6a5d9c0065aff5e083ad2e (diff) | |
download | libgit2-283eeefb0988f2981c846773e715b7e67a559b39.tar.gz |
Merge pull request #314 from nulltoken/ntk/fix-reflog
reflog: Fix reflog writer/reader
Diffstat (limited to 'src')
-rw-r--r-- | src/commit.c | 4 | ||||
-rw-r--r-- | src/reflog.c | 10 | ||||
-rw-r--r-- | src/signature.c | 4 | ||||
-rw-r--r-- | src/signature.h | 2 | ||||
-rw-r--r-- | src/tag.c | 2 |
5 files changed, 12 insertions, 10 deletions
diff --git a/src/commit.c b/src/commit.c index fc4848733..a6c19e596 100644 --- a/src/commit.c +++ b/src/commit.c @@ -209,12 +209,12 @@ int commit_parse_buffer(git_commit *commit, const void *data, size_t len) } commit->author = git__malloc(sizeof(git_signature)); - if ((error = git_signature__parse(commit->author, &buffer, buffer_end, "author ")) < GIT_SUCCESS) + if ((error = git_signature__parse(commit->author, &buffer, buffer_end, "author ", '\n')) < GIT_SUCCESS) return git__rethrow(error, "Failed to parse buffer"); /* Always parse the committer; we need the commit time */ commit->committer = git__malloc(sizeof(git_signature)); - if ((error = git_signature__parse(commit->committer, &buffer, buffer_end, "committer ")) < GIT_SUCCESS) + if ((error = git_signature__parse(commit->committer, &buffer, buffer_end, "committer ", '\n')) < GIT_SUCCESS) return git__rethrow(error, "Failed to parse buffer"); /* parse commit message */ 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') { diff --git a/src/signature.c b/src/signature.c index d7c1b2d3e..cc55d1dc7 100644 --- a/src/signature.c +++ b/src/signature.c @@ -253,7 +253,7 @@ int parse_time(git_time_t *time_out, const char *buffer) } int git_signature__parse(git_signature *sig, const char **buffer_out, - const char *buffer_end, const char *header) + const char *buffer_end, const char *header, char ender) { const char *buffer = *buffer_out; const char *line_end, *name_end, *email_end, *tz_start, *time_start; @@ -261,7 +261,7 @@ int git_signature__parse(git_signature *sig, const char **buffer_out, memset(sig, 0x0, sizeof(git_signature)); - if ((line_end = memchr(buffer, '\n', buffer_end - buffer)) == NULL) + if ((line_end = memchr(buffer, ender, buffer_end - buffer)) == NULL) return git__throw(GIT_EOBJCORRUPTED, "Failed to parse signature. No newline given"); if (header) { diff --git a/src/signature.h b/src/signature.h index c2e7e7815..2fe6cd7c9 100644 --- a/src/signature.h +++ b/src/signature.h @@ -6,7 +6,7 @@ #include "repository.h" #include <time.h> -int git_signature__parse(git_signature *sig, const char **buffer_out, const char *buffer_end, const char *header); +int git_signature__parse(git_signature *sig, const char **buffer_out, const char *buffer_end, const char *header, char ender); void git_signature__writebuf(git_buf *buf, const char *header, const git_signature *sig); #endif @@ -144,7 +144,7 @@ static int parse_tag_buffer(git_tag *tag, const char *buffer, const char *buffer if (tag->tagger == NULL) return GIT_ENOMEM; - if ((error = git_signature__parse(tag->tagger, &buffer, buffer_end, "tagger ")) != 0) { + if ((error = git_signature__parse(tag->tagger, &buffer, buffer_end, "tagger ", '\n')) != 0) { free(tag->tag_name); git_signature_free(tag->tagger); return git__rethrow(error, "Failed to parse tag"); |