summaryrefslogtreecommitdiff
path: root/tests/test_helpers.c
diff options
context:
space:
mode:
authorRamsay Jones <ramsay@ramsay1.demon.co.uk>2010-02-12 16:50:33 +0000
committerRamsay Jones <ramsay@ramsay1.demon.co.uk>2010-02-28 20:09:45 +0000
commit1e5dd57214dbec1b166c881c1c44c8930923da17 (patch)
tree7f7103b840176225a27d40ff95c541ecaf74bb59 /tests/test_helpers.c
parent74eff33f8be680e821d9674ab12da3c0b76dad23 (diff)
downloadlibgit2-1e5dd57214dbec1b166c881c1c44c8930923da17.tar.gz
Fix some coding style issues
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Diffstat (limited to 'tests/test_helpers.c')
-rw-r--r--tests/test_helpers.c88
1 files changed, 44 insertions, 44 deletions
diff --git a/tests/test_helpers.c b/tests/test_helpers.c
index 6829e2c49..46a29b40d 100644
--- a/tests/test_helpers.c
+++ b/tests/test_helpers.c
@@ -29,66 +29,66 @@
int write_object_data(char *file, void *data, size_t len)
{
- git_file fd;
- int ret;
+ git_file fd;
+ int ret;
- if ((fd = gitfo_creat(file, S_IREAD | S_IWRITE)) < 0)
- return -1;
- ret = gitfo_write(fd, data, len);
- gitfo_close(fd);
+ if ((fd = gitfo_creat(file, S_IREAD | S_IWRITE)) < 0)
+ return -1;
+ ret = gitfo_write(fd, data, len);
+ gitfo_close(fd);
- return ret;
+ return ret;
}
int write_object_files(const char *odb_dir, object_data *d)
{
- if (gitfo_mkdir(odb_dir, 0755) < 0) {
- if (errno == EEXIST) {
- fprintf(stderr, "odb directory \"%s\" already exists!\n", odb_dir);
- return -1;
- }
- fprintf(stderr, "can't make odb directory \"%s\"\n", odb_dir);
- return -1;
- }
+ if (gitfo_mkdir(odb_dir, 0755) < 0) {
+ int err = errno;
+ fprintf(stderr, "can't make directory \"%s\"", odb_dir);
+ if (err == EEXIST)
+ fprintf(stderr, " (already exists)");
+ fprintf(stderr, "\n");
+ return -1;
+ }
- if ((gitfo_mkdir(d->dir, 0755) < 0) && (errno != EEXIST)) {
- fprintf(stderr, "can't make object directory \"%s\"\n", d->dir);
- return -1;
- }
- if (write_object_data(d->file, d->bytes, d->blen) < 0) {
- fprintf(stderr, "can't write object file \"%s\"\n", d->file);
- return -1;
- }
+ if ((gitfo_mkdir(d->dir, 0755) < 0) && (errno != EEXIST)) {
+ fprintf(stderr, "can't make object directory \"%s\"\n", d->dir);
+ return -1;
+ }
+ if (write_object_data(d->file, d->bytes, d->blen) < 0) {
+ fprintf(stderr, "can't write object file \"%s\"\n", d->file);
+ return -1;
+ }
- return 0;
+ return 0;
}
int remove_object_files(const char *odb_dir, object_data *d)
{
- if (gitfo_unlink(d->file) < 0) {
- fprintf(stderr, "can't delete object file \"%s\"\n", d->file);
- return -1;
- }
- if ((gitfo_rmdir(d->dir) < 0) && (errno != ENOTEMPTY)) {
- fprintf(stderr, "can't remove object directory \"%s\"\n", d->dir);
- return -1;
- }
+ if (gitfo_unlink(d->file) < 0) {
+ fprintf(stderr, "can't delete object file \"%s\"\n", d->file);
+ return -1;
+ }
+ if ((gitfo_rmdir(d->dir) < 0) && (errno != ENOTEMPTY)) {
+ fprintf(stderr, "can't remove object directory \"%s\"\n", d->dir);
+ return -1;
+ }
- if (gitfo_rmdir(odb_dir) < 0) {
- fprintf(stderr, "can't remove odb directory \"%s\"\n", odb_dir);
- return -1;
- }
+ if (gitfo_rmdir(odb_dir) < 0) {
+ fprintf(stderr, "can't remove directory \"%s\"\n", odb_dir);
+ return -1;
+ }
- return 0;
+ return 0;
}
int cmp_objects(git_obj *o, object_data *d)
{
- if (o->type != git_obj_string_to_type(d->type))
- return -1;
- if (o->len != d->dlen)
- return -1;
- if ((o->len > 0) && (memcmp(o->data, d->data, o->len) != 0))
- return -1;
- return 0;
+ if (o->type != git_obj_string_to_type(d->type))
+ return -1;
+ if (o->len != d->dlen)
+ return -1;
+ if ((o->len > 0) && (memcmp(o->data, d->data, o->len) != 0))
+ return -1;
+ return 0;
}