Re: [PATCH v4 3/6] submodule: Explicit local branch creation in module_clone

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

 



"W. Trevor King" <wking@xxxxxxxxxx> writes:

> @@ -817,11 +831,15 @@ cmd_update()
>  
>  		displaypath=$(relative_path "$prefix$sm_path")
>  
> -		if test "$update_module" = "none"
> -		then
> +		case "$update_module" in
> +		none)
>  			echo "Skipping submodule '$displaypath'"
>  			continue
> -		fi
> +			;;
> +		checkout)
> +			local_branch=""
> +			;;
> +		esac

I wonder if there is a way to avoid detaching (and you may need to
update the coddpath that resets the submodule to the commit
specified by the superproject tree) when it is safe to do so.

For an end user, running "submodule update" is similar to running
"git pull" in a project that does not use submodules, expressing "I
want to catch up with the work done by others".  In a working tree
with local changes, we do allow you to run "git pull" as long as
your local changes do not overlap with the work done by others, and
the result of the pull would look as if you did not have any of the
local changes when you ran "git pull" and then you did the local
changes on top of the state that is up-to-date with their work.

Can't we design "submodule update --checkout" to work in a similar
fashion?  The updated superproject may say it wants $oSHA-1 at a
submodule path P, and also its .gitmodules may say that commit is
supposed to be at the tip of branch B=submodule.P.branch in the
submodule repository.  You may locally have advanced that branch in
your submodule repository in the meantime to point at $ySHA-1 while
others worked in the superproject and the submodule, and the
difference $oSHA-1...$ySHA-1 can be considered as the local change
made by you from the perspective of the superproject.

Without thinking things through, if $ySHA-1 matches or is a
descendant of $oSHA-1 (assuming that remote-tracking branch
origin/$B in the submodule does point at $oSHA-1 in either case), it
should be safe to do this update.

And in a situation where you cannot do the checkout safely, it is
perfectly fine to say "the submodules X and Y have local changes;
you cannot do 'submodule update' until you upstream them" and fail
the update, just like we fail a 'git pull' saying "you cannot do
pull until you commit them", no?

Perhaps that kind of "'git submodule update' is parallel to 'git
pull' in the project without submodules" is better done with other
update modes like --rebase or --merge.  If so, how should we explain
what 'submodule update --checkout' is to the end users?  Is it
supposed to be like "git fetch && git checkout origin/master"?

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[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]