* [RFH] On a script for submodules
@ 2008-01-03 9:07 Imran M Yousuf
2008-01-03 9:39 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Imran M Yousuf @ 2008-01-03 9:07 UTC (permalink / raw)
To: git
Hi All,
I started writing a script intended for modular (Git modules)
projects. The script can be found at
http://repo.or.cz/w/git-modules-bs.git. This is a very rudimentary
version and I intend to make it more useful for developers who work
with multiple modules. I would also like to mention that I am not an
expert shell scripter thus probably have made several mistakes in the
script; I would really appreciate if someone would take their time to
suggest me improvements. I would also like to get some feedbacks as
what else could be added here. A brief description can be found in the
following posting.
http://imyousuf-tech.blogs.smartitengineering.com/2008/01/propagating-git-commands-to-its.html
Thank you,
--
Imran M Yousuf
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFH] On a script for submodules
2008-01-03 9:07 [RFH] On a script for submodules Imran M Yousuf
@ 2008-01-03 9:39 ` Junio C Hamano
2008-01-03 9:52 ` Imran M Yousuf
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2008-01-03 9:39 UTC (permalink / raw)
To: Imran M Yousuf; +Cc: git
"Imran M Yousuf" <imyousuf@gmail.com> writes:
> ... I would really appreciate if someone would take their time to
> suggest me improvements. I would also like to get some feedbacks as
> what else could be added here. A brief description can be found in the
> following posting.
Around here, it is customary to have discussion on-list, not
pointing at external web pages and repositories. I would
suggest starting by stating what the overall design is and how
it meshes with existing git-submodule command and its design.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFH] On a script for submodules
2008-01-03 9:39 ` Junio C Hamano
@ 2008-01-03 9:52 ` Imran M Yousuf
2008-01-06 4:06 ` Imran M Yousuf
0 siblings, 1 reply; 4+ messages in thread
From: Imran M Yousuf @ 2008-01-03 9:52 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 1975 bytes --]
Hi all,
Sorry for referring to the blog. I am writing the details here again
and also attached the script in the email.
I am fairly a new git user; I started working around with GIT on
Framework development project and I noticed that GIT commands executed
on the parent module is not propagated to the child modules. In some
use cases it would be extremely useful (at least for me) to be able to
be propagate a command from the master module to all its child at all
depth. I wrote the bash shell script (in the attachment) to simply
propagate commands from parent to its child. To use this script one
can simply do the following (I am assuming that the file will have the
name git-modules and will be an executable in $PATH):
for: git-pull
do: git-modules pull
for: git-status
do: git-modules status
for: git-commit -a -m "This is a test commit"
do: git-modules commit -a -m "This is a test commit"
for: git-checkout master
do: git-modules checkout master
Basically any git-X command can be simply be done as "git-modules X
args-as-usual".
It is mainly different from the git-submodule command in its usage. I
mainly wrote it to propagate commands. It could be extended for
further usage as well.
I would really appreciate and welcome criticism, feedback and addition
to the script.
Thank you,
On Jan 3, 2008 3:39 PM, Junio C Hamano <gitster@pobox.com> wrote:
> "Imran M Yousuf" <imyousuf@gmail.com> writes:
>
> > ... I would really appreciate if someone would take their time to
> > suggest me improvements. I would also like to get some feedbacks as
> > what else could be added here. A brief description can be found in the
> > following posting.
>
> Around here, it is customary to have discussion on-list, not
> pointing at external web pages and repositories. I would
> suggest starting by stating what the overall design is and how
> it meshes with existing git-submodule command and its design.
>
>
>
--
Imran M Yousuf
[-- Attachment #2: git-modules --]
[-- Type: application/octet-stream, Size: 1238 bytes --]
#!/bin/bash
ARGS=1
if [ $# -lt "$ARGS" ]; then
echo Not enough arguments.
echo Example \"\<this script\> status\" for \"git-status\" - git-modules status
exit 65;
fi
function traverseModule() {
current_dir=`pwd`
dir_path="$current_dir:$dir_path"
cd $1
eval $2
if [ -f .gitmodules ]; then
for mod_path in `grep "path =" .gitmodules | awk '{print $3}'`; do
traverseModule $mod_path $2
done
fi
old_dir=$(echo $dir_path | cut -d':' -f1-1)
cd $old_dir
dir_path=${dir_path:$(echo "${#old_dir}+1" | bc)}
}
project_home=`pwd`
echo Project Home: $project_home
if [ -d $project_home/.git/ ]; then
git_command=$1
shift
command_arguments=""
for arg in "$@"; do
if [ `expr index "$arg" ' '` -gt 0 ]; then
arg="\"$arg\""
fi
command_arguments="$command_arguments $arg"
done
echo GIT Command git-$git_command with arguments\($#\) "$command_arguments"
main_command="git-$git_command $command_arguments"
eval $main_command
if [ -f .gitmodules ]; then
for mod_path in `grep "path =" .gitmodules | awk '{print $3}'`; do
traverseModule $mod_path "$main_command"
done
fi
else
echo $project_home not a git repo thus exiting
exit
fi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFH] On a script for submodules
2008-01-03 9:52 ` Imran M Yousuf
@ 2008-01-06 4:06 ` Imran M Yousuf
0 siblings, 0 replies; 4+ messages in thread
From: Imran M Yousuf @ 2008-01-06 4:06 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 2852 bytes --]
Hi All,
I updated the script to do git submodule init and update if not done
already while recursing; fixed some issues and converted it into sh
script from bash. Hopefully by tomorrow I will be email a merge of
this script with git submodule by adding a recurse command in addition
to the ones existing and also add a parameter --init-submodules to the
git-clone command so that when cloning the git submodule init and git
submodule update is done internally.
I would be grateful if you would kindly provide your feedback.
Best regards,
Imran
On Jan 3, 2008 3:52 PM, Imran M Yousuf <imyousuf@gmail.com> wrote:
> Hi all,
>
> Sorry for referring to the blog. I am writing the details here again
> and also attached the script in the email.
>
> I am fairly a new git user; I started working around with GIT on
> Framework development project and I noticed that GIT commands executed
> on the parent module is not propagated to the child modules. In some
> use cases it would be extremely useful (at least for me) to be able to
> be propagate a command from the master module to all its child at all
> depth. I wrote the bash shell script (in the attachment) to simply
> propagate commands from parent to its child. To use this script one
> can simply do the following (I am assuming that the file will have the
> name git-modules and will be an executable in $PATH):
>
> for: git-pull
> do: git-modules pull
>
> for: git-status
> do: git-modules status
>
> for: git-commit -a -m "This is a test commit"
> do: git-modules commit -a -m "This is a test commit"
>
> for: git-checkout master
> do: git-modules checkout master
>
> Basically any git-X command can be simply be done as "git-modules X
> args-as-usual".
>
> It is mainly different from the git-submodule command in its usage. I
> mainly wrote it to propagate commands. It could be extended for
> further usage as well.
>
> I would really appreciate and welcome criticism, feedback and addition
> to the script.
>
> Thank you,
>
> On Jan 3, 2008 3:39 PM, Junio C Hamano <gitster@pobox.com> wrote:
>
> > "Imran M Yousuf" <imyousuf@gmail.com> writes:
> >
> > > ... I would really appreciate if someone would take their time to
> > > suggest me improvements. I would also like to get some feedbacks as
> > > what else could be added here. A brief description can be found in the
> > > following posting.
> >
> > Around here, it is customary to have discussion on-list, not
> > pointing at external web pages and repositories. I would
> > suggest starting by stating what the overall design is and how
> > it meshes with existing git-submodule command and its design.
> >
> >
> >
>
>
>
> --
> Imran M Yousuf
>
--
Imran M Yousuf
Entrepreneur & Software Engineer
Smart IT Engineering
Dhaka, Bangladesh
Email: imran@smartitengineering.com
Mobile: +880-1711402557
[-- Attachment #2: git-modules --]
[-- Type: application/octet-stream, Size: 1595 bytes --]
#!/bin/sh
ARGS=1
if [ $# -lt "$ARGS" ]; then
echo Not enough arguments.
echo Example \"\<this script\> status\" for \"git-status\" - git-modules status
exit 65;
fi
initializeSubModule() {
if [ ! -d "$1"/.git ]; then
echo Initializing and updating "$1"
git-submodule init "$1"; git-submodule update "$1"
fi
}
traverseModule() {
current_dir=`pwd`
dir_path="$current_dir:$dir_path"
initializeSubModule "$1"
cd "$1"
echo Working in mod $1 @ `pwd` with $2
eval "$2"
if [ -f .gitmodules ]; then
for mod_path in `grep "path =" .gitmodules | awk '{print $3}'`; do
traverseModule "$mod_path" "$2"
done
fi
old_dir=$(echo $dir_path | cut -d':' -f1-1)
length_old_dir=`expr "$old_dir" : '.*'`
cd $old_dir
index=$(echo "$length_old_dir+2" | bc)
dir_path=`echo $dir_path $index | awk '{print substr($1, $2)}'`
}
propagate() {
project_home=`pwd`
echo Project Home: $project_home
if [ -d $project_home/.git/ ]; then
git_command=$1
shift
command_arguments=""
for arg in "$@"; do
if [ `expr index "$arg" ' '` -gt 0 ]; then
arg="\"$arg\""
fi
command_arguments="$command_arguments $arg"
done
echo GIT Command git-$git_command with arguments\($#\) "$command_arguments"
main_command="git-$git_command $command_arguments"
eval $main_command
if [ -f .gitmodules ]; then
for mod_path in `grep "path =" .gitmodules | awk '{print $3}'`; do
traverseModule $mod_path "$main_command"
done
fi
else
echo $project_home not a git repo thus exiting
exit
fi
}
propagate "$@"
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-01-06 4:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-03 9:07 [RFH] On a script for submodules Imran M Yousuf
2008-01-03 9:39 ` Junio C Hamano
2008-01-03 9:52 ` Imran M Yousuf
2008-01-06 4:06 ` Imran M Yousuf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).