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: Thu, 3 Jan 2008 15:52:04 +0600	[thread overview]
Message-ID: <7bfdc29a0801030152t25de6889wc21b9c933f5b9ab9@mail.gmail.com> (raw)
In-Reply-To: <7vsl1fs0xa.fsf@gitster.siamese.dyndns.org>

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


  reply	other threads:[~2008-01-03  9:52 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 [this message]
2008-01-06  4:06     ` Imran M Yousuf

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=7bfdc29a0801030152t25de6889wc21b9c933f5b9ab9@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).