Skip to content

Commit a569670

Browse files
committed
skip descendant check if remote ref not found
1 parent 39fd764 commit a569670

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

src/remote.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,9 @@ static int update_tips_for_spec(
14601460
if (error < 0 && error != GIT_ENOTFOUND)
14611461
goto on_error;
14621462

1463-
if (!error && !spec->force && !git_graph_descendant_of(remote->repo, &head->oid, &old))
1463+
if (!(error || error == GIT_ENOTFOUND)
1464+
&& !spec->force
1465+
&& !git_graph_descendant_of(remote->repo, &head->oid, &old))
14641466
continue;
14651467

14661468
if (error == GIT_ENOTFOUND) {

tests/remote/fetch.c

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,18 @@ static const char *REPO2_REFNAME = "refs/remotes/repo1/main";
1313
static char *FORCE_FETCHSPEC = "+refs/heads/main:refs/remotes/repo1/main";
1414
static char *NON_FORCE_FETCHSPEC = "refs/heads/main:refs/remotes/repo1/main";
1515

16-
char* strip_trailing_slash(char *path) {
17-
if (path[strlen(path) - 1] == '/') {
18-
char* result = (char *) calloc(strlen(path) - 1, sizeof(char));
19-
memcpy(result, path, strlen(path) - 1);
20-
return result;
21-
} else {
22-
char* result = (char *) calloc(strlen(path), sizeof(char));
23-
strncpy(result, path, strlen(path));
24-
return result;
25-
}
26-
}
27-
28-
2916
void test_remote_fetch__initialize(void) {
3017
git_config *c;
3118
git_buf repo1_path_buf = GIT_BUF_INIT;
3219
git_buf repo2_path_buf = GIT_BUF_INIT;
3320
const char *sandbox = clar_sandbox_path();
3421

35-
cl_git_pass(git_buf_join(&repo1_path_buf, '/', sandbox, "fetchtest_repo1"));
36-
repo1_path = calloc(repo1_path_buf.size, sizeof(char));
37-
git_buf_copy_cstr(repo1_path, repo1_path_buf.size, &repo1_path_buf);
22+
cl_git_pass(git_buf_joinpath(&repo1_path_buf, sandbox, "fetchtest_repo1"));
23+
repo1_path = git_buf_detach(&repo1_path_buf);
3824
cl_git_pass(git_repository_init(&repo1, repo1_path, true));
3925

40-
cl_git_pass(git_buf_join(&repo2_path_buf, '/', sandbox, "fetchtest_repo2"));
41-
repo2_path = calloc(repo2_path_buf.size, sizeof(char));
42-
git_buf_copy_cstr(repo2_path, repo2_path_buf.size, &repo2_path_buf);
26+
cl_git_pass(git_buf_joinpath(&repo2_path_buf, sandbox, "fetchtest_repo2"));
27+
repo2_path = git_buf_detach(&repo2_path_buf);
4328
cl_git_pass(git_repository_init(&repo2, repo2_path, true));
4429

4530
cl_git_pass(git_repository_config(&c, repo1));

0 commit comments

Comments
 (0)