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

Re: [PATCH] Added --mirror-all to git-fetch.

From
Shawn Pearce <spearce@spearce.org>
Date
Sep 20, 2006, 16:49 UTC
Message-ID
<20060920164912.GD23260@spearce.org>
In-Reply-To
<7v1wq6jy3q.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> wrote:
Show 8 quoted lines
> I realize I am going around in circles, but Pasky's "remotes/"
> argument made me realize that this mirroring is not much more
> than "fetch --force --all".  I initially had an impression that
> this was for only strict mirroring where you do not even want
> your own "origin", but if you arrange the .git/remotes/origin
> file the right way, "fetch --force --all" (if you remembered to
> put '+' in front of the refspecs, even without --force) would
> what --mirror-all would do wouldn't it?

I started this change with '--all' and realized that ideally you want '--all' to copy all available refs/heads/* from the remote to refs/remotes/<name>/* here. You want to create any new branches which the remote has introduced since your last fetch.

You probably don't want to force a non-fast forward unless there's a '+' in the corresponding Pull line of remotes/<name> or if --force is used. However you probably also want to delete any removed branches.

Which I think is quite different from a mirror. A mirror wants to replace the entire ref namespace with what's on the remote as it has no need for a local namespace of its own.

Originally I gave Pasky a one-liner on #git:
  git fetch --force origin $(git ls-remote origin \
      | awk '{if(!/\^{}$/){print $2":"$2}}')

but he expressed interest in it being a native feature of the core-Git fetch Porcelain. To be honest I disagreed with him but submitted the patch anyway.

I think --all copying into .git/refs/remotes/<name>/* makes perfect sense.

And I think this mirror thing may make more sense as a small wrapper around git-fetch. A wrapper that checks for:

	- its running in a bare repository;
	- it has a single remote named origin;
	- HEAD isn't a symlink or a symref (its a normal ref in its
	  own right);
	- git-mirror.permitted is true in the config file.
 
-- 
Shawn.
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 14 in “Added --mirror-all to git-fetch.”
  1. Added --mirror-all to git-fetch.Shawn Pearce, Sep 19, 2006
  2. Petr BaudisSep 19, 2006
  3. Junio C HamanoSep 20, 2006
  4. Petr BaudisSep 20, 2006
  5. Shawn PearceSep 20, 2006
  6. Junio C HamanoSep 20, 2006
  7. Shawn PearceSep 20, 2006
  8. Junio C HamanoSep 20, 2006
  9. Shawn PearceSep 20, 2006
  10. Junio C HamanoSep 20, 2006
  11. A Large Angry SCMSep 20, 2006
  12. Petr BaudisSep 20, 2006
  13. Junio C HamanoSep 20, 2006
  14. Shawn PearceSep 20, 2006

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.