Re: [RFC PATCH v2 1/2] fetch: set-head with --set-head option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Bence Ferdinandy" <bence@xxxxxxxxxxxxxx> writes:

>> Ideally, because every "git fetch" you do will automatically learn
>> what their HEAD of the day points at, even without "--set-head", it
>> may be nice to let the user know when their HEAD changed, so that
>> the user can inspect the situation and decide.
>
> That would actually make sense, we could print a message saying HEAD has
> changed and I guess helpfully print the exact set-head command they would need
> to manually update should they wish to do so.

We need to be careful if we were to do this, though.  A user may see
that their HEAD points at their 'main' branch, and they know the
remote-tracking HEAD points at 'next' branch.  But the only thing
the latter tells us is that 'next' is, as far as this user is
concerned, the primary branch they are interested in from this
remote.  It may have been set earlier with "git remtoe set-head"
explicitly, or it may have been set back when "git clone" created
this repository and back then the remote had 'next' marked as its
primary branch.  In other words, the HEAD we learned from remote
while we are fetching from it may or may not be the same from the
remote-tracking HEAD we have, but it does not mean that the remote
recently flipped its HEAD if these two are different, but what we
want to report is "their HEAD used to point at 'master' but now it
is pointing at 'main'".

> So there will be no
> extra flag for fetch, rather:
>
> - if the remote HEAD does not exist, we create it
>
> - if it does exist, but has changed we print a message saying it was changed from X to Y and print the required command to update to this
>
> - no configuration needed

Very good, with two reservations.

 - if the remote HEAD does not exist, we may still not want to
   create it.  Imagine

	[remote "his"]
		url = https://git.kernel.org/pub/scm/git/git
		push = refs/heads/maint
		push = refs/heads/master
		push = refs/heads/next
		push = +refs/heads/seen

   without any refspec for the fetching side.  "git fetch his master"
   may learn where the remote HEAD is, and it may even be pointing
   at their 'master' branch, but because we do not maintain any
   remote tracking information for their 'master' (in other words,
   refs/remotes/his/master is not updated by this 'fetch' and there
   is no configuration to make future 'fetch' to do so).

 - it would be very nice to report when we notice that they changed
   their HEAD, but I do not think we have enough information to do
   so.  Our existing refs/remotes/origin/HEAD may not have been set
   to match their HEAD in the first place.

Thanks.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux