Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/submodule--helper.c9
-rw-r--r--git-compat-util.h3
-rw-r--r--repository.h3
3 files changed, 13 insertions, 2 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index bfcc8e2c99..7f0a39286f 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -63,7 +63,10 @@ static char *get_default_remote_submodule(const char *module_path)
{
struct repository subrepo;
- repo_submodule_init(&subrepo, the_repository, module_path, null_oid());
+ if (repo_submodule_init(&subrepo, the_repository, module_path,
+ null_oid()) < 0)
+ die(_("could not get a repository handle for submodule '%s'"),
+ module_path);
return repo_get_default_remote(&subrepo);
}
@@ -1480,7 +1483,9 @@ static int add_possible_reference_from_superproject(
struct strbuf err = STRBUF_INIT;
strbuf_add(&sb, odb->path, len);
- repo_init(&alternate, sb.buf, NULL);
+ if (repo_init(&alternate, sb.buf, NULL) < 0)
+ die(_("could not get a repository handle for gitdir '%s'"),
+ sb.buf);
/*
* We need to end the new path with '/' to mark it as a dir,
diff --git a/git-compat-util.h b/git-compat-util.h
index 58d7708296..3eb7785bdd 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -565,8 +565,11 @@ static inline int git_has_dir_sep(const char *path)
/* The sentinel attribute is valid from gcc version 4.0 */
#if defined(__GNUC__) && (__GNUC__ >= 4)
#define LAST_ARG_MUST_BE_NULL __attribute__((sentinel))
+/* warn_unused_result exists as of gcc 3.4.0, but be lazy and check 4.0 */
+#define RESULT_MUST_BE_USED __attribute__ ((warn_unused_result))
#else
#define LAST_ARG_MUST_BE_NULL
+#define RESULT_MUST_BE_USED
#endif
#define MAYBE_UNUSED __attribute__((__unused__))
diff --git a/repository.h b/repository.h
index 6cc661e5a4..17c45ae096 100644
--- a/repository.h
+++ b/repository.h
@@ -1,6 +1,7 @@
#ifndef REPOSITORY_H
#define REPOSITORY_H
+#include "git-compat-util.h"
#include "path.h"
struct config_set;
@@ -185,6 +186,7 @@ void repo_set_gitdir(struct repository *repo, const char *root,
void repo_set_worktree(struct repository *repo, const char *path);
void repo_set_hash_algo(struct repository *repo, int algo);
void initialize_the_repository(void);
+RESULT_MUST_BE_USED
int repo_init(struct repository *r, const char *gitdir, const char *worktree);
/*
@@ -196,6 +198,7 @@ int repo_init(struct repository *r, const char *gitdir, const char *worktree);
* Return 0 upon success and a non-zero value upon failure.
*/
struct object_id;
+RESULT_MUST_BE_USED
int repo_submodule_init(struct repository *subrepo,
struct repository *superproject,
const char *path,