Re: [PATCH v2 2/9] Implement "git mv" for submodules

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

 



Peter Collingbourne <peter@xxxxxxxxx> writes:

> +		OPT_BOOLEAN('M', NULL, &skip_module_update, "don't upda...

If you are moving them by default, it is confusing to make up a negative
"skip" option like this.

Instead, add a boolean "module_update" that defaults to true, and give
"--[no-]module-update" without a short single-letter option, i.e.

	OPT_BOOLEAN(0 , "module-update", &module_update, "update submodule entries")

Exactly the same comment applies to your "git rm" patch.

> @@ -96,13 +98,14 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
>  	/* Checking */
>  	for (i = 0; i < argc; i++) {
>  		const char *src = source[i], *dst = destination[i];
> -		int length, src_is_dir;
> +		int length, src_is_dir, pos;
>  		const char *bad = NULL;
>  
>  		if (show_only)
>  			printf("Checking rename of '%s' to '%s'\n", src, dst);
>  
>  		length = strlen(src);
> +		pos = cache_name_pos(src, length);
>  		if (lstat(src, &st) < 0)
>  			bad = "bad source";
>  		else if (!strncmp(src, dst, length) &&
> @@ -111,7 +114,9 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
>  		} else if ((src_is_dir = S_ISDIR(st.st_mode))
>  				&& lstat(dst, &st) == 0)
>  			bad = "cannot move directory over file";
> -		else if (src_is_dir) {
> +		else if (src_is_dir &&
> +				!(pos >= 0 &&
> +				  S_ISGITLINK(active_cache[pos]->ce_mode))) {

This looks like a funny indentation (perhaps a "diff" artifcat???)...

> diff --git a/git-submodule.sh b/git-submodule.sh
> index de29f3a..f1e4e22 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -859,6 +859,20 @@ cmd_sync()
>  		fi
>  	done
>  }
> +#
> +# Updates the entry in .gitmodules to move a submodule.
> +# This command is called by "git mv" for each submodule it moves.
> +#
> +cmd_mvconfig()
> +{
> +	src="$1"
> +	dst="$2"
> +
> +	name=$(module_name "$src") || exit
> +	git config -f .gitmodules submodule."$name".path "$dst" ||
> +		die "Could not update .gitmodules entry for $name"
> +	git add .gitmodules || die "Could not add .gitmodules to index"
> +}

This does not seem to depend on the first "give random name to submodules"
patch in the series, or does it?
--
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]