git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Imran M Yousuf" <imyousuf@gmail.com>
To: git@vger.kernel.org
Subject: Re: [RFH] On a script for submodules
Date: Sun, 6 Jan 2008 10:06:08 +0600	[thread overview]
Message-ID: <7bfdc29a0801052006g4d01ebc9mfb26f3829fc2a27f@mail.gmail.com> (raw)
In-Reply-To: <7bfdc29a0801030152t25de6889wc21b9c933f5b9ab9@mail.gmail.com>

[-- 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 "$@"

      reply	other threads:[~2008-01-06  4:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7bfdc29a0801052006g4d01ebc9mfb26f3829fc2a27f@mail.gmail.com \
    --to=imyousuf@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).