git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] fetch --prune: Repair branchname DF conflicts

From
TMTom Miller <jackerran@gmail.com>
Date
Dec 18, 2013, 21:22 UTC
Message-ID
<1387401776-30994-3-git-send-email-jackerran@gmail.com>
In-Reply-To
<1387401776-30994-1-git-send-email-jackerran@gmail.com>

When a branchname DF conflict occurs during a fetch, --prune should be able to fix it. When fetching with --prune, the fetching process happens before pruning causing the branchname DF conflict to persist and report an error. This patch prunes before fetching, thus correcting DF conflicts during a fetch.

Signed-off-by: Tom Miller <jackerran@gmail.com>
Tested-by: Thomas Rast <tr@thomasrast.ch>
---
 builtin/fetch.c  | 10 +++++-----
 t/t5510-fetch.sh | 14 ++++++++++++++
 2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index e50b697..845c687 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -868,11 +868,6 @@ static int do_fetch(struct transport *transport,
 
 	if (tags == TAGS_DEFAULT && autotags)
 		transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1");
-	if (fetch_refs(transport, ref_map)) {
-		free_refs(ref_map);
-		retcode = 1;
-		goto cleanup;
-	}
 	if (prune) {
 		/*
 		 * We only prune based on refspecs specified
@@ -888,6 +883,11 @@ static int do_fetch(struct transport *transport,
 				   transport->url);
 		}
 	}
+	if (fetch_refs(transport, ref_map)) {
+		free_refs(ref_map);
+		retcode = 1;
+		goto cleanup;
+	}
 	free_refs(ref_map);
 
 	/* if neither --no-tags nor --tags was specified, do automated tag
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 5d4581d..a981125 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -614,4 +614,18 @@ test_expect_success 'all boundary commits are excluded' '
 	test_bundle_object_count .git/objects/pack/pack-${pack##pack	}.pack 3
 '
 
+test_expect_success 'branchname D/F conflict resolved by --prune' '
+	git branch dir/file &&
+	git clone . prune-df-conflict &&
+	git branch -D dir/file &&
+	git branch dir &&
+	(
+		cd prune-df-conflict &&
+		git fetch --prune &&
+		git rev-parse origin/dir >../actual
+	) &&
+	git rev-parse dir >expect &&
+	test_cmp expect actual
+'
+
 test_done
-- 
1.8.5.1.163.gd7aced9
Previous: Tom MillerNext: Junio C Hamano
Message 3 of 13 in “builtin/fetch.c: Add pretty_url() and print_url()”
  1. 1/3 builtin/fetch.c: Add pretty_url() and print_url()Tom Miller, Dec 18, 2013
  2. 2/3 fetch --prune: Always print header urlTom Miller, Dec 18, 2013
  3. 3/3 fetch --prune: Repair branchname DF conflictsTom Miller, Dec 18, 2013
  4. Junio C HamanoDec 18, 2013
  5. Tom MillerDec 19, 2013
  6. Junio C HamanoDec 19, 2013
  7. Jeff KingDec 19, 2013
  8. Junio C HamanoDec 19, 2013
  9. Junio C HamanoDec 18, 2013
  10. Tom MillerDec 19, 2013
  11. Thomas MillerDec 19, 2013
  12. 1/2 fetch --prune: Always print header urlTom Miller, Dec 19, 2013
  13. 2/2 fetch --prune: Run prune before fetchingTom Miller, Dec 19, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.