summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/clone.c5
-rw-r--r--src/iterator.c4
-rw-r--r--src/path.c11
-rw-r--r--src/revwalk.c30
-rw-r--r--src/revwalk.h4
5 files changed, 38 insertions, 16 deletions
diff --git a/src/clone.c b/src/clone.c
index e19d02ba2..62f103561 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -430,10 +430,15 @@ int git_clone(
}
if (error != 0) {
+ git_error_state last_error = {0};
+ giterr_capture(&last_error, error);
+
git_repository_free(repo);
repo = NULL;
(void)git_futils_rmdir_r(local_path, NULL, rmdir_flags);
+
+ giterr_restore(&last_error);
}
*out = repo;
diff --git a/src/iterator.c b/src/iterator.c
index 401b5de93..e9ec65250 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -1313,8 +1313,8 @@ static int workdir_iterator__update_entry(fs_iterator *fi)
if (error < 0)
giterr_clear();
- /* mark submodule (or any dir with .git) as GITLINK and remove slash */
- if (!error || error == GIT_EEXISTS) {
+ /* mark submodule as GITLINK and remove slash */
+ if (!error) {
fi->entry.mode = S_IFGITLINK;
fi->entry.path[strlen(fi->entry.path) - 1] = '\0';
}
diff --git a/src/path.c b/src/path.c
index fa800b74c..1dccf90da 100644
--- a/src/path.c
+++ b/src/path.c
@@ -1051,15 +1051,8 @@ int git_path_dirload_with_stat(
}
if (S_ISDIR(ps->st.st_mode)) {
- if ((error = git_buf_joinpath(&full, full.ptr, ".git")) < 0)
- break;
-
- if (p_access(full.ptr, F_OK) == 0) {
- ps->st.st_mode = GIT_FILEMODE_COMMIT;
- } else {
- ps->path[ps->path_len++] = '/';
- ps->path[ps->path_len] = '\0';
- }
+ ps->path[ps->path_len++] = '/';
+ ps->path[ps->path_len] = '\0';
}
}
diff --git a/src/revwalk.c b/src/revwalk.c
index f037ee692..f0109360b 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -81,6 +81,9 @@ static int process_commit(git_revwalk *walk, git_commit_list_node *commit, int h
{
int error;
+ if (!hide && walk->hide_cb)
+ hide = walk->hide_cb(&commit->oid, walk->hide_cb_payload);
+
if (hide && mark_uninteresting(commit) < 0)
return -1;
@@ -178,11 +181,6 @@ static int push_ref(git_revwalk *walk, const char *refname, int hide, int from_g
return push_commit(walk, &oid, hide, from_glob);
}
-struct push_cb_data {
- git_revwalk *walk;
- int hide;
-};
-
static int push_glob(git_revwalk *walk, const char *glob, int hide)
{
int error = 0;
@@ -575,3 +573,25 @@ void git_revwalk_reset(git_revwalk *walk)
git_vector_clear(&walk->twos);
}
+int git_revwalk_add_hide_cb(
+ git_revwalk *walk,
+ git_revwalk_hide_cb hide_cb,
+ void *payload)
+{
+ assert(walk);
+
+ if (walk->walking)
+ git_revwalk_reset(walk);
+
+ if (walk->hide_cb) {
+ /* There is already a callback added */
+ giterr_set(GITERR_INVALID, "There is already a callback added to hide commits in revision walker.");
+ return -1;
+ }
+
+ walk->hide_cb = hide_cb;
+ walk->hide_cb_payload = payload;
+
+ return 0;
+}
+
diff --git a/src/revwalk.h b/src/revwalk.h
index a0ce1ae86..a0654f3e5 100644
--- a/src/revwalk.h
+++ b/src/revwalk.h
@@ -39,6 +39,10 @@ struct git_revwalk {
/* merge base calculation */
git_commit_list_node *one;
git_vector twos;
+
+ /* hide callback */
+ git_revwalk_hide_cb hide_cb;
+ void *hide_cb_payload;
};
git_commit_list_node *git_revwalk__commit_lookup(git_revwalk *walk, const git_oid *oid);