threads / discuss / 16427

why no "git fetch --dry-run" ?

Subject: why no "git fetch --dry-run" ?

## tl;dr

4 messages between Nov 21, 2008 and Nov 22, 2008.

replies: 3people: 4as markdown or json

Leo Razoumov· Nov 21, 2008, 21:41 UTC · lore

Hello List, I am curious why there is "git push --dry-run" and no "git fetch --dry-run" nor "git pull --dry-run". It would make sense to keep push/pull/fetch as symmetric as possible. For example, I just want to see which branches, if any, changed on a remote repository since my last fetch. "git fetch -v --dry-run" would be handy in this case.

--Leo--
Miklos Vajna· Nov 21, 2008, 22:18 UTC · re: Leo Razoumov · lore

Re: why no "git fetch --dry-run" ?

On Fri, Nov 21, 2008 at 04:41:57PM -0500, Leo Razoumov <slonik.az@gmail.com> wrote:
Show 6 quoted lines
> I am curious why there is "git push --dry-run" and no "git fetch
> --dry-run" nor "git pull --dry-run". It would make sense to keep
> push/pull/fetch as symmetric as possible.
> For example, I just want to see which branches, if any, changed on a
> remote repository since my last fetch. "git fetch -v --dry-run" would
> be handy in this case.

Actually fetch - at a core level - isn't symmetric to push, the protocol is completely different. I haven't checked the source, but I suppose that the push protocol has "dry run" support, while the fetch one doesn't have.

Baz· Nov 21, 2008, 23:14 UTC · re: Miklos Vajna · lore

Re: why no "git fetch --dry-run" ?

2008/11/21 Miklos Vajna <vmiklos@frugalware.org>:
Show 13 quoted lines
> On Fri, Nov 21, 2008 at 04:41:57PM -0500, Leo Razoumov <slonik.az@gmail.com> wrote:
>> I am curious why there is "git push --dry-run" and no "git fetch
>> --dry-run" nor "git pull --dry-run". It would make sense to keep
>> push/pull/fetch as symmetric as possible.
>> For example, I just want to see which branches, if any, changed on a
>> remote repository since my last fetch. "git fetch -v --dry-run" would
>> be handy in this case.
>
> Actually fetch - at a core level - isn't symmetric to push, the protocol
> is completely different. I haven't checked the source, but I suppose
> that the push protocol has "dry run" support, while the fetch one
> doesn't have.
>

I wrote the patch for "push --dry-run" because I was more worried about messing up the central repository (which I can't fix) than messing up my local repository (which I can). It just needed a few checks added to send-pack to make it work. I guess it's not been done for fetch yet because nobody had that itch, shouldn't be too hard to write. Certainly, other people have asked for it.

-Baz
Junio C Hamano· Nov 22, 2008, 00:40 UTC · re: Leo Razoumov · lore

Re: why no "git fetch --dry-run" ?

"Leo Razoumov" <slonik.az@gmail.com> writes:
> I am curious why there is "git push --dry-run" and no "git fetch
> --dry-run" nor "git pull --dry-run". It would make sense to keep
> push/pull/fetch as symmetric as possible.

There are things that are not implemented in git because they do not make sense, and there are things that are not implemented in git because nobody had itch to scratch for. To put it differently, we tend to implement only things that there are actual, demonstrated needs for from real world and only when the addition makes sense as a coherent part of the system.

"fetch --dry-run" falls into the latter category.

"push" is hard to undo because it affects the outside world, but "fetch" is only about your local object store and its remote tracking branches, so the need to have --dry-run mode to "push" was much more real than to the need for "fetch --dry-run" and was implemented.

If you have the itch for the latter, I do not think anybody objects to it on the ground that such a feature does not make sense.

Having said that, "fetch --dry-run" probably has little value in practice. You cannot tell how much data will be transferred before actually running a fetch, so it won't be a tool for you to decide if you can afford the time to run fetch now or do that later ("push --dry-run" will let you gain the necessary information for doing this this if your push is fast-forward, which should mostly be the case). The only information you would get is if an actual "fetch" will have any update to each of the branches you are tracking (so that's one bit per branch) and if you have a connection to the other end, and that is about it.

← back to recent threads