threads / patch / 10245

patchfetch: if not fetching from default remote, ignore default merge

Subject: [PATCH] fetch: if not fetching from default remote, ignore default merge

## tl;dr

4 messages between Oct 11, 2007 and Oct 11, 2007. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Johannes Schindelin· Oct 11, 2007, 00:47 UTC · lore

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>
---
 builtin-fetch.c            |    8 +++++++-
 t/t5510-fetch.sh           |    8 ++++++++
 t/t5700-clone-reference.sh |    4 ++--
 3 files changed, 17 insertions(+), 3 deletions(-)
Show changes to 3 files +17 −3

builtin-fetch.c, t/t5510-fetch.sh, t/t5700-clone-reference.sh

diff --git a/builtin-fetch.c b/builtin-fetch.c
index cf7498b..ca4de9f 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -105,7 +105,13 @@ static struct ref *get_ref_map(struct transport *transport,
 				    !remote->fetch[0].pattern)
 					ref_map->merge = 1;
 			}
-			if (has_merge)
+			/*
+			 * if the remote we're fetching from is the same
+			 * as given in branch.<name>.remote, we add the
+			 * ref given in branch.<name>.merge, too.
+			 */
+			if (has_merge && !strcmp(branch->remote_name,
+						remote->name))
 				add_merge_config(&ref_map, remote_refs, branch, &tail);
 		} else {
 			ref_map = get_remote_ref(remote_refs, "HEAD");
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 73a4e3c..755d809 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -188,4 +188,12 @@ test_expect_success 'push via rsync' '
 '
 }
 
+test_expect_success 'fetch with a non-applying branch.<name>.merge' '
+	git config branch.master.remote yeti &&
+	git config branch.master.merge refs/heads/bigfoot &&
+	git config remote.blub.url one &&
+	git config remote.blub.fetch 'refs/heads/*:refs/remotes/one/*' &&
+	git fetch blub
+'
+
 test_done
diff --git a/t/t5700-clone-reference.sh b/t/t5700-clone-reference.sh
index 4e93aaa..b6a5486 100755
--- a/t/t5700-clone-reference.sh
+++ b/t/t5700-clone-reference.sh
@@ -38,7 +38,7 @@ cd "$base_dir"
 
 test_expect_success 'pulling from reference' \
 'cd C &&
-git pull ../B'
+git pull ../B master'
 
 cd "$base_dir"
 
@@ -61,7 +61,7 @@ test_expect_success 'existence of info/alternates' \
 cd "$base_dir"
 
 test_expect_success 'pulling from reference' \
-'cd D && git pull ../B'
+'cd D && git pull ../B master'
 
 cd "$base_dir"
 
-- 
1.5.3.4.1169.g5fb8d
Johannes Sixt· Oct 11, 2007, 06:39 UTC · re: Johannes Schindelin · lore

Re: [PATCH] fetch: if not fetching from default remote, ignore default merge

Johannes Schindelin schrieb:
Show 5 quoted lines
> +test_expect_success 'fetch with a non-applying branch.<name>.merge' '
> +	git config branch.master.remote yeti &&
> +	git config branch.master.merge refs/heads/bigfoot &&
> +	git config remote.blub.url one &&
> +	git config remote.blub.fetch 'refs/heads/*:refs/remotes/one/*' &&
Better use double-quotes around the refspecs.
> +	git fetch blub
> +'
> +
-- Hannes
Johannes Schindelin· Oct 11, 2007, 11:34 UTC · re: Johannes Sixt · lore

Re: [PATCH] fetch: if not fetching from default remote, ignore default merge

Hi,
On Thu, 11 Oct 2007, Johannes Sixt wrote:
Show 8 quoted lines
> Johannes Schindelin schrieb:
> > +test_expect_success 'fetch with a non-applying branch.<name>.merge' '
> > +	git config branch.master.remote yeti &&
> > +	git config branch.master.merge refs/heads/bigfoot &&
> > +	git config remote.blub.url one &&
> > +	git config remote.blub.fetch 'refs/heads/*:refs/remotes/one/*' &&
> 
> Better use double-quotes around the refspecs.
Hehe, "oops!".

Although in this case we could even use the string unquoted (which I indeed did!), since there is no chance that there is a matching file in t/trash/.

Ciao, Dscho

Johannes Schindelin· Oct 11, 2007, 11:35 UTC · re: Johannes Sixt · lore

[PATCH v2] 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>
---
 builtin-fetch.c            |    8 +++++++-
 t/t5510-fetch.sh           |    8 ++++++++
 t/t5700-clone-reference.sh |    4 ++--
 3 files changed, 17 insertions(+), 3 deletions(-)
Show changes to 3 files +17 −3

builtin-fetch.c, t/t5510-fetch.sh, t/t5700-clone-reference.sh

diff --git a/builtin-fetch.c b/builtin-fetch.c
index cf7498b..ca4de9f 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -105,7 +105,13 @@ static struct ref *get_ref_map(struct transport *transport,
 				    !remote->fetch[0].pattern)
 					ref_map->merge = 1;
 			}
-			if (has_merge)
+			/*
+			 * if the remote we're fetching from is the same
+			 * as given in branch.<name>.remote, we add the
+			 * ref given in branch.<name>.merge, too.
+			 */
+			if (has_merge && !strcmp(branch->remote_name,
+						remote->name))
 				add_merge_config(&ref_map, remote_refs, branch, &tail);
 		} else {
 			ref_map = get_remote_ref(remote_refs, "HEAD");
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 73a4e3c..1f398bc 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -188,4 +188,12 @@ test_expect_success 'push via rsync' '
 '
 }
 
+test_expect_success 'fetch with a non-applying branch.<name>.merge' '
+	git config branch.master.remote yeti &&
+	git config branch.master.merge refs/heads/bigfoot &&
+	git config remote.blub.url one &&
+	git config remote.blub.fetch "refs/heads/*:refs/remotes/one/*" &&
+	git fetch blub
+'
+
 test_done
diff --git a/t/t5700-clone-reference.sh b/t/t5700-clone-reference.sh
index 4e93aaa..b6a5486 100755
--- a/t/t5700-clone-reference.sh
+++ b/t/t5700-clone-reference.sh
@@ -38,7 +38,7 @@ cd "$base_dir"
 
 test_expect_success 'pulling from reference' \
 'cd C &&
-git pull ../B'
+git pull ../B master'
 
 cd "$base_dir"
 
@@ -61,7 +61,7 @@ test_expect_success 'existence of info/alternates' \
 cd "$base_dir"
 
 test_expect_success 'pulling from reference' \
-'cd D && git pull ../B'
+'cd D && git pull ../B master'
 
 cd "$base_dir"
 
-- 
1.5.3.4.1174.gcd0d6-dirty

← back to recent threads