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

[PATCH 2/3] fetch --prune: Always print header url

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

If fetch --prune is run with no new refs to fetch, but it has refs to prune. Then, the header url is not printed as it would if there were new refs to fetch. the following is example output showing this behavior:

$ git fetch --prune --dry-run origin
 x [deleted]         (none)     -> origin/world
After this patch the output of fetch --prune should look like this:
$ git fetch --prune --dry-run origin
From https://github.com/git/git
 x [deleted]         (none)     -> origin/test
Signed-off-by: Tom Miller <jackerran@gmail.com>
---
 builtin/fetch.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index b3145f6..e50b697 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -732,7 +732,8 @@ static int fetch_refs(struct transport *transport, struct ref *ref_map)
 	return ret;
 }
 
-static int prune_refs(struct refspec *refs, int ref_count, struct ref *ref_map)
+static int prune_refs(struct refspec *refs, int ref_count, struct ref *ref_map,
+			const char *raw_url)
 {
 	int result = 0;
 	struct ref *ref, *stale_refs = get_stale_heads(refs, ref_count, ref_map);
@@ -744,6 +745,7 @@ static int prune_refs(struct refspec *refs, int ref_count, struct ref *ref_map)
 		if (!dry_run)
 			result |= delete_ref(ref->name, NULL, 0);
 		if (verbosity >= 0) {
+			print_url(raw_url);
 			fprintf(stderr, " x %-*s %-*s -> %s\n",
 				TRANSPORT_SUMMARY(_("[deleted]")),
 				REFCOL_WIDTH, _("(none)"), prettify_refname(ref->name));
@@ -878,11 +880,12 @@ static int do_fetch(struct transport *transport,
 		 * don't care whether --tags was specified.
 		 */
 		if (ref_count) {
-			prune_refs(refs, ref_count, ref_map);
+			prune_refs(refs, ref_count, ref_map, transport->url);
 		} else {
 			prune_refs(transport->remote->fetch,
 				   transport->remote->fetch_refspec_nr,
-				   ref_map);
+				   ref_map,
+				   transport->url);
 		}
 	}
 	free_refs(ref_map);
-- 
1.8.5.1.163.gd7aced9
Previous: Tom MillerNext: Tom Miller
Message 2 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.