summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--CMakeLists.txt2
-rw-r--r--examples/network/fetch.c2
-rw-r--r--examples/network/ls-remote.c2
-rw-r--r--include/git2/remote.h15
-rw-r--r--src/attr.c6
-rw-r--r--src/config_file.c12
-rw-r--r--src/netops.c3
-rw-r--r--src/object.c4
-rw-r--r--src/path.c6
-rw-r--r--src/pkt.c1
-rw-r--r--src/posix.c15
-rw-r--r--src/posix.h2
-rw-r--r--src/remote.c60
-rw-r--r--src/repository.c5
-rw-r--r--src/status.c8
-rw-r--r--src/win32/posix.h2
-rw-r--r--src/win32/posix_w32.c41
-rwxr-xr-xtests-clar/clar4
-rw-r--r--tests-clar/clar_helpers.c2
-rw-r--r--tests-clar/core/path.c13
-rw-r--r--tests-clar/network/remotelocal.c2
-rw-r--r--tests-clar/network/remotes.c19
-rw-r--r--tests-clar/object/lookup.c37
-rw-r--r--tests-clar/repo/discover.c12
-rw-r--r--tests-clar/repo/open.c12
-rw-r--r--tests-clar/status/worktree.c17
27 files changed, 244 insertions, 62 deletions
diff --git a/.travis.yml b/.travis.yml
index 4c8c42aaa..b9a08dc59 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,7 +22,7 @@ script:
# Run Tests
after_script:
- - ctest .
+ - ctest -V .
# Only watch the development branch
branches:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7bfd21b73..fbc222d5c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -96,7 +96,7 @@ FILE(GLOB SRC_H include/git2/*.h)
# On Windows use specific platform sources
IF (WIN32 AND NOT CYGWIN)
- ADD_DEFINITIONS(-DWIN32 -D_DEBUG)
+ ADD_DEFINITIONS(-DWIN32 -D_DEBUG -D_WIN32_WINNT=0x0501)
FILE(GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/win32/*.c)
ELSE()
FILE(GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/unix/*.c)
diff --git a/examples/network/fetch.c b/examples/network/fetch.c
index 23046bd09..f4a044984 100644
--- a/examples/network/fetch.c
+++ b/examples/network/fetch.c
@@ -69,7 +69,7 @@ int fetch(git_repository *repo, int argc, char **argv)
// Figure out whether it's a named remote or a URL
printf("Fetching %s\n", argv[1]);
if (git_remote_load(&remote, repo, argv[1]) < 0) {
- if (git_remote_new(&remote, repo, argv[1], NULL) < 0)
+ if (git_remote_new(&remote, repo, NULL, argv[1], NULL) < 0)
return -1;
}
diff --git a/examples/network/ls-remote.c b/examples/network/ls-remote.c
index 02d432e8b..958a88651 100644
--- a/examples/network/ls-remote.c
+++ b/examples/network/ls-remote.c
@@ -19,7 +19,7 @@ int use_unnamed(git_repository *repo, const char *url)
// Create an instance of a remote from the URL. The transport to use
// is detected from the URL
- error = git_remote_new(&remote, repo, url, NULL);
+ error = git_remote_new(&remote, repo, NULL, url, NULL);
if (error < GIT_SUCCESS)
goto cleanup;
diff --git a/include/git2/remote.h b/include/git2/remote.h
index e81e25f98..6550cd20b 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -38,11 +38,12 @@ GIT_BEGIN_DECL
*
* @param out pointer to the new remote object
* @param repo the associtated repository
- * @param url the remote repository's URL
* @param name the remote's name
+ * @param url the remote repository's URL
+ * @param fetch the fetch refspec to use for this remote
* @return GIT_SUCCESS or an error code
*/
-GIT_EXTERN(int) git_remote_new(git_remote **out, git_repository *repo, const char *url, const char *name);
+GIT_EXTERN(int) git_remote_new(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch);
/**
* Get the information for a particular remote
@@ -218,6 +219,16 @@ GIT_EXTERN(int) git_remote_supported_url(const char* url);
*/
GIT_EXTERN(int) git_remote_list(git_strarray *remotes_list, git_repository *repo);
+/**
+ * Add a remote with the default fetch refspec to the repository's configuration
+ *
+ * @param out the resulting remote
+ * @param repo the repository in which to create the remote
+ * @param name the remote's name
+ * @param url the remote's url
+ */
+GIT_EXTERN(int) git_remote_add(git_remote **out, git_repository *repo, const char *name, const char *url);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/src/attr.c b/src/attr.c
index b7ac6355d..616cec6ff 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -450,11 +450,11 @@ static int collect_attr_files(
git_vector_init(files, 4, NULL) < 0)
return -1;
- /* given a unrooted path in a non-bare repo, resolve it */
- if (workdir && git_path_root(path) < 0)
+ /* Resolve path in a non-bare repo */
+ if (workdir != NULL)
error = git_path_find_dir(&dir, path, workdir);
else
- error = git_buf_sets(&dir, path);
+ error = git_path_dirname_r(&dir, path);
if (error < 0)
goto cleanup;
diff --git a/src/config_file.c b/src/config_file.c
index 746d9655c..4ccec2bc1 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -258,18 +258,17 @@ static int config_set(git_config_file *cfg, const char *name, const char *value)
GITERR_CHECK_ALLOC(var->value);
}
+ if (config_write(b, key, NULL, value) < 0) {
+ cvar_free(var);
+ return -1;
+ }
+
git_strmap_insert2(b->values, key, var, old_var, rval);
if (rval < 0)
return -1;
if (old_var != NULL)
cvar_free(old_var);
- if (config_write(b, key, NULL, value) < 0) {
- git_strmap_delete(b->values, var->key);
- cvar_free(var);
- return -1;
- }
-
return 0;
}
@@ -1018,6 +1017,7 @@ static int config_write(diskfile_backend *cfg, const char *key, const regex_t *p
pre_end = post_start = cfg->reader.read_ptr;
git__free(current_section);
+ current_section = NULL;
if (parse_section_header(cfg, &current_section) < 0)
goto rewrite_fail;
diff --git a/src/netops.c b/src/netops.c
index 2d200002f..4d461a049 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -11,7 +11,6 @@
# include <sys/time.h>
# include <netdb.h>
#else
-# define _WIN32_WINNT 0x0501
# include <winsock2.h>
# include <Ws2tcpip.h>
# ifdef _MSC_VER
@@ -36,7 +35,7 @@ static void net_set_error(const char *str)
size = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
0, error, 0, (LPSTR)&err_str, 0, 0);
- giterr_set(GITERR_NET, "%s: $s", str, err_str);
+ giterr_set(GITERR_NET, "%s: %s", str, err_str);
LocalFree(err_str);
}
#else
diff --git a/src/object.c b/src/object.c
index e02bd69ba..02be5dac8 100644
--- a/src/object.c
+++ b/src/object.c
@@ -150,8 +150,8 @@ int git_object_lookup_prefix(
if (type != GIT_OBJ_ANY && type != odb_obj->raw.type) {
git_odb_object_free(odb_obj);
- giterr_set(GITERR_INVALID, "The given type does not match the type on the ODB");
- return -1;
+ giterr_set(GITERR_ODB, "The given type does not match the type on the ODB");
+ return GIT_ENOTFOUND;
}
type = odb_obj->raw.type;
diff --git a/src/path.c b/src/path.c
index 703f43af1..9f31676b1 100644
--- a/src/path.c
+++ b/src/path.c
@@ -205,9 +205,13 @@ int git_path_prettify(git_buf *path_out, const char *path, const char *base)
}
if (p_realpath(path, buf) == NULL) {
+ /* giterr_set resets the errno when dealing with a GITERR_OS kind of error */
+ int error = (errno == ENOENT || errno == ENOTDIR) ? GIT_ENOTFOUND : -1;
giterr_set(GITERR_OS, "Failed to resolve path '%s'", path);
+
git_buf_clear(path_out);
- return (errno == ENOENT) ? GIT_ENOTFOUND : -1;
+
+ return error;
}
return git_buf_sets(path_out, buf);
diff --git a/src/pkt.c b/src/pkt.c
index 00836bc34..b9c87f169 100644
--- a/src/pkt.c
+++ b/src/pkt.c
@@ -217,6 +217,7 @@ int git_pkt_parse_line(
* server is trying to send us the packfile already.
*/
if (bufflen >= 4 && !git__prefixcmp(line, "PACK")) {
+ giterr_clear();
*out = line;
return pack_pkt(head);
}
diff --git a/src/posix.c b/src/posix.c
index a3f81d767..a9a6af984 100644
--- a/src/posix.c
+++ b/src/posix.c
@@ -12,9 +12,20 @@
#ifndef GIT_WIN32
-int p_open(const char *path, int flags)
+int p_open(const char *path, int flags, ...)
{
- return open(path, flags | O_BINARY);
+ mode_t mode = 0;
+
+ if (flags & O_CREAT)
+ {
+ va_list arg_list;
+
+ va_start(arg_list, flags);
+ mode = (mode_t)va_arg(arg_list, int);
+ va_end(arg_list);
+ }
+
+ return open(path, flags | O_BINARY, mode);
}
int p_creat(const char *path, mode_t mode)
diff --git a/src/posix.h b/src/posix.h
index 752d5156f..d020d94ac 100644
--- a/src/posix.h
+++ b/src/posix.h
@@ -42,7 +42,7 @@ extern int p_write(git_file fd, const void *buf, size_t cnt);
#define p_close(fd) close(fd)
#define p_umask(m) umask(m)
-extern int p_open(const char *path, int flags);
+extern int p_open(const char *path, int flags, ...);
extern int p_creat(const char *path, mode_t mode);
extern int p_getcwd(char *buffer_out, size_t size);
extern int p_rename(const char *from, const char *to);
diff --git a/src/remote.c b/src/remote.c
index 98c256929..a5cfc822e 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -54,7 +54,7 @@ static int parse_remote_refspec(git_config *cfg, git_refspec *refspec, const cha
return refspec_parse(refspec, val);
}
-int git_remote_new(git_remote **out, git_repository *repo, const char *url, const char *name)
+int git_remote_new(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch)
{
git_remote *remote;
@@ -78,8 +78,17 @@ int git_remote_new(git_remote **out, git_repository *repo, const char *url, cons
GITERR_CHECK_ALLOC(remote->name);
}
+ if (fetch != NULL) {
+ if (refspec_parse(&remote->fetch, fetch) < 0)
+ goto on_error;
+ }
+
*out = remote;
return 0;
+
+on_error:
+ git_remote_free(remote);
+ return -1;
}
int git_remote_load(git_remote **out, git_repository *repo, const char *name)
@@ -102,24 +111,28 @@ int git_remote_load(git_remote **out, git_repository *repo, const char *name)
remote->name = git__strdup(name);
GITERR_CHECK_ALLOC(remote->name);
- if (git_vector_init(&remote->refs, 32, NULL) < 0)
- return -1;
-
- if (git_buf_printf(&buf, "remote.%s.url", name) < 0)
- return -1;
+ if (git_vector_init(&remote->refs, 32, NULL) < 0) {
+ error = -1;
+ goto cleanup;
+ }
- if (git_config_get_string(config, git_buf_cstr(&buf), &val) < 0) {
+ if (git_buf_printf(&buf, "remote.%s.url", name) < 0) {
error = -1;
goto cleanup;
}
+ if ((error = git_config_get_string(config, git_buf_cstr(&buf), &val)) < 0)
+ goto cleanup;
+
remote->repo = repo;
remote->url = git__strdup(val);
GITERR_CHECK_ALLOC(remote->url);
git_buf_clear(&buf);
- if (git_buf_printf(&buf, "remote.%s.fetch", name) < 0)
- return -1;
+ if (git_buf_printf(&buf, "remote.%s.fetch", name) < 0) {
+ error = -1;
+ goto cleanup;
+ }
error = parse_remote_refspec(config, &remote->fetch, git_buf_cstr(&buf));
if (error == GIT_ENOTFOUND)
@@ -131,8 +144,10 @@ int git_remote_load(git_remote **out, git_repository *repo, const char *name)
}
git_buf_clear(&buf);
- if (git_buf_printf(&buf, "remote.%s.push", name) < 0)
- return -1;
+ if (git_buf_printf(&buf, "remote.%s.push", name) < 0) {
+ error = -1;
+ goto cleanup;
+ }
error = parse_remote_refspec(config, &remote->push, git_buf_cstr(&buf));
if (error == GIT_ENOTFOUND)
@@ -470,3 +485,26 @@ int git_remote_list(git_strarray *remotes_list, git_repository *repo)
return 0;
}
+
+int git_remote_add(git_remote **out, git_repository *repo, const char *name, const char *url)
+{
+ git_buf buf = GIT_BUF_INIT;
+
+ if (git_buf_printf(&buf, "refs/heads/*:refs/remotes/%s/*", name) < 0)
+ return -1;
+
+ if (git_remote_new(out, repo, name, url, git_buf_cstr(&buf)) < 0)
+ goto on_error;
+
+ git_buf_free(&buf);
+
+ if (git_remote_save(*out) < 0)
+ goto on_error;
+
+ return 0;
+
+on_error:
+ git_buf_free(&buf);
+ git_remote_free(*out);
+ return -1;
+}
diff --git a/src/repository.c b/src/repository.c
index d4de38104..ea9673731 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -397,13 +397,14 @@ int git_repository_discover(
{
git_buf path = GIT_BUF_INIT;
uint32_t flags = across_fs ? GIT_REPOSITORY_OPEN_CROSS_FS : 0;
+ int error;
assert(start_path && repository_path && size > 0);
*repository_path = '\0';
- if (find_repo(&path, NULL, start_path, flags, ceiling_dirs) < 0)
- return -1;
+ if ((error = find_repo(&path, NULL, start_path, flags, ceiling_dirs)) < 0)
+ return error != GIT_ENOTFOUND ? -1 : error;
if (size < (size_t)(path.size + 1)) {
giterr_set(GITERR_REPOSITORY,
diff --git a/src/status.c b/src/status.c
index ff8535c66..546dc863d 100644
--- a/src/status.c
+++ b/src/status.c
@@ -340,17 +340,17 @@ int git_status_file(
assert(status_flags && repo && path);
if ((workdir = git_repository_workdir(repo)) == NULL) {
- giterr_set(GITERR_OS, "Cannot get file status from bare repo");
- return GIT_ENOTFOUND;
+ giterr_set(GITERR_INVALID, "Cannot get file status from bare repo");
+ return -1;
}
if (git_buf_joinpath(&temp_path, workdir, path) < 0)
return -1;
if (git_path_isdir(temp_path.ptr)) {
- giterr_set(GITERR_OS, "Cannot get file status for directory '%s'", temp_path.ptr);
+ giterr_set(GITERR_INVALID, "Cannot get file status for directory '%s'", temp_path.ptr);
git_buf_free(&temp_path);
- return GIT_ENOTFOUND;
+ return -1;
}
e = status_entry_new(NULL, path);
diff --git a/src/win32/posix.h b/src/win32/posix.h
index d13d3e39b..2666fccb4 100644
--- a/src/win32/posix.h
+++ b/src/win32/posix.h
@@ -45,7 +45,7 @@ extern int p_chmod(const char* path, mode_t mode);
extern int p_rmdir(const char* path);
extern int p_access(const char* path, mode_t mode);
extern int p_fsync(int fd);
-extern int p_open(const char *path, int flags);
+extern int p_open(const char *path, int flags, ...);
extern int p_creat(const char *path, mode_t mode);
extern int p_getcwd(char *buffer_out, size_t size);
extern int p_rename(const char *from, const char *to);
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index 8af664165..10de70da8 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -217,13 +217,27 @@ int p_readlink(const char *link, char *target, size_t target_len)
return dwRet;
}
-int p_open(const char *path, int flags)
+int p_open(const char *path, int flags, ...)
{
int fd;
- wchar_t* buf = gitwin_to_utf16(path);
+ wchar_t* buf;
+ mode_t mode = 0;
+
+ buf = gitwin_to_utf16(path);
if (!buf)
return -1;
- fd = _wopen(buf, flags | _O_BINARY);
+
+ if (flags & O_CREAT)
+ {
+ va_list arg_list;
+
+ va_start(arg_list, flags);
+ mode = va_arg(arg_list, mode_t);
+ va_end(arg_list);
+ }
+
+ fd = _wopen(buf, flags | _O_BINARY, mode);
+
git__free(buf);
return fd;
}
@@ -312,7 +326,7 @@ int p_hide_directory__w32(const char *path)
char *p_realpath(const char *orig_path, char *buffer)
{
- int ret;
+ int ret, buffer_sz = 0;
wchar_t* orig_path_w = gitwin_to_utf16(orig_path);
wchar_t* buffer_w = (wchar_t*)git__malloc(GIT_PATH_MAX * sizeof(wchar_t));
@@ -322,13 +336,14 @@ char *p_realpath(const char *orig_path, char *buffer)
ret = GetFullPathNameW(orig_path_w, GIT_PATH_MAX, buffer_w, NULL);
git__free(orig_path_w);
- if (!ret || ret > GIT_PATH_MAX) {
+ /* According to MSDN, a return value equals to zero means a failure. */
+ if (ret == 0 || ret > GIT_PATH_MAX) {
buffer = NULL;
goto done;
}
if (buffer == NULL) {
- int buffer_sz = WideCharToMultiByte(CP_UTF8, 0, buffer_w, -1, NULL, 0, NULL, NULL);
+ buffer_sz = WideCharToMultiByte(CP_UTF8, 0, buffer_w, -1, NULL, 0, NULL, NULL);
if (!buffer_sz ||
!(buffer = (char *)git__malloc(buffer_sz)) ||
@@ -336,10 +351,22 @@ char *p_realpath(const char *orig_path, char *buffer)
{
git__free(buffer);
buffer = NULL;
+ goto done;
}
} else {
- if (!WideCharToMultiByte(CP_UTF8, 0, buffer_w, -1, buffer, GIT_PATH_MAX, NULL, NULL))
+ if (!WideCharToMultiByte(CP_UTF8, 0, buffer_w, -1, buffer, GIT_PATH_MAX, NULL, NULL)) {
buffer = NULL;
+ goto done;
+ }
+ }
+
+ if (!git_path_exists(buffer))
+ {
+ if (buffer_sz > 0)
+ git__free(buffer);
+
+ buffer = NULL;
+ errno = ENOENT;
}
done:
diff --git a/tests-clar/clar b/tests-clar/clar
index 2c70da038..deb3b2689 100755
--- a/tests-clar/clar
+++ b/tests-clar/clar
@@ -297,10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VyhiRNG2h1GFNZRhk64+UbNjtKXE5WCJynNPp1EFTdFO+UlAVpZSpTKM3YWLE13kimDCotAJKudb0hcP+060xATUttCE5iEI8KFAYWZP4bR+WGR9dX6EzDGZe3C/nhNjV8v6hXE0WhWQlAUaTBEUUrBleoAlym54YzfwesN15GPhyFHe+zjkzPERRi4DJSg4HGNROPAh/PH5uwFfwXi2w0EhmBhlV8CHcjVa3MWc//0MnZus+Sagzv4/8yUoNUfgEoc78A0Mls38cp5rS0IQ9PC+Xw6PQKdp9572i+ujbirabq+3jpjt0jsZuDULfgj1SjVe6ZXvPUm7pVgyeZJEpZk0E3eA+PH2jSgr50mVfEhjwyZg7Vhxu2moYTibDl0WN9JGu36sSFBbK/hkLwtecFdZVF5MBz61+53A42nFe93SdL7OeYX3eprTNQdLHHqTxluGW4OTJlLxSoVNqWFwOg57BL8yRXZ6PXJjbT/cMi2Fg4UESgMUgsCsaELEfJPCCGQ7GQI6PIe1j+zcMFDRAwX6g3MtnOD/fmSQPIj66ukIehHcksiqm3MRZCPpZWtRKVYn05Q9fG64k2c38dTbf63eIKlZw"""
diff --git a/tests-clar/clar_helpers.c b/tests-clar/clar_helpers.c
index 697614095..d180285b8 100644
--- a/tests-clar/clar_helpers.c
+++ b/tests-clar/clar_helpers.c
@@ -30,7 +30,7 @@ void cl_git_mkfile(const char *filename, const char *content)
void cl_git_write2file(const char *filename, const char *new_content, int flags)
{
- int fd = open(filename, flags, 0644);
+ int fd = p_open(filename, flags, 0644);
cl_assert(fd >= 0);
if (!new_content)
new_content = "\n";
diff --git a/tests-clar/core/path.c b/tests-clar/core/path.c
index f02e0f761..d826612ac 100644
--- a/tests-clar/core/path.c
+++ b/tests-clar/core/path.c
@@ -405,3 +405,16 @@ void test_core_path__12_offset_to_path_root(void)
cl_assert(git_path_root("//computername") == -1);
#endif
}
+
+#define NON_EXISTING_FILEPATH "i_hope_i_do_not_exist"
+
+void test_core_path__13_cannot_prettify_a_non_existing_file(void)
+{
+ git_buf p = GIT_BUF_INIT;
+
+ cl_must_pass(git_path_exists(NON_EXISTING_FILEPATH) == false);
+ cl_assert_equal_i(GIT_ENOTFOUND, git_path_prettify(&p, NON_EXISTING_FILEPATH, NULL));
+ cl_assert_equal_i(GIT_ENOTFOUND, git_path_prettify(&p, NON_EXISTING_FILEPATH "/so-do-i", NULL));
+
+ git_buf_free(&p);
+}
diff --git a/tests-clar/network/remotelocal.c b/tests-clar/network/remotelocal.c
index e154226d9..35fa072ef 100644
--- a/tests-clar/network/remotelocal.c
+++ b/tests-clar/network/remotelocal.c
@@ -85,7 +85,7 @@ static void connect_to_local_repository(const char *local_repository)
{
build_local_file_url(&file_path_buf, local_repository);
- cl_git_pass(git_remote_new(&remote, repo, git_buf_cstr(&file_path_buf), NULL));
+ cl_git_pass(git_remote_new(&remote, repo, NULL, git_buf_cstr(&file_path_buf), NULL));
cl_git_pass(git_remote_connect(remote, GIT_DIR_FETCH));
}
diff --git a/tests-clar/network/remotes.c b/tests-clar/network/remotes.c
index 766a461b9..0649c86dd 100644
--- a/tests-clar/network/remotes.c
+++ b/tests-clar/network/remotes.c
@@ -78,7 +78,7 @@ void test_network_remotes__save(void)
git_remote_free(_remote);
/* Set up the remote and save it to config */
- cl_git_pass(git_remote_new(&_remote, _repo, "git://github.com/libgit2/libgit2", "upstream"));
+ cl_git_pass(git_remote_new(&_remote, _repo, "upstream", "git://github.com/libgit2/libgit2", NULL));
cl_git_pass(git_remote_set_fetchspec(_remote, "refs/heads/*:refs/remotes/upstream/*"));
cl_git_pass(git_remote_set_pushspec(_remote, "refs/heads/*:refs/heads/*"));
cl_git_pass(git_remote_save(_remote));
@@ -153,3 +153,20 @@ void test_network_remotes__list(void)
git_config_free(cfg);
}
+
+void test_network_remotes__loading_a_missing_remote_returns_ENOTFOUND(void)
+{
+ cl_assert_equal_i(GIT_ENOTFOUND, git_remote_load(&_remote, _repo, "just-left-few-minutes-ago"));
+}
+
+void test_network_remotes__add(void)
+{
+ git_remote_free(_remote);
+ cl_git_pass(git_remote_add(&_remote, _repo, "addtest", "http://github.com/libgit2/libgit2"));
+ git_remote_free(_remote);
+
+ cl_git_pass(git_remote_load(&_remote, _repo, "addtest"));
+ _refspec = git_remote_fetchspec(_remote);
+ cl_assert(!strcmp(git_refspec_src(_refspec), "refs/heads/*"));
+ cl_assert(!strcmp(git_refspec_dst(_refspec), "refs/remotes/addtest/*"));
+}
diff --git a/tests-clar/object/lookup.c b/tests-clar/object/lookup.c
new file mode 100644
index 000000000..4732865cb
--- /dev/null
+++ b/tests-clar/object/lookup.c
@@ -0,0 +1,37 @@
+#include "clar_libgit2.h"
+
+#include "repository.h"
+
+static git_repository *g_repo;
+
+void test_object_lookup__initialize(void)
+{
+ cl_git_pass(git_repository_open(&g_repo, cl_fixture("testrepo.git")));
+}
+
+void test_object_lookup__cleanup(void)
+{
+ git_repository_free(g_repo);
+}
+
+void test_object_lookup__lookup_wrong_type_returns_enotfound(void)
+{
+ const char *commit = "e90810b8df3e80c413d903f631643c716887138d";
+ git_oid oid;
+ git_object *object;
+
+ cl_git_pass(git_oid_fromstr(&oid, commit));
+ cl_assert_equal_i(
+ GIT_ENOTFOUND, git_object_lookup(&object, g_repo, &oid, GIT_OBJ_TAG));
+}
+
+void test_object_lookup__lookup_nonexisting_returns_enotfound(void)
+{
+ const char *unknown = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
+ git_oid oid;
+ git_object *object;
+
+ cl_git_pass(git_oid_fromstr(&oid, unknown));
+ cl_assert_equal_i(
+ GIT_ENOTFOUND, git_object_lookup(&object, g_repo, &oid, GIT_OBJ_ANY));
+}
diff --git a/tests-clar/repo/discover.c b/tests-clar/repo/discover.c
index 6b17d6dba..b3d639bd1 100644
--- a/tests-clar/repo/discover.c
+++ b/tests-clar/repo/discover.c
@@ -82,7 +82,7 @@ void test_repo_discover__0(void)
append_ceiling_dir(&ceiling_dirs_buf, TEMP_REPO_FOLDER);
ceiling_dirs = git_buf_cstr(&ceiling_dirs_buf);
- cl_git_fail(git_repository_discover(repository_path, sizeof(repository_path), DISCOVER_FOLDER, 0, ceiling_dirs));
+ cl_assert_equal_i(GIT_ENOTFOUND, git_repository_discover(repository_path, sizeof(repository_path), DISCOVER_FOLDER, 0, ceiling_dirs));
cl_git_pass(git_repository_init(&repo, DISCOVER_FOLDER, 1));
cl_git_pass(git_repository_discover(repository_path, sizeof(repository_path), DISCOVER_FOLDER, 0, ceiling_dirs));
@@ -117,7 +117,7 @@ void test_repo_discover__0(void)
cl_git_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_MALFORMED_FOLDER1, 0, ceiling_dirs));
cl_git_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_MALFORMED_FOLDER2, 0, ceiling_dirs));
cl_git_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_MALFORMED_FOLDER3, 0, ceiling_dirs));
- cl_git_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_NOT_FOUND_FOLDER, 0, ceiling_dirs));
+ cl_assert_equal_i(GIT_ENOTFOUND, git_repository_discover(found_path, sizeof(found_path), ALTERNATE_NOT_FOUND_FOLDER, 0, ceiling_dirs));
append_ceiling_dir(&ceiling_dirs_buf, SUB_REPOSITORY_FOLDER);
ceiling_dirs = git_buf_cstr(&ceiling_dirs_buf);
@@ -125,9 +125,9 @@ void test_repo_discover__0(void)
//this must pass as ceiling_directories cannot predent the current
//working directory to be checked
cl_git_pass(git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER, 0, ceiling_dirs));
- cl_git_fail(git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB, 0, ceiling_dirs));
- cl_git_fail(git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB_SUB, 0, ceiling_dirs));
- cl_git_fail(git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB_SUB_SUB, 0, ceiling_dirs));
+ cl_assert_equal_i(GIT_ENOTFOUND, git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB, 0, ceiling_dirs));
+ cl_assert_equal_i(GIT_ENOTFOUND, git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB_SUB, 0, ceiling_dirs));
+ cl_assert_equal_i(GIT_ENOTFOUND, git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB_SUB_SUB, 0, ceiling_dirs));
//.gitfile redirection should not be affected by ceiling directories
ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER, ceiling_dirs, sub_repository_path);
@@ -135,7 +135,7 @@ void test_repo_discover__0(void)
ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB, ceiling_dirs, sub_repository_path);
ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB_SUB, ceiling_dirs, repository_path);
- cl_git_pass(git_futils_rmdir_r(TEMP_REPO_FOLDER, 1));
+ cl_git_pass(git_futils_rmdir_r(TEMP_REPO_FOLDER, GIT_DIRREMOVAL_FILES_AND_DIRS));
git_repository_free(repo);
git_buf_free(&ceiling_dirs_buf);
}
diff --git a/tests-clar/repo/open.c b/tests-clar/repo/open.c
index 1813887ec..292466390 100644
--- a/tests-clar/repo/open.c
+++ b/tests-clar/repo/open.c
@@ -7,7 +7,7 @@ void test_repo_open__cleanup(void)
cl_git_sandbox_cleanup();
if (git_path_isdir("alternate"))
- git_futils_rmdir_r("alternate", 1);
+ git_futils_rmdir_r("alternate", GIT_DIRREMOVAL_FILES_AND_DIRS);
}
void test_repo_open__bare_empty_repo(void)
@@ -202,8 +202,8 @@ void test_repo_open__bad_gitlinks(void)
cl_git_fail(git_repository_open_ext(&repo, "alternate", 0, NULL));
}
- git_futils_rmdir_r("invalid", 1);
- git_futils_rmdir_r("invalid2", 1);
+ git_futils_rmdir_r("invalid", GIT_DIRREMOVAL_FILES_AND_DIRS);
+ git_futils_rmdir_r("invalid2", GIT_DIRREMOVAL_FILES_AND_DIRS);
}
#ifdef GIT_WIN32
@@ -274,3 +274,9 @@ void test_repo_open__win32_path(void)
git_buf_free(&winpath);
#endif
}
+
+void test_repo_open__opening_a_non_existing_repository_returns_ENOTFOUND(void)
+{
+ git_repository *repo;
+ cl_assert_equal_i(GIT_ENOTFOUND, git_repository_open(&repo, "i-do-not/exist"));
+} \ No newline at end of file
diff --git a/tests-clar/status/worktree.c b/tests-clar/status/worktree.c
index 8f48cf16a..c4c935c0d 100644
--- a/tests-clar/status/worktree.c
+++ b/tests-clar/status/worktree.c
@@ -275,6 +275,7 @@ void test_status_worktree__single_folder(void)
error = git_status_file(&status_flags, repo, "subdir");
cl_git_fail(error);
+ cl_assert(error != GIT_ENOTFOUND);
}
@@ -384,3 +385,19 @@ void test_status_worktree__issue_592_5(void)
git_buf_free(&path);
}
+
+void test_status_worktree__cannot_retrieve_the_status_of_a_bare_repository(void)
+{
+ git_repository *repo;
+ int error;
+ unsigned int status = 0;
+
+ cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
+
+ error = git_status_file(&status, repo, "dummy");
+
+ cl_git_fail(error);
+ cl_assert(error != GIT_ENOTFOUND);
+
+ git_repository_free(repo);
+}