summaryrefslogtreecommitdiff
path: root/shallow.c
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2021-03-03 15:16:21 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2021-03-03 15:16:21 +0900
commite3b7705207b3e9c661026e43b95cfb2f40d7e6f2 (patch)
tree8b454ead9d5277e6212d03dcd92aacc7c96a574f /shallow.c
parentd6e11a6ebb61d22349f15df790fc8fe080ad5b52 (diff)
downloadgit-e3b7705207b3e9c661026e43b95cfb2f40d7e6f2.tar.gz
git-e3b7705207b3e9c661026e43b95cfb2f40d7e6f2.tar.bz2
git-e3b7705207b3e9c661026e43b95cfb2f40d7e6f2.zip
Imported Upstream version 2.15.0upstream/2.15.0
Diffstat (limited to 'shallow.c')
-rw-r--r--shallow.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/shallow.c b/shallow.c
index e8429a9a..df4d44ea 100644
--- a/shallow.c
+++ b/shallow.c
@@ -99,7 +99,7 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,
cur_depth = 0;
} else {
commit = (struct commit *)
- stack.objects[--stack.nr].item;
+ object_array_pop(&stack);
cur_depth = *(int *)commit->util;
}
}
@@ -107,7 +107,7 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,
cur_depth++;
if ((depth != INFINITE_DEPTH && cur_depth >= depth) ||
(is_repository_shallow() && !commit->parents &&
- (graft = lookup_commit_graft(commit->object.oid.hash)) != NULL &&
+ (graft = lookup_commit_graft(&commit->object.oid)) != NULL &&
graft->nr_parent < 0)) {
commit_list_insert(commit, &result);
commit->object.flags |= shallow_flag;
@@ -286,28 +286,26 @@ int write_shallow_commits(struct strbuf *out, int use_pack_protocol,
return write_shallow_commits_1(out, use_pack_protocol, extra, 0);
}
-static struct tempfile temporary_shallow;
-
const char *setup_temporary_shallow(const struct oid_array *extra)
{
+ struct tempfile *temp;
struct strbuf sb = STRBUF_INIT;
- int fd;
if (write_shallow_commits(&sb, 0, extra)) {
- fd = xmks_tempfile(&temporary_shallow, git_path("shallow_XXXXXX"));
+ temp = xmks_tempfile(git_path("shallow_XXXXXX"));
- if (write_in_full(fd, sb.buf, sb.len) < 0)
+ if (write_in_full(temp->fd, sb.buf, sb.len) < 0 ||
+ close_tempfile_gently(temp) < 0)
die_errno("failed to write to %s",
- get_tempfile_path(&temporary_shallow));
- close_tempfile(&temporary_shallow);
+ get_tempfile_path(temp));
strbuf_release(&sb);
- return get_tempfile_path(&temporary_shallow);
+ return get_tempfile_path(temp);
}
/*
* is_repository_shallow() sees empty string as "no shallow
* file".
*/
- return get_tempfile_path(&temporary_shallow);
+ return "";
}
void setup_alternate_shallow(struct lock_file *shallow_lock,
@@ -398,7 +396,7 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)
for (i = 0; i < sa->nr; i++) {
if (has_object_file(sa->oid + i)) {
struct commit_graft *graft;
- graft = lookup_commit_graft(sa->oid[i].hash);
+ graft = lookup_commit_graft(&sa->oid[i]);
if (graft && graft->nr_parent < 0)
continue;
info->ours[info->nr_ours++] = i;