Re: [RFC/PATCHv2] submodule: add ability to configure update command

2013-07-02 Thread Chris Packham
On 02/07/13 04:48, Junio C Hamano wrote:
 Chris Packham judge.pack...@gmail.com writes:
 
 +!*)
 +command=$(expr $update_module : '!\(.*\)')
 
   command=${command#!}
 

Thanks, expr was my attempt to avoid using a ${command:1} bash-ism. v3
on it's way.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC/PATCHv2] submodule: add ability to configure update command

2013-07-01 Thread Chris Packham
Users can set submodule.$name.update to '!command' which will cause
'command' to be run instead of checkout/merge/rebase.  This allows the
user some finer grained control over how the update is done. The primary
motivation for this was interoperability with stgit however being able
to intercept the submodule update process may prove useful for
integrating or extending other tools.

Signed-off-by: Chris Packham judge.pack...@gmail.com
---

On 01/07/13 03:30, Jens Lehmann wrote:

 Hmm, if we go that route, why not do the same we do for aliases? If
 the submodule.*.update setting is prefixed with a '!', we just execute
 the shell command following. This would give everyone the freedom to
 do arbitrary stuff if the current none, checkout, merge  rebase won't
 do the trick without having to add another config option.


And here's an implementation of this. Actually I like this a lot better
to the v1 patch. Still lacks tests but if there is enough interest I can
add some.

 Documentation/git-submodule.txt | 5 -
 git-submodule.sh| 6 ++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index e576713..0befc20 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -159,7 +159,9 @@ update::
This will make the submodules HEAD be detached unless `--rebase` or
`--merge` is specified or the key `submodule.$name.update` is set to
`rebase`, `merge` or `none`. `none` can be overridden by specifying
-   `--checkout`.
+   `--checkout`. Setting the key `submodule.$name.update` to `!command`
+   will cause `command` to be run. `command` can be any arbitrary shell
+   command that takes a single argument, namely the sha1 to update to.
 +
 If the submodule is not yet initialized, and you just want to use the
 setting as stored in .gitmodules, you can automatically initialize the
@@ -172,6 +174,7 @@ If `--force` is specified, the submodule will be checked 
out (using
 `git checkout --force` if appropriate), even if the commit specified in the
 index of the containing repository already matches the commit checked out in
 the submodule.
++
 
 summary::
Show commit summary between the given commit (defaults to HEAD) and
diff --git a/git-submodule.sh b/git-submodule.sh
index eb58c8e..680cb68 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -799,6 +799,12 @@ Maybe you want to use 'update --init'?)
say_msg=$(eval_gettext Submodule path 
'\$prefix\$sm_path': merged in '\$sha1')
must_die_on_failure=yes
;;
+   !*)
+   command=$(expr $update_module : '!\(.*\)')
+   die_msg=$(eval_gettext Unable to exec 
'\$command \$sha1' in submodule path '\$prefix\$sm_path')
+   say_msg=$(eval_gettext Submodule path 
'\$prefix\$sm_path': '\$command \$sha1')
+   must_die_on_failure=yes
+   ;;
*)
command=git checkout $subforce -q
die_msg=$(eval_gettext Unable to checkout 
'\$sha1' in submodule path '\$prefix\$sm_path')
-- 
1.8.3.1.644.g533062f.dirty

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


Re: [RFC/PATCHv2] submodule: add ability to configure update command

2013-07-01 Thread Junio C Hamano
Chris Packham judge.pack...@gmail.com writes:

 Subject: Re: [RFC/PATCHv2] submodule: add ability to configure update command

ability to configure wants to be rephrased to make it more useful
in the shortlog output to help me update release notes ;-)

Subject: [PATCH] submodule update: allow custom update command

perhaps?  We already allow you to configure update command between
merge, rebase and checkout-to-detach, and the value of the change is
to let an arbitrary custom command to be used there.

 And here's an implementation of this. Actually I like this a lot better
 to the v1 patch.

I agree that this looks much more sensible.

Thanks.

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


Re: [RFC/PATCHv2] submodule: add ability to configure update command

2013-07-01 Thread Junio C Hamano
Chris Packham judge.pack...@gmail.com writes:

 + !*)
 + command=$(expr $update_module : '!\(.*\)')

command=${command#!}

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