fetch: if not fetching from default remote, ignore default merge
When doing "git fetch <remote>" on a remote that does not have the branch referenced in branch.<current-branch>.merge, git fetch failed. It failed because it tried to add the "merge" ref to the refs to be fetched. Fix that. And add a test case. Incidentally, this unconvered a bug in our own test suite, where "git pull <some-path>" was expected to merge the ref given in the defaults, even if not pulling from the default remote. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Johannes Schindelin committed
Oct 11, 2007 at 01:47 UTC
da0204df587ae76cd291bc7e495fc60d873c2f20
3 files changed
+17
-3
builtin-fetch.c
+7
-1
@@ -105,7 +105,13 @@ static struct ref *get_ref_map(struct transport *transport,
105
!remote->fetch[0].pattern)
106
ref_map->merge = 1;
107
}
108
- if (has_merge)
108
+ /*
109
+ * if the remote we're fetching from is the same
110
+ * as given in branch.<name>.remote, we add the
111
+ * ref given in branch.<name>.merge, too.
112
+ */
113
+ if (has_merge && !strcmp(branch->remote_name,
114
+ remote->name))
115
add_merge_config(&ref_map, remote_refs, branch, &tail);
116
} else {
117
ref_map = get_remote_ref(remote_refs, "HEAD");
t/t5510-fetch.sh
+8
@@ -200,4 +200,12 @@ test_expect_success 'push via rsync' '
200
'
201
}
202
203
+test_expect_success 'fetch with a non-applying branch.<name>.merge' '
204
+ git config branch.master.remote yeti &&
205
+ git config branch.master.merge refs/heads/bigfoot &&
206
+ git config remote.blub.url one &&
207
+ git config remote.blub.fetch "refs/heads/*:refs/remotes/one/*" &&
208
+ git fetch blub
209
+'
210
+
211
test_done
t/t5700-clone-reference.sh
+2
-2
@@ -38,7 +38,7 @@ cd "$base_dir"
38
39
test_expect_success 'pulling from reference' \
40
'cd C &&
41
-git pull ../B'
41
+git pull ../B master'
42
43
cd "$base_dir"
44
@@ -61,7 +61,7 @@ test_expect_success 'existence of info/alternates' \
61
cd "$base_dir"
62
63
test_expect_success 'pulling from reference' \
64
-'cd D && git pull ../B'
64
+'cd D && git pull ../B master'
65
66
cd "$base_dir"
67