Git development
 help / color / mirror / Atom feed
* Re: [PATCH 2/5] First step, making setup (somewhat) reentrant
From: Johannes Schindelin @ 2008-01-07 11:28 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Christian Thaeter, git
In-Reply-To: <7v4pdq0z30.fsf@gitster.siamese.dyndns.org>

Hi,

On Mon, 7 Jan 2008, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > Which brings me to a more fundamental question: what do you need 
> > reentrant setup_directory() for?  If it is just to allow multiple 
> > calls to that function for the _same_ repository, I say clean up your 
> > code.
> 
> IIRC, he is writing a set-of-repositories browser.
> 
> But I think the right approach of cleaning up is to design a
> layer of containers like we did for "the_index" libification

Yes, I concur. That was a nice abstraction without impacting existing code 
too much.

Ciao,
Dscho

^ permalink raw reply

* [PATCH] git-svn: clarify the "Ignoring error from SVN" piece
From: Eric Wong @ 2008-01-07 10:40 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List, Michael J. Cohen
In-Reply-To: <20080107103040.GA28557@soma>

I've heard of several users puzzled by this, and it sometimes it
appears as if git-svn is doing nothing on slower connections and
larger repositories.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 git-svn.perl |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 2c97b05..3308fe1 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -4085,6 +4085,10 @@ sub skip_unknown_revs {
 			warn "W: Ignoring error from SVN, path probably ",
 			     "does not exist: ($errno): ",
 			     $err->expanded_message,"\n";
+			warn "W: Do not be alarmed at the above message ",
+			     "git-svn is just searching aggressively for ",
+			     "old history.\n",
+			     "This may take a while on large repositories\n";
 			$ignored_err{$err_key} = 1;
 		}
 		return;
-- 
Eric Wong

^ permalink raw reply related

* Re: git-svn doesn't like !! in the url
From: Eric Wong @ 2008-01-07 10:30 UTC (permalink / raw)
  To: Michael J. Cohen; +Cc: Git Mailing List, Junio C Hamano
In-Reply-To: <EA596F68-D87B-49AD-9DEF-2C2E07127BDE@gmail.com>

"Michael J. Cohen" <michael.joseph.cohen@gmail.com> wrote:
> I think it needs to urlencode the items before it passes it back to  
> the server.
> 
> W: Ignoring error from SVN, path probably does not exist: (175007):  
> HTTP Path Not Found: REPORT request failed on '/wowace/!svn/bc/100/ 
> trunk/!!!LeaveMeAloneLibraries': '/wowace/!svn/bc/100/trunk/!!! 
> LeaveMeAloneLibraries' path not found
> 
> works fine with svn co.

Hi,

That was just a warning message (hence "W:").  If the path you're
tracking did not have a revision between r0 - r100 in the repository;
then it'll spew that warning once (it used to spew it a lot more).

git-svn looks at old history in chunks starting at the beginning of the
repository to avoid pulling (potentially) hundreds of thousands of
revisions + filenames into memory all at once.

As long as git-svn started importing revisions when the project started,
everything should be alright.



I just dug up cfbe7ab333d68790eb37341e30f040f99cef6af7 and that
should've escaped everything that needs to be urlencoded for HTTP(S).
(you were also the one that noticed the need for that one, too :).

I also just noticed that changeset didn't make it into 1.5.3.7 nor
maint, however...

Junio: if there are plans for 1.5.3.8, could you please add
cfbe7ab333d68790eb37341e30f040f99cef6af7 to it?  Thanks.

-- 
Eric Wong

^ permalink raw reply

* RFC/RFH submodule handling in big setups
From: Finn Arne Gangstad @ 2008-01-07 10:23 UTC (permalink / raw)
  To: git

We're trying to get git to work well with our vision of submodules,
and have to figure out how to make submodule fetching and pushing work
in a smooth way.

This is our situation (simplified):

          [product1]          [product2]  ...         (supermodules)
           /      \             /     \
    ... [foo]  [os-abstraction-lib] [log-merger] ...  (submodules)


A developer does a modification to the os-abstraction-lib, and a
modification to the log-merger that depends on the change in the
os-abstraction-lib. He wants this into product2, and doesn't know or
care about product1.  He doesn't know whether his modification is
acceptable or not, or whether his modification will go in before some
other modification.

He needs some way of pushing his modifications to a branch in the
supermodule (e.g. "change-131345"), without interfering with anyone
else.  The problem is where to push the sub-modules, they need to be
available for anyone who wants to get the "change-131345" branch of
the product2, but the modifications shouldn't show up anywhere else
(yet).  Here are solutions we have thought of so far:

1. push and fetch sha1s directly - this was sort of vetoed on this list.

2. each time you push a submodule, push it to a auto-generated
   tag (something like submodule-autogen-<sha1>), and use fetch -t
   when fetching the submodules

   Issue: Need to clean up these tags at some point, or there will be too
   many of them. There will be many ugly tags no matter what.

3. each time you push a submodule, do a merge ours to a
   "internal-submodule-tracking" branch, and push to that. Something
   like this in other words:

     git fetch origin internal-submodule-tracking
     git merge -s ours origin/internal-submodule-tracking
     git push origin internal-submodule-tracking
     git reset --hard HEAD^1

   Issue: feels wrong somehow?

4. Manually push all sub-modules to some new branch before pushing the
   super-module. This is what we'd rather avoid, but the developer
   should obviously have the option of doing this to some sub-modules
   if he wants to.

5. Secret option 5 - something we didn't think about

- Finn Arne

^ permalink raw reply

* Re: CRLF problems with Git on Win32
From: Peter Klavins @ 2008-01-07 10:13 UTC (permalink / raw)
  To: git
In-Reply-To: <5C0F88FD-AB2F-4BAD-ADEC-75428F14260F@zib.de>

I use an alternate workaround that clones the repository, removes the 
checked out files, sets autocrlf, then checks out the files again:

$ git clone git://git.debian.org/git/turqstat/turqstat.git
$ cd turqstat
$ git config --add core.autocrlf true
$ rm -rf * .gitignore
$ git reset --hard

The result should now be the same as using Steffen's system.

However, there is still an unresolved problem with git's way of treating 
cr/lf as an attribute only of the checkout and not the repository itself:

$ git status
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#
#       modified:   visualc/.gitignore
#       modified:   visualc/turqstat.sln
#       modified:   visualc/turqstat.vcproj
#
no changes added to commit (use "git add" and/or "git commit -a")

So, checking out the repository with cr/lf true has now caused misalignment 
of files that were originally checked in with existing cr/lf's in place. 
Visual Studio in fact happily works with files that only have lf endings, 
_except_ *.sln and *.vcproj files, which it much prefers to have with cr/lf 
endings.

The _real_ solution to this problem for the moment is _not_ to mix files 
with both lf and cr/lf endings in the repository.

So, the original author of the repository should _also_ have used 
core.autocrlf true, thus causing the *sln and *vcproj to have their cr's 
stripped on checkin, but replaced on checkout when checking out with 
autocrlf true.

------------------------------------------------------------------------
 Peter Klavins 

^ permalink raw reply

* Re: CRLF problems with Git on Win32
From: Jeff King @ 2008-01-07 10:12 UTC (permalink / raw)
  To: Steffen Prohaska; +Cc: Peter Karlsson, Git Mailing List
In-Reply-To: <5C0F88FD-AB2F-4BAD-ADEC-75428F14260F@zib.de>

On Mon, Jan 07, 2008 at 10:57:52AM +0100, Steffen Prohaska wrote:

> or you can manually do what clone would do for you, i.e.
>
>     mkdir turqstat
>     cd turqstat
>     git init
>     git config core.autocrlf true
>     git remote add origin git://git.debian.org/git/turqstat/turqstat.git
>     git fetch origin
>     git checkout -b master origin/master
>
> (this is what I typically do).
>
> BTW, I think that git clone should be improved to avoid the
> workaround described above.  Maybe it could ask the user if it
> should set up a specific line ending conversion before checkout.
> Unfortunately, I had no time to write a patch, yet.

I don't know if there are other options that might impact how clone
works, but something like the patch below might make sense. It would
allow:

  git clone -c core.autocrlf=true ...

Note that the patch should not be applied; it doesn't handle values with
whitespace (and hopefully builtin clone will come soon after v1.5.4,
which would make doing it right much simpler).

---

diff --git a/git-clone.sh b/git-clone.sh
index b4e858c..a002550 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -23,6 +23,7 @@ reference=           reference repository
 o,origin=            use <name> instead of 'origin' to track upstream
 u,upload-pack=       path to git-upload-pack on the remote
 depth=               create a shallow clone of that depth
+c,config=            set a config option of the form key=value
 
 use-separate-remote  compatibility, do not use
 no-separate-remote   compatibility, do not use"
@@ -127,6 +128,7 @@ use_separate_remote=t
 depth=
 no_progress=
 local_explicitly_asked_for=
+config=
 test -t 1 || no_progress=--no-progress
 
 while test $# != 0
@@ -173,6 +175,9 @@ do
 	--depth)
 		shift
 		depth="--depth=$1" ;;
+	-c|--config)
+		shift
+		config="$config $1" ;;
 	--)
 		shift
 		break ;;
@@ -242,6 +247,12 @@ fi &&
 export GIT_DIR &&
 GIT_CONFIG="$GIT_DIR/config" git-init $quiet ${template+"$template"} || usage
 
+for i in $config; do
+	key=`echo $i | cut -d= -f1`
+	value=`echo $i | cut -d= -f2-`
+	git config $key $value
+done
+
 if test -n "$bare"
 then
 	GIT_CONFIG="$GIT_DIR/config" git config core.bare true

^ permalink raw reply related

* Re: CRLF problems with Git on Win32
From: Junio C Hamano @ 2008-01-07 10:00 UTC (permalink / raw)
  To: Steffen Prohaska; +Cc: Peter Karlsson, Git Mailing List
In-Reply-To: <5C0F88FD-AB2F-4BAD-ADEC-75428F14260F@zib.de>

Steffen Prohaska <prohaska@zib.de> writes:

> Per default, CRLF conversion is disabled in msysgit.

That's interesting, as core.autocrlf was invented _specifically_
for use on Windows.

^ permalink raw reply

* Re: CRLF problems with Git on Win32
From: Steffen Prohaska @ 2008-01-07  9:57 UTC (permalink / raw)
  To: Peter Karlsson; +Cc: Git Mailing List
In-Reply-To: <Pine.LNX.4.64.0801071010340.1864@ds9.cixit.se>


On Jan 7, 2008, at 10:16 AM, Peter Karlsson wrote:

> When I clone git://git.debian.org/git/turqstat/turqstat.git using the
> msys-Windows version of git (1.5.4-rc2), some but not all the files  
> get
> autoconverted to CRLF. Is it possible to set properties for the files
> that are text, to make sure they are converted properly?

Per default, CRLF conversion is disabled in msysgit.  Git should
not convert a single file.  Does it really convert some?

You can verify that CRLF conversion is off by running

     git config core.autocrlf

which should just print an empty line.

You can enable automatic conversion for all text files by running

     git config core.autocrlf true

(this can be set on a per-repository basis or you can set a
  default for your account if you pass the '--global' option.)

A difficulty you'll run into is that you need to set
"core.autocrlf true" before you checkout.  But because git clone
fuses git init, git fetch, and git checkout into a single
operation, you can't use it as is if you like to enable CRLF
on a per-repository basis (it works if you set a global default).

You can either use

     git clone -n URL  # -n tells clone to stop before checkout
     cd turqstat
     git config core.autocrlf true
     git checkout -b master origin/master

or you can manually do what clone would do for you, i.e.

     mkdir turqstat
     cd turqstat
     git init
     git config core.autocrlf true
     git remote add origin git://git.debian.org/git/turqstat/ 
turqstat.git
     git fetch origin
     git checkout -b master origin/master

(this is what I typically do).

BTW, I think that git clone should be improved to avoid the
workaround described above.  Maybe it could ask the user if it
should set up a specific line ending conversion before checkout.
Unfortunately, I had no time to write a patch, yet.

	Steffen

^ permalink raw reply

* Re: [PATCH 2/5] First step, making setup (somewhat) reentrant
From: Junio C Hamano @ 2008-01-07  9:22 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Christian Thaeter, git, gitster
In-Reply-To: <alpine.LSU.1.00.0801070845270.10101@racer.site>

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> Which brings me to a more fundamental question: what do you need reentrant 
> setup_directory() for?  If it is just to allow multiple calls to that 
> function for the _same_ repository, I say clean up your code.

IIRC, he is writing a set-of-repositories browser.

But I think the right approach of cleaning up is to design a
layer of containers like we did for "the_index" libification
[*1*].  We would probably want:

 * a container that abstracts accesses to a single repository
   that includes:

    - set of refs;

    - object database and object hash (because different
      repositories can have different notion of who is parent of
      whom);

 * a container that abstracts accesses to a state of the index
   (we already have this -- the_index).

 * a container that abstracts a manipulation state in a single
   repository, that points at the first one but somehow knows
   what in-core objects are rewritten during its operation
   (e.g. history simplification rewrites parents list in in-core
   commit objects).

and a relatively low impact approach to transition to such a
scheme would be to use "the_index" libification as the model.
I.e. make the real API to take an explicit container as one of
their parameter, but define the default container to work on for
each level, and express the existing API in terms of the updated
API that works on the default container.


[Reference]

  228e94f93570b580da388069900c56b813c91953 (Move index-related
  variables into a structure.)

  4aab5b46f44a7ba860e07a52be506b7b57b2bd5f (Make read-cache.c
  "the_index" free.)

^ permalink raw reply

* CRLF problems with Git on Win32
From: Peter Karlsson @ 2008-01-07  9:16 UTC (permalink / raw)
  To: Git Mailing List

Hi!

When I clone git://git.debian.org/git/turqstat/turqstat.git using the
msys-Windows version of git (1.5.4-rc2), some but not all the files get
autoconverted to CRLF. Is it possible to set properties for the files
that are text, to make sure they are converted properly?

-- 
\\// Peter - http://www.softwolves.pp.se/

^ permalink raw reply

* Re: [PATCH] Allow git-mergetool to handle paths with a leading space
From: Junio C Hamano @ 2008-01-07  9:09 UTC (permalink / raw)
  To: Rogan Dawes, Theodore Ts'o; +Cc: Git Mailing List
In-Reply-To: <4781D6C2.9060305@dawes.za.net>

Rogan Dawes <rogan@dawes.za.net> writes:

> Yes, you are right. Maybe setting IFS to the empty string is better?

Yes.  POSIX XCU "2.6.5 Field Splitting" is quite clear about
this.  Empty IFS tells read not to split the fields, and such an
IFS does not have IFS white space in it so the SP at the
beginning of the input will not be stripped.

My limited test indicates that bash, dash and ksh do behave as
specified, so I think it is a reasonably safe thing to do.
Although I usually would say "I do not care about Solaris
default /bin/sh", I know even that shell at least gets this
right.

I think the patch is Ok as long as the user does not care any
character outside the portable filename character set (POSIX XBD
3.276) other than SP.  Because the rest of the mergetool is
written in such a way that it does not handle many characters
outside the portable filename character set well anyway, I think
the filename limitation that still remains after your patch may
be acceptable.

I did not however apply your patch to my tree tonight, as Ted as
the original and the primary author of the script may have
better ideas, and/or future directions for the patch.  He can
simply just Ack your patch if he chooses to.

I'd however write that overly long pipeline indented a bit more
sanely, like this, though:

	git ls-files -u |
        sed -e 's/^[^	]*	//' |
        sort -u |
        while IFS="" read i
	do
        	printf "\n"
                merge_file "$i" </dev/tty >/dev/tty
                ...

In the longer term, I'd probably suggest redoing the entire
command in a NUL safe scripting language (or even C, especially
if pressed by mingw or msys folks) to eliminate the issue
altogether, though.  But that would definitely be a post 1.5.4
item.


[Reference]

http://www.opengroup.org/onlinepubs/000095399/toc.htm

^ permalink raw reply

* Re: [PATCH] Make commit, cherry-pick and revert more silent.
From: Gabriel @ 2008-01-07  8:55 UTC (permalink / raw)
  To: git
In-Reply-To: <7vir2636tq.fsf@gitster.siamese.dyndns.org>

Le Sun, 06 Jan 2008 14:52:33 -0800, Junio C Hamano a écrit :

> So a more convincing presentation would be:
> ...
Will split.

> After I wrote all that, I realized that the patch is not acceptable as
> is.
> 
> Why?
> 
> This makes a successful cherry-pick way too silent.  With your patch, we
> will see:
> 
>  * "Auto-merged ..." messages that shows what paths are affected
>    by the cherry-pick/revert (which I do not think we would want to
>    squelch),
> 
>  * "Finished one cherry-pick."
> 
> But we will lose the "Created commit ...: <msg>" and "<num> files
> changed..."  summary, neither of which we would want to lose.

I'll have a look.
This seems to require refactoring the interface between cherry-pick/
revert and commit.

> Also sign your patch (see Documentation/SubmittingPatches), please, when
> you try the second round.
> 
> Thanks.

Thanks, I appreciate the review.

^ permalink raw reply

* Re: [PATCH 2/5] First step, making setup (somewhat) reentrant
From: Johannes Schindelin @ 2008-01-07  8:50 UTC (permalink / raw)
  To: Christian Thaeter; +Cc: git, gitster
In-Reply-To: <1199684855-14246-2-git-send-email-ct@pipapo.org>

Hi,

[I assume that you mean this series post-1.5.4]

On Mon, 7 Jan 2008, Christian Thaeter wrote:

> diff --git a/environment.c b/environment.c
> index 18a1c4e..492d87c 100644
> --- a/environment.c
> +++ b/environment.c
> @@ -38,31 +38,48 @@ int auto_crlf = 0;	/* 1: both ways, -1: only when adding git objects */
>  unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
>  
>  /* This is set by setup_git_dir_gently() and/or git_default_config() */
> -char *git_work_tree_cfg;
> -static const char *work_tree;
> +char *git_work_tree_cfg = NULL;
> +static char *work_tree = NULL;
> +static int work_tree_initialized = 0;

Global variables do not need initialisation, if all what you do is set 
them to NULL.  Therefore, most of this hunk is not necessary, and only 
distracts from what is really relevant, "work_tree_initialized = 0".

>  static void setup_git_env(void)
>  {
>  	git_dir = getenv(GIT_DIR_ENVIRONMENT);
>  	if (!git_dir)
>  		git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
> +	if (git_object_dir)
> +		free(git_object_dir);

Logically, this belongs into a "cleanup_git_env()" function, no?

>  	git_object_dir = getenv(DB_ENVIRONMENT);
> -	if (!git_object_dir) {
> +	if (git_object_dir) {
> +		git_object_dir = xstrdup(git_object_dir);
> +	}

Are you sure that you want to keep the object directory, even if you want 
to initialise to a new repository?

Which brings me to a more fundamental question: what do you need reentrant 
setup_directory() for?  If it is just to allow multiple calls to that 
function for the _same_ repository, I say clean up your code.

Ciao,
Dscho

^ permalink raw reply

* Re: What's in git.git (stable frozen)
From: Junio C Hamano @ 2008-01-07  8:27 UTC (permalink / raw)
  To: git
  Cc: Paul Mackerras, Eric Wong, J. Bruce Fields, Shawn O. Pearce,
	Theodore Ts'o
In-Reply-To: <7v63y8ble8.fsf@gitster.siamese.dyndns.org>

I've applied all the leftover bits I mentioned in yesterday's
message and 'master' tonight is pretty much where I want it to
be in 1.5.4-rc3 (and in 1.5.4 final).

Subsystem people (except Shawn, whose git-gui 0.9.1 is already
in) are requested to tell me to pull from them, if they have
accumulated changes that should be in the final release.  I am
hoping that I can tag -rc3 in a few days (say by the end of my
Wednesday).

^ permalink raw reply

* Re: [PATCH] parse_commit_buffer: don't parse invalid commits
From: Martin Koegler @ 2008-01-07  7:40 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vbq7y4ns6.fsf@gitster.siamese.dyndns.org>

On Sun, Jan 06, 2008 at 02:00:57PM -0800, Junio C Hamano wrote:
> Martin Koegler <mkoegler@auto.tuwien.ac.at> writes:
> > diff --git a/commit.c b/commit.c
> > index f074811..ffa0894 100644
> > --- a/commit.c
> > +++ b/commit.c
> > @@ -48,19 +48,33 @@ struct commit *lookup_commit(const unsigned char *sha1)
> >  	return check_commit(obj, sha1, 0);
> >  }
> >  
> > -static unsigned long parse_commit_date(const char *buf)
> > +static unsigned long parse_commit_date(const char *buf, const char* tail)
> 
> Should be "const char *tail" in our codebase.

Will fix.

> >  {
> >  	unsigned long date;
> > +	char datebuf[20];
> > +	unsigned long len;
> >  
> > +	if (buf + 6 >= tail)
> > +		return 0;
> >  	if (memcmp(buf, "author", 6))
> >  		return 0;
> 
> Even though buf, which is a result from read_sha1_file(), is
> always terminated with an extra NUL (outside its object size),
> if a bogus commit object ends with "author" (and without the
> author information) this part will pass, and ...

fsck_commit (builtin-fsck.c) does quite redundant checks (except that
it checks for author too). Should I make parse_commit fail, if there
is no author and commiter line? This way, we could remove 
|        if (memcmp(buffer, "tree ", 5))
|                return objerror(&commit->object, "invalid format - expected 'tree' line");
|        if (get_sha1_hex(buffer+5, tree_sha1) || buffer[45] != '\n')
|                return objerror(&commit->object, "invalid 'tree' line format - bad sha1");
|        buffer += 46;
|        while (!memcmp(buffer, "parent ", 7)) {
|                if (get_sha1_hex(buffer+7, sha1) || buffer[47] != '\n')
|                        return objerror(&commit->object, "invalid 'parent' line format - bad sha1");
|                buffer += 48;
|        }
|        if (memcmp(buffer, "author ", 7))
|                return objerror(&commit->object, "invalid format - expected 'author' line");
from fsck_commit.


> > -	while (*buf++ != '\n')
> > +	while (buf < tail && *buf++ != '\n')
> >  		/* nada */;
> > +	if (buf + 9 >= tail)
> > +		return 0;
> 
> ... you catch that here.  That seems like a good change.
> 
> >  	if (memcmp(buf, "committer", 9))
> >  		return 0;
> > -	while (*buf++ != '>')
> > +	while (buf < tail && *buf++ != '>')
> >  		/* nada */;
> > -	date = strtoul(buf, NULL, 10);
> > +	if (buf >= tail)
> > +		return 0;
> 
> Likewise here.
> 
> > +	len = tail - buf;
> > +	if (len > sizeof(datebuf) - 1)
> > +	  len = sizeof(datebuf) - 1;
> 
> Broken indentation.

Will fix.

> > +	memcpy(datebuf, buf, len);
> > +	datebuf[len] = 0;
> > +	date = strtoul(datebuf, NULL, 10);
> 
> However, as long as buf at this point hasn't go beyond tail,
> which you already checked, I think we can rely on strtoul()
> stopping at the NUL at the end of buffer (that is one beyond
> tail), without this extra memcpy().  Am I mistaken?

No.

parse_commit_buffer is only called from parse_commit (safe, as it uses
a buffer by read_sha1_file) and parse_object_buffer (safe, as it is
called by parse_object (safe as it uses a buffer by read_sha1_file)
and get_obj (in builtin-for-each-ref.c, safe as it uses a buffer by
read_sha1_file)).

> > @@ -275,7 +289,7 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
> >  			n_refs++;
> >  		}
> >  	}
> > -	item->date = parse_commit_date(bufptr);
> > +	item->date = parse_commit_date(bufptr, tail);
> >  
> >  	if (track_object_refs) {
> >  		unsigned i = 0;
> > -- 
> > 1.4.4.4
> 
> When already somewhat deep in the rc cycle, looking at a patch
> from somebody who uses 1.4.4.4 makes me look at the patch a bit
> more carefully than usual ;-)

stg is much simpler to use for such patches. My distribution [Linus
already called it insafe for it's git version] ships stg 0.11, which
is sufficient for this. I simply use stg with the shipped git 1.4.4.4
to avoid any compatibiltiy problems.

mfg Martin Kögler
PS:
The function of get_obj in builtin-for-each-ref.c looks quite similar to
parse_object.

^ permalink raw reply

* [PATCH] Allow git-mergetool to handle paths with a leading space
From: Rogan Dawes @ 2008-01-07  7:37 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List
In-Reply-To: <7v3atb5g5o.fsf@gitster.siamese.dyndns.org>

[-- Attachment #1: Type: text/plain, Size: 2190 bytes --]

Signed-off-by: Rogan Dawes <rogan@dawes.za.net>
---
Junio C Hamano wrote:
> Rogan Dawes <rogan@dawes.za.net> writes:
> 
>>>> I am working on a project which has the root directory constructed
>>>> with a leading space. i.e. ./ dir/. "read" skips the leading space
>>>> char, and ends up with an incorrect filename, which can then not be
>>>> found. Setting IFS=\n solves this problem.
>>> Does the project have a file that has letter 'n' (en) in its name?
>>> Have you tested your patch while having a conflict in that file?
>> Yes, it works correctly.
> 
> I am curious and puzzled...
> 
>         $ echo 'ann1' | (IFS=\n read i; echo "<$i>")
>         <ann1>
>         $ echo 'ann1' | (IFS=\n read i j; echo "<$i>")
> 	<a>
>         $ echo 'n1' | (IFS=\n read i j; echo "<$i>")
> 	<>
> 
> Ok, "\n" is a funny way to say IFS does not matter as long as it
> is set to a non whitespace letter.
> 
> It is VERY misleading as it looks as if the issue is fixed by
> setting IFS to a single LF alone (excluding SP and HT from the
> usual set), but that is not the patch is doing.  It is setting
> it to a single 'n'.

Yes, you are right. Maybe setting IFS to the empty string is better?

$ printf " ann 1\n ann 2\n" | while IFS="" read i j k ; do echo "<$i> 
<$j> <$k>"; done
< ann 1> <> <>
< ann 2> <> <>
$

Admittedly, there are still problems with my version, as you say, 
backslashes and newlines will not be handled correctly. My Perl-fu is 
weak, however, and my revised solution (IFS="") works for me :-)

Rogan

P.S. Quoting "$files" stops the spaces from being eaten in the preceding 
echo line.

diff --git a/git-mergetool.sh b/git-mergetool.sh
index 2f31fa2..facfbc8 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -393,8 +393,8 @@ if test $# -eq 0 ; then
                 echo "No files need merging"
                 exit 0
         fi
-       echo Merging the files: $files
-       git ls-files -u | sed -e 's/^[^ ]*      //' | sort -u | while read i
+       echo Merging the files: "$files"
+       git ls-files -u | sed -e 's/^[^ ]*      //' | sort -u | while 
IFS="" read i
         do
                 printf "\n"
                 merge_file "$i" < /dev/tty > /dev/tty

[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 484 bytes --]

diff --git a/git-mergetool.sh b/git-mergetool.sh
index 2f31fa2..facfbc8 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -393,8 +393,8 @@ if test $# -eq 0 ; then
 		echo "No files need merging"
 		exit 0
 	fi
-	echo Merging the files: $files
-	git ls-files -u | sed -e 's/^[^	]*	//' | sort -u | while read i
+	echo Merging the files: "$files"
+	git ls-files -u | sed -e 's/^[^	]*	//' | sort -u | while IFS="" read i
 	do
 		printf "\n"
 		merge_file "$i" < /dev/tty > /dev/tty

^ permalink raw reply related

* git-svn doesn't like !! in the url
From: Michael J. Cohen @ 2008-01-07  7:10 UTC (permalink / raw)
  To: Git Mailing List

I think it needs to urlencode the items before it passes it back to  
the server.

W: Ignoring error from SVN, path probably does not exist: (175007):  
HTTP Path Not Found: REPORT request failed on '/wowace/!svn/bc/100/ 
trunk/!!!LeaveMeAloneLibraries': '/wowace/!svn/bc/100/trunk/!!! 
LeaveMeAloneLibraries' path not found

works fine with svn co.

-mjc

^ permalink raw reply

* [PATCH 5/5] Make setup_git_directory reentrant
From: Christian Thaeter @ 2008-01-07  5:47 UTC (permalink / raw)
  To: git; +Cc: gitster, Christian Thaeter
In-Reply-To: <1199684855-14246-4-git-send-email-ct@pipapo.org>

Reentrant means here one can call it serveral times for different repos.

The functionality introduced here (based on earlier commits) is sufficent
to call setup_git_directory() for inspecting the refs like generating a
repository list for a browser. For full reset some more works needs
to be done later.

Signed-off-by: Christian Thaeter <ct@pipapo.org>
---
 setup.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/setup.c b/setup.c
index adede16..770dc41 100644
--- a/setup.c
+++ b/setup.c
@@ -200,6 +200,8 @@ static const char *set_work_tree(const char *dir)
 
 	if (!getcwd(buffer, sizeof(buffer)))
 		die ("Could not get the current working directory");
+	if (git_work_tree_cfg)
+		free (git_work_tree_cfg);
 	git_work_tree_cfg = xstrdup(buffer);
 	inside_work_tree = 1;
 
@@ -329,6 +331,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
 	inside_git_dir = 0;
 	if (!work_tree_env)
 		inside_work_tree = 1;
+	if (git_work_tree_cfg)
+		free (git_work_tree_cfg);
 	git_work_tree_cfg = xstrndup(cwd, offset);
 	if (check_repository_format_gently(nongit_ok))
 		return NULL;
@@ -387,7 +391,14 @@ int check_repository_format(void)
 
 const char *setup_git_directory(void)
 {
-	const char *retval = setup_git_directory_gently(NULL);
+	const char *retval;
+
+	inside_git_dir = -1;
+	inside_work_tree = -1;
+	git_invalidate_cached_refs();
+	reset_packed_git();
+	reset_git_work_tree();
+	retval = setup_git_directory_gently(NULL);
 
 	/* If the work tree is not the default one, recompute prefix */
 	if (inside_work_tree < 0) {
-- 
1.5.3.7

^ permalink raw reply related

* [PATCH 4/5] Export some more functions to enable resetting the git state
From: Christian Thaeter @ 2008-01-07  5:47 UTC (permalink / raw)
  To: git; +Cc: gitster, Christian Thaeter
In-Reply-To: <1199684855-14246-3-git-send-email-ct@pipapo.org>

This declares the functions added by the former 2 commits as 'extern'.

Further invalidate_cached_refs() got renamed to
git_invalidate_cached_refs() and is exported too.

Signed-off-by: Christian Thaeter <ct@pipapo.org>
---
 cache.h |    3 +++
 refs.c  |    6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/cache.h b/cache.h
index 39331c2..4352d08 100644
--- a/cache.h
+++ b/cache.h
@@ -224,7 +224,9 @@ extern char *get_refs_directory(void);
 extern char *get_index_file(void);
 extern char *get_graft_file(void);
 extern int set_git_dir(const char *path);
+extern void reset_git_work_tree(void);
 extern const char *get_git_work_tree(void);
+extern void git_invalidate_cached_refs(void);
 
 #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
 
@@ -553,6 +555,7 @@ extern struct packed_git *parse_pack_index_file(const unsigned char *sha1,
 
 extern void prepare_packed_git(void);
 extern void reprepare_packed_git(void);
+extern void reset_packed_git(void);
 extern void install_packed_git(struct packed_git *pack);
 
 extern struct packed_git *find_sha1_pack(const unsigned char *sha1,
diff --git a/refs.c b/refs.c
index 58f6d17..900cc5d 100644
--- a/refs.c
+++ b/refs.c
@@ -167,7 +167,7 @@ static void free_ref_list(struct ref_list *list)
 	}
 }
 
-static void invalidate_cached_refs(void)
+void git_invalidate_cached_refs(void)
 {
 	struct cached_refs *ca = &cached_refs;
 
@@ -898,7 +898,7 @@ int delete_ref(const char *refname, const unsigned char *sha1)
 	if (err && errno != ENOENT)
 		fprintf(stderr, "warning: unlink(%s) failed: %s",
 			git_path("logs/%s", lock->ref_name), strerror(errno));
-	invalidate_cached_refs();
+	git_invalidate_cached_refs();
 	unlock_ref(lock);
 	return ret;
 }
@@ -1137,7 +1137,7 @@ int write_ref_sha1(struct ref_lock *lock,
 		unlock_ref(lock);
 		return -1;
 	}
-	invalidate_cached_refs();
+	git_invalidate_cached_refs();
 	if (log_ref_write(lock->ref_name, lock->old_sha1, sha1, logmsg) < 0 ||
 	    (strcmp(lock->ref_name, lock->orig_ref_name) &&
 	     log_ref_write(lock->orig_ref_name, lock->old_sha1, sha1, logmsg) < 0)) {
-- 
1.5.3.7

^ permalink raw reply related

* [PATCH 3/5] provide a reset_packed_git() function
From: Christian Thaeter @ 2008-01-07  5:47 UTC (permalink / raw)
  To: git; +Cc: gitster, Christian Thaeter
In-Reply-To: <1199684855-14246-2-git-send-email-ct@pipapo.org>

this frees packs and pack-windows allocated by former operations and
reset some variables to let prepare_packed_git() reinit the packs on the
next call.

find_pack_entry() uses a static pointer to cache the last_found pack
which will be reseted too.

Signed-off-by: Christian Thaeter <ct@pipapo.org>
---
 sha1_file.c |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/sha1_file.c b/sha1_file.c
index 6583797..139d5a2 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -418,6 +418,7 @@ static unsigned int pack_open_windows;
 static size_t peak_pack_mapped;
 static size_t pack_mapped;
 struct packed_git *packed_git;
+static struct packed_git *last_found_packed_git = (void *)1;
 
 void pack_report(void)
 {
@@ -969,6 +970,22 @@ void reprepare_packed_git(void)
 	prepare_packed_git();
 }
 
+void reset_packed_git(void)
+{
+	/* certainly not the best way to release all windows, but should work for now */
+	while (unuse_one_window(NULL, -1))
+		; /* nothing */
+
+	while (packed_git) {
+		struct packed_git* p = packed_git;
+		packed_git = packed_git->next;
+		free(p);
+	}
+
+	last_found_packed_git = (void *)1;
+	prepare_packed_git_run_once = 0;
+}
+
 int check_sha1_signature(const unsigned char *sha1, void *map, unsigned long size, const char *type)
 {
 	unsigned char real_sha1[20];
@@ -1705,14 +1722,13 @@ int matches_pack_name(struct packed_git *p, const char *name)
 
 static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, const char **ignore_packed)
 {
-	static struct packed_git *last_found = (void *)1;
 	struct packed_git *p;
 	off_t offset;
 
 	prepare_packed_git();
 	if (!packed_git)
 		return 0;
-	p = (last_found == (void *)1) ? packed_git : last_found;
+	p = (last_found_packed_git == (void *)1) ? packed_git : last_found_packed_git;
 
 	do {
 		if (ignore_packed) {
@@ -1741,16 +1757,16 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, cons
 			e->offset = offset;
 			e->p = p;
 			hashcpy(e->sha1, sha1);
-			last_found = p;
+			last_found_packed_git = p;
 			return 1;
 		}
 
 		next:
-		if (p == last_found)
+		if (p == last_found_packed_git)
 			p = packed_git;
 		else
 			p = p->next;
-		if (p == last_found)
+		if (p == last_found_packed_git)
 			p = p->next;
 	} while (p);
 	return 0;
-- 
1.5.3.7

^ permalink raw reply related

* [PATCH 1/5] Add streq() to compat-util
From: Christian Thaeter @ 2008-01-07  5:47 UTC (permalink / raw)
  To: git; +Cc: gitster, Christian Thaeter

streq() compares strings for equality, it differs from strcmp() in that
it can handle NULL pointers and that it short-circruits if a==b.

returns 1 if the strings are equal (or both are NULL) and 0 when not.

Signed-off-by: Christian Thaeter <ct@pipapo.org>
---
Here comes a series of patches to reinit libgit with subsequent
setup_git_directory() calls. So far, this only suffices for simple
tasks like scanning a list of repositories (buiding the start page
of a repository browser). There are still a lot of things not
fixed yet (grep for '\tstatic', object & graft cache etc.).
Nevertheless, it works for me so far.

 git-compat-util.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index b6ef544..759e94c 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -424,4 +424,13 @@ static inline int strtol_i(char const *s, int base, int *result)
 	return 0;
 }
 
+static inline int streq(const char *a, const char* b)
+{
+	if (a == b)
+		return 1;
+	if (a && b)
+		return !strcmp(a, b);
+	return 0;
+}
+
 #endif
-- 
1.5.3.7

^ permalink raw reply related

* [PATCH 2/5] First step, making setup (somewhat) reentrant
From: Christian Thaeter @ 2008-01-07  5:47 UTC (permalink / raw)
  To: git; +Cc: gitster, Christian Thaeter
In-Reply-To: <1199684855-14246-1-git-send-email-ct@pipapo.org>

setup_git_env() just initialized some static data and then let it
leak. For reentrant operation, as in using a git process to access
serveral repositories in order, this data has to be freed and properly
reinitialized.

get_git_work_tree() used a once only initialization flag, we now provide
a reset_git_work_tree() to free allocated resources and let it initialize
itself on the next call.

create_default_files() in init-db needed to be fixed to compare strings
properly.

Signed-off-by: Christian Thaeter <ct@pipapo.org>
---
 builtin-init-db.c |    4 ++--
 environment.c     |   43 ++++++++++++++++++++++++++++++++++---------
 2 files changed, 36 insertions(+), 11 deletions(-)

diff --git a/builtin-init-db.c b/builtin-init-db.c
index e1393b8..d5a5dd9 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -270,8 +270,8 @@ static int create_default_files(const char *git_dir, const char *template_path)
 		git_config_set("core.bare", "false");
 		/* allow template config file to override the default */
 		if (log_all_ref_updates == -1)
-		    git_config_set("core.logallrefupdates", "true");
-		if (work_tree != git_work_tree_cfg)
+			git_config_set("core.logallrefupdates", "true");
+		if (!streq(work_tree, git_work_tree_cfg))
 			git_config_set("core.worktree", work_tree);
 	}
 
diff --git a/environment.c b/environment.c
index 18a1c4e..492d87c 100644
--- a/environment.c
+++ b/environment.c
@@ -38,31 +38,48 @@ int auto_crlf = 0;	/* 1: both ways, -1: only when adding git objects */
 unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
 
 /* This is set by setup_git_dir_gently() and/or git_default_config() */
-char *git_work_tree_cfg;
-static const char *work_tree;
+char *git_work_tree_cfg = NULL;
+static char *work_tree = NULL;
+static int work_tree_initialized = 0;
 
 static const char *git_dir;
-static char *git_object_dir, *git_index_file, *git_refs_dir, *git_graft_file;
+static char *git_object_dir = NULL, *git_index_file = NULL, *git_refs_dir = NULL, *git_graft_file = NULL;
 
 static void setup_git_env(void)
 {
 	git_dir = getenv(GIT_DIR_ENVIRONMENT);
 	if (!git_dir)
 		git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
+	if (git_object_dir)
+		free(git_object_dir);
 	git_object_dir = getenv(DB_ENVIRONMENT);
-	if (!git_object_dir) {
+	if (git_object_dir) {
+		git_object_dir = xstrdup(git_object_dir);
+	}
+	else {
 		git_object_dir = xmalloc(strlen(git_dir) + 9);
 		sprintf(git_object_dir, "%s/objects", git_dir);
 	}
+	if (git_refs_dir)
+		free(git_refs_dir);
 	git_refs_dir = xmalloc(strlen(git_dir) + 6);
 	sprintf(git_refs_dir, "%s/refs", git_dir);
+	if (git_index_file)
+		free(git_index_file);
 	git_index_file = getenv(INDEX_ENVIRONMENT);
-	if (!git_index_file) {
+	if (git_index_file) {
+		git_index_file = xstrdup(git_index_file);
+	}
+	else {
 		git_index_file = xmalloc(strlen(git_dir) + 7);
 		sprintf(git_index_file, "%s/index", git_dir);
 	}
+	if (git_graft_file)
+		free (git_graft_file);
 	git_graft_file = getenv(GRAFT_ENVIRONMENT);
-	if (!git_graft_file)
+	if (git_graft_file)
+		git_graft_file = xstrdup(git_graft_file);
+	else
 		git_graft_file = xstrdup(git_path("info/grafts"));
 }
 
@@ -79,10 +96,16 @@ const char *get_git_dir(void)
 	return git_dir;
 }
 
+void reset_git_work_tree(void)
+{
+	work_tree_initialized = 0;
+	if (work_tree)
+		free (work_tree);
+}
+
 const char *get_git_work_tree(void)
 {
-	static int initialized = 0;
-	if (!initialized) {
+	if (!work_tree_initialized) {
 		work_tree = getenv(GIT_WORK_TREE_ENVIRONMENT);
 		/* core.bare = true overrides implicit and config work tree */
 		if (!work_tree && is_bare_repository_cfg < 1) {
@@ -90,11 +113,13 @@ const char *get_git_work_tree(void)
 			/* make_absolute_path also normalizes the path */
 			if (work_tree && !is_absolute_path(work_tree))
 				work_tree = xstrdup(make_absolute_path(git_path(work_tree)));
+			else if (work_tree)
+				work_tree = xstrdup(work_tree);
 		} else if (work_tree)
 			work_tree = xstrdup(make_absolute_path(work_tree));
-		initialized = 1;
 		if (work_tree)
 			is_bare_repository_cfg = 0;
+		work_tree_initialized = 1;
 	}
 	return work_tree;
 }
-- 
1.5.3.7

^ permalink raw reply related

* Re: Problem with git ls-files
From: Imran M Yousuf @ 2008-01-07  5:42 UTC (permalink / raw)
  To: git
In-Reply-To: <7bfdc29a0801062048w1350fb6etc6bd94c63e42d7dd@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3400 bytes --]

Hi All,

I though I should also provide the steps to recreate the scenario.
Please create a repo using the sample-repo.txt file. Now you can clone
the test-repo/super-project using the attached git-clone script with
the command -

git-clone -w <path-to>/test-repo/super-project

If the attached git-submodule is used you will be able to see the
output of the git-ls-files --stage.

I am eagerly waiting for your help; please HELP.

Best regards & Thank you,

Imran

On Jan 7, 2008 10:48 AM, Imran M Yousuf <imyousuf@gmail.com> wrote:
> For output of git-ls-files is
>
> 100644 c462997b94c371248bf17895ee18e7fbea5bce9b 0 .gitmodules
> 160000 091158296a8f57322f70f3c17e5fcb66687a0970 0 a
> 160000 6397239aeb662ba96f61b59ccc0a0d0812f48435 0 b
> 160000 c9f0a7dedcb4a9daf5a68c37109577d7d177e10b 0 c
> 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 main.txt
>
> Sorry for the mistake earlier.
>
> The pastes are also available here.
> http://git.pastebin.com/f632762aa
>
> Please help.
>
> Best regards & thank you,
>
> Imran
>
>
> On Jan 7, 2008 10:38 AM, Imran M Yousuf <imyousuf@gmail.com> wrote:
> > Hi all,
> >
> > I am facing a strange problem with git ls-files in git-submodule. When I do -
> > echo in modules init with "$@" - `git-ls-files --stage` - `git
> > ls-files --stage -- "$@" | grep -e '^160000 '` - `pwd`
> > The output is =
> >
> > in modules init with d - 100644
> > c462997b94c371248bf17895ee18e7fbea5bce9b 0 .gitmodules 160000
> > 091158296a8f57322f70f3c17e5fcb66687a0970 0 a 160000
> > 6397239aeb662ba96f61b59ccc0a0d0812f48435 0 b 160000
> > c9f0a7dedcb4a9daf5a68c37109577d7d177e10b 0 c 100644
> > e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 main.txt - -
> > /home/imyousuf/projects/git-projs/test/super-project/a
> >
> > If we format the above output of git list-files --stage we can see the following
> >
> > 100644 c462997b94c371248bf17895ee18e7fbea5bce9b 0 .gitmodules
> > 160000 091158296a8f57322f70f3c17e5fcb66687a0970 0 a
> > 160000 6397239aeb662ba96f61b59ccc0a0d0812f48435 0 b
> > 160000 c9f0a7dedcb4a9daf5a68c37109577d7d177e10b 0 c
> > 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 main.txt
> >
> > In the output please note the path
> > /home/imyousuf/projects/git-projs/test/super-project/a
> >
> > Now I am providing the output of -
> > ls -al /home/imyousuf/projects/git-projs/test/super-project/a
> >
> >  drwxr-xr-x 4 imyousuf imyousuf 4096 2008-01-07 10:22 .
> >  drwxr-xr-x 6 imyousuf imyousuf 4096 2008-01-07 10:22 ..
> >  -rw-r--r-- 1 imyousuf imyousuf  130 2008-01-07 10:22 a.txt
> >  drwxr-xr-x 2 imyousuf imyousuf 4096 2008-01-07 10:22 d
> >  drwxr-xr-x 8 imyousuf imyousuf 4096 2008-01-07 10:22 .git
> >  -rw-r--r-- 1 imyousuf imyousuf   95 2008-01-07 10:22 .gitmodules
> >
> >
> > Now this is getting really confusing for me, because I get the strange
> > output when I call the git submodule from shell script but after the
> > shell script is executed if I do the same command copy and paste in
> > gnome-terminal it works fine.
> >
> > Can someone please tell me what I am doing wrong?
> >
> > Thank you,
> >
> > Imran
> >
>
>
>
> --
> Imran M Yousuf
> Entrepreneur & Software Engineer
> Smart IT Engineering
> Dhaka, Bangladesh
> Email: imran@smartitengineering.com
> Mobile: +880-1711402557
>



-- 
Imran M Yousuf
Entrepreneur & Software Engineer
Smart IT Engineering
Dhaka, Bangladesh
Email: imran@smartitengineering.com
Mobile: +880-1711402557

[-- Attachment #2: sample-repo.txt --]
[-- Type: text/plain, Size: 644 bytes --]

mkdir test-repo
cd test-repo/
mkdir submodules
mkdir submodules/a 
mkdir submodules/b
cd submodules/a/
touch a.txt; echo sample text for a.txt >> ./a.txt; git-init; git-add a.txt; git-commit -a -m "First commit on a"
cd ../b/
touch b.txt; echo sample text for b.txt >> ./b.txt; git-init; git-add b.txt; git-commit -a -m "First commit on b"
cd ../a/
git-submodule add ../b/; git-commit -a -m "committing with submodule b"
cd ../../
mkdir super-project
cd super-project/
touch main.txt; echo sample text for main.txt >> ./main.txt; git-init; git-add main.txt; git-submodule add ../submodules/a; git-commit -a -m "First commit on super project";


[-- Attachment #3: git-clone --]
[-- Type: application/octet-stream, Size: 12630 bytes --]

#!/bin/sh
#
# Copyright (c) 2005, Linus Torvalds
# Copyright (c) 2005, Junio C Hamano
#
# Clone a repository into a different directory that does not yet exist.

# See git-sh-setup why.
unset CDPATH

die() {
	echo >&2 "$@"
	exit 1
}

usage() {
	die "Usage: $0 [--template=<template_directory>] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-w|--with-submodule] [-u <upload-pack>] [--origin <name>] [--depth <n>] [-n] <repo> [<dir>]"
}

get_repo_base() {
	(
		cd "`/bin/pwd`" &&
		cd "$1" || cd "$1.git" &&
		{
			cd .git
			pwd
		}
	) 2>/dev/null
}

if [ -n "$GIT_SSL_NO_VERIFY" -o \
	"`git config --bool http.sslVerify`" = false ]; then
    curl_extra_args="-k"
fi

http_fetch () {
	# $1 = Remote, $2 = Local
	curl -nsfL $curl_extra_args "$1" >"$2" ||
		case $? in
		126|127) exit ;;
		*)	 return $? ;;
		esac
}

clone_dumb_http () {
	# $1 - remote, $2 - local
	cd "$2" &&
	clone_tmp="$GIT_DIR/clone-tmp" &&
	mkdir -p "$clone_tmp" || exit 1
	if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \
		"`git config --bool http.noEPSV`" = true ]; then
		curl_extra_args="${curl_extra_args} --disable-epsv"
	fi
	http_fetch "$1/info/refs" "$clone_tmp/refs" ||
		die "Cannot get remote repository information.
Perhaps git-update-server-info needs to be run there?"
	test "z$quiet" = z && v=-v || v=
	while read sha1 refname
	do
		name=`expr "z$refname" : 'zrefs/\(.*\)'` &&
		case "$name" in
		*^*)	continue;;
		esac
		case "$bare,$name" in
		yes,* | ,heads/* | ,tags/*) ;;
		*)	continue ;;
		esac
		if test -n "$use_separate_remote" &&
		   branch_name=`expr "z$name" : 'zheads/\(.*\)'`
		then
			tname="remotes/$origin/$branch_name"
		else
			tname=$name
		fi
		git-http-fetch $v -a -w "$tname" "$sha1" "$1" || exit 1
	done <"$clone_tmp/refs"
	rm -fr "$clone_tmp"
	http_fetch "$1/HEAD" "$GIT_DIR/REMOTE_HEAD" ||
	rm -f "$GIT_DIR/REMOTE_HEAD"
	if test -f "$GIT_DIR/REMOTE_HEAD"; then
		head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"`
		case "$head_sha1" in
		'ref: refs/'*)
			;;
		*)
			git-http-fetch $v -a "$head_sha1" "$1" ||
			rm -f "$GIT_DIR/REMOTE_HEAD"
			;;
		esac
	fi
}

initializeSubModule() {
	if [ ! -d "$1"/.git ]; then
		git-submodule-test init "$1"; git-submodule-test update "$1"
	fi
}

initSubModules() {
	current_dir=`pwd`
	dir_path="$current_dir:$dir_path"
	initializeSubModule "$1"
        cd "$1"
	if [ -f .gitmodules ]; then
                for sub_mod_path in `grep "path =" .gitmodules | awk '{print $3}'`; do
			initSubModules "$sub_mod_path"
                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)}'`
}

quiet=
local=no
use_local_hardlink=yes
local_shared=no
unset template
no_checkout=
upload_pack=
bare=
reference=
origin=
origin_override=
use_separate_remote=t
depth=
no_progress=
local_explicitly_asked_for=
test -t 1 || no_progress=--no-progress
with_submodule=0
while
	case "$#,$1" in
	0,*) break ;;
	*,-n|*,--no|*,--no-|*,--no-c|*,--no-ch|*,--no-che|*,--no-chec|\
	*,--no-check|*,--no-checko|*,--no-checkou|*,--no-checkout)
	  no_checkout=yes ;;
	*,--na|*,--nak|*,--nake|*,--naked|\
	*,-b|*,--b|*,--ba|*,--bar|*,--bare) bare=yes ;;
	*,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local)
	  local_explicitly_asked_for=yes
	  use_local_hardlink=yes ;;
	*,--no-h|*,--no-ha|*,--no-har|*,--no-hard|*,--no-hardl|\
	*,--no-hardli|*,--no-hardlin|*,--no-hardlink|*,--no-hardlinks)
	  use_local_hardlink=no ;;
        *,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared)
          local_shared=yes; ;;
	1,--template) usage ;;
	*,--template)
		shift; template="--template=$1" ;;
	*,--template=*)
	  template="$1" ;;
	*,-q|*,--quiet) quiet=-q ;;
	*,--use-separate-remote) ;;
	*,--no-separate-remote)
		die "clones are always made with separate-remote layout" ;;
	1,--reference) usage ;;
	*,--reference)
		shift; reference="$1" ;;
	*,--reference=*)
		reference=`expr "z$1" : 'z--reference=\(.*\)'` ;;
	*,-o|*,--or|*,--ori|*,--orig|*,--origi|*,--origin)
		case "$2" in
		'')
		    usage ;;
		*/*)
		    die "'$2' is not suitable for an origin name"
		esac
		git check-ref-format "heads/$2" ||
		    die "'$2' is not suitable for a branch name"
		test -z "$origin_override" ||
		    die "Do not give more than one --origin options."
		origin_override=yes
		origin="$2"; shift
		;;
	1,-u|1,--upload-pack) usage ;;
	*,-u|*,--upload-pack)
		shift
		upload_pack="--upload-pack=$1" ;;
	*,--upload-pack=*)
		upload_pack=--upload-pack=$(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
	*,-w|*,--w|*,--wi|*,--wit|*,--with|*,--with-s|*,--with-su|*,--with-sub|*,--with-subm|*,--with-submo|*,--with-submod|*,--with-submodu|*,--with-submodul|*,--with-submodule) with_submodule=1 ;;
	1,--depth) usage;;
	*,--depth)
		shift
		depth="--depth=$1";;
	*,-*) usage ;;
	*) break ;;
	esac
do
	shift
done

repo="$1"
test -n "$repo" ||
    die 'you must specify a repository to clone.'

# --bare implies --no-checkout and --no-separate-remote
if test yes = "$bare"
then
	if test yes = "$origin_override"
	then
		die '--bare and --origin $origin options are incompatible.'
	fi
	no_checkout=yes
	use_separate_remote=
fi

if test -z "$origin"
then
	origin=origin
fi

# Turn the source into an absolute path if
# it is local
if base=$(get_repo_base "$repo"); then
	repo="$base"
	local=yes
fi

dir="$2"
# Try using "humanish" part of source repo if user didn't specify one
[ -z "$dir" ] && dir=$(echo "$repo" | sed -e 's|/$||' -e 's|:*/*\.git$||' -e 's|.*[/:]||g')
[ -e "$dir" ] && die "destination directory '$dir' already exists."
[ yes = "$bare" ] && unset GIT_WORK_TREE
[ -n "$GIT_WORK_TREE" ] && [ -e "$GIT_WORK_TREE" ] &&
die "working tree '$GIT_WORK_TREE' already exists."
D=
W=
cleanup() {
	err=$?
	test -z "$D" && rm -rf "$dir"
	test -z "$W" && test -n "$GIT_WORK_TREE" && rm -rf "$GIT_WORK_TREE"
	cd ..
	test -n "$D" && rm -rf "$D"
	test -n "$W" && rm -rf "$W"
	exit $err
}
trap cleanup 0
mkdir -p "$dir" && D=$(cd "$dir" && pwd) || usage
test -n "$GIT_WORK_TREE" && mkdir -p "$GIT_WORK_TREE" &&
W=$(cd "$GIT_WORK_TREE" && pwd) && export GIT_WORK_TREE="$W"
if test yes = "$bare" || test -n "$GIT_WORK_TREE"; then
	GIT_DIR="$D"
else
	GIT_DIR="$D/.git"
fi &&
export GIT_DIR &&
GIT_CONFIG="$GIT_DIR/config" git-init $quiet ${template+"$template"} || usage

if test -n "$bare"
then
	GIT_CONFIG="$GIT_DIR/config" git config core.bare true
fi

if test -n "$reference"
then
	ref_git=
	if test -d "$reference"
	then
		if test -d "$reference/.git/objects"
		then
			ref_git="$reference/.git"
		elif test -d "$reference/objects"
		then
			ref_git="$reference"
		fi
	fi
	if test -n "$ref_git"
	then
		ref_git=$(cd "$ref_git" && pwd)
		echo "$ref_git/objects" >"$GIT_DIR/objects/info/alternates"
		(
			GIT_DIR="$ref_git" git for-each-ref \
				--format='%(objectname) %(*objectname)'
		) |
		while read a b
		do
			test -z "$a" ||
			git update-ref "refs/reference-tmp/$a" "$a"
			test -z "$b" ||
			git update-ref "refs/reference-tmp/$b" "$b"
		done
	else
		die "reference repository '$reference' is not a local directory."
	fi
fi

rm -f "$GIT_DIR/CLONE_HEAD"

# We do local magic only when the user tells us to.
case "$local" in
yes)
	( cd "$repo/objects" ) ||
		die "cannot chdir to local '$repo/objects'."

	if test "$local_shared" = yes
	then
		mkdir -p "$GIT_DIR/objects/info"
		echo "$repo/objects" >>"$GIT_DIR/objects/info/alternates"
	else
		l= &&
		if test "$use_local_hardlink" = yes
		then
			# See if we can hardlink and drop "l" if not.
			sample_file=$(cd "$repo" && \
				      find objects -type f -print | sed -e 1q)
			# objects directory should not be empty because
			# we are cloning!
			test -f "$repo/$sample_file" || exit
			if ln "$repo/$sample_file" "$GIT_DIR/objects/sample" 2>/dev/null
			then
				rm -f "$GIT_DIR/objects/sample"
				l=l
			elif test -n "$local_explicitly_asked_for"
			then
				echo >&2 "Warning: -l asked but cannot hardlink to $repo"
			fi
		fi &&
		cd "$repo" &&
		find objects -depth -print | cpio -pumd$l "$GIT_DIR/" || exit 1
	fi
	git-ls-remote "$repo" >"$GIT_DIR/CLONE_HEAD" || exit 1
	;;
*)
	case "$repo" in
	rsync://*)
		case "$depth" in
		"") ;;
		*) die "shallow over rsync not supported" ;;
		esac
		rsync $quiet -av --ignore-existing  \
			--exclude info "$repo/objects/" "$GIT_DIR/objects/" ||
		exit
		# Look at objects/info/alternates for rsync -- http will
		# support it natively and git native ones will do it on the
		# remote end.  Not having that file is not a crime.
		rsync -q "$repo/objects/info/alternates" \
			"$GIT_DIR/TMP_ALT" 2>/dev/null ||
			rm -f "$GIT_DIR/TMP_ALT"
		if test -f "$GIT_DIR/TMP_ALT"
		then
		    ( cd "$D" &&
		      . git-parse-remote &&
		      resolve_alternates "$repo" <"$GIT_DIR/TMP_ALT" ) |
		    while read alt
		    do
			case "$alt" in 'bad alternate: '*) die "$alt";; esac
			case "$quiet" in
			'')	echo >&2 "Getting alternate: $alt" ;;
			esac
			rsync $quiet -av --ignore-existing  \
			    --exclude info "$alt" "$GIT_DIR/objects" || exit
		    done
		    rm -f "$GIT_DIR/TMP_ALT"
		fi
		git-ls-remote "$repo" >"$GIT_DIR/CLONE_HEAD" || exit 1
		;;
	https://*|http://*|ftp://*)
		case "$depth" in
		"") ;;
		*) die "shallow over http or ftp not supported" ;;
		esac
		if test -z ""
		then
			clone_dumb_http "$repo" "$D"
		else
			die "http transport not supported, rebuild Git with curl support"
		fi
		;;
	*)
		case "$upload_pack" in
		'') git-fetch-pack --all -k $quiet $depth $no_progress "$repo";;
		*) git-fetch-pack --all -k $quiet "$upload_pack" $depth $no_progress "$repo" ;;
		esac >"$GIT_DIR/CLONE_HEAD" ||
			die "fetch-pack from '$repo' failed."
		;;
	esac
	;;
esac
test -d "$GIT_DIR/refs/reference-tmp" && rm -fr "$GIT_DIR/refs/reference-tmp"

if test -f "$GIT_DIR/CLONE_HEAD"
then
	# Read git-fetch-pack -k output and store the remote branches.
	if [ -n "$use_separate_remote" ]
	then
		branch_top="remotes/$origin"
	else
		branch_top="heads"
	fi
	tag_top="tags"
	while read sha1 name
	do
		case "$name" in
		*'^{}')
			continue ;;
		HEAD)
			destname="REMOTE_HEAD" ;;
		refs/heads/*)
			destname="refs/$branch_top/${name#refs/heads/}" ;;
		refs/tags/*)
			destname="refs/$tag_top/${name#refs/tags/}" ;;
		*)
			continue ;;
		esac
		git update-ref -m "clone: from $repo" "$destname" "$sha1" ""
	done < "$GIT_DIR/CLONE_HEAD"
fi

if test -n "$W"; then
	cd "$W" || exit
else
	cd "$D" || exit
fi

if test -z "$bare" && test -f "$GIT_DIR/REMOTE_HEAD"
then
	# a non-bare repository is always in separate-remote layout
	remote_top="refs/remotes/$origin"
	head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"`
	case "$head_sha1" in
	'ref: refs/'*)
		# Uh-oh, the remote told us (http transport done against
		# new style repository with a symref HEAD).
		# Ideally we should skip the guesswork but for now
		# opt for minimum change.
		head_sha1=`expr "z$head_sha1" : 'zref: refs/heads/\(.*\)'`
		head_sha1=`cat "$GIT_DIR/$remote_top/$head_sha1"`
		;;
	esac

	# The name under $remote_top the remote HEAD seems to point at.
	head_points_at=$(
		(
			test -f "$GIT_DIR/$remote_top/master" && echo "master"
			cd "$GIT_DIR/$remote_top" &&
			find . -type f -print | sed -e 's/^\.\///'
		) | (
		done=f
		while read name
		do
			test t = $done && continue
			branch_tip=`cat "$GIT_DIR/$remote_top/$name"`
			if test "$head_sha1" = "$branch_tip"
			then
				echo "$name"
				done=t
			fi
		done
		)
	)

	# Upstream URL
	git config remote."$origin".url "$repo" &&

	# Set up the mappings to track the remote branches.
	git config remote."$origin".fetch \
		"+refs/heads/*:$remote_top/*" '^$' &&

	# Write out remote.$origin config, and update our "$head_points_at".
	case "$head_points_at" in
	?*)
		# Local default branch
		git symbolic-ref HEAD "refs/heads/$head_points_at" &&

		# Tracking branch for the primary branch at the remote.
		git update-ref HEAD "$head_sha1" &&

		rm -f "refs/remotes/$origin/HEAD"
		git symbolic-ref "refs/remotes/$origin/HEAD" \
			"refs/remotes/$origin/$head_points_at" &&

		git config branch."$head_points_at".remote "$origin" &&
		git config branch."$head_points_at".merge "refs/heads/$head_points_at"
		;;
	'')
		# Source had detached HEAD pointing nowhere
		git update-ref --no-deref HEAD "$head_sha1" &&
		rm -f "refs/remotes/$origin/HEAD"
		;;
	esac

	case "$no_checkout" in
	'')
		test "z$quiet" = z -a "z$no_progress" = z && v=-v || v=
		git read-tree -m -u $v HEAD HEAD
	esac
fi
rm -f "$GIT_DIR/CLONE_HEAD" "$GIT_DIR/REMOTE_HEAD"

if [ $with_submodule -eq 1  ]; then
	if [ -f .gitmodules ]; then
	        for mod_path in `grep "path =" .gitmodules | awk '{print $3}'`; do
                        initSubModules "$mod_path"
                done
	fi
fi

trap - 0

[-- Attachment #4: git-submodule --]
[-- Type: application/octet-stream, Size: 9090 bytes --]

#!/bin/sh
#
# git-submodules.sh: add, init, update or list git submodules
# or recurse any git command over the submodules recursively.
#
# Copyright (c) 2007 Lars Hjemli

USAGE='[[--quiet] [--cached] [add <repo> [-b branch]|status|init|update] [--] [<path>...]|[recurse [-v] command arguments ...]]'
. git-sh-setup
require_work_tree

add=
branch=
init=
update=
status=
quiet=
cached=

#
# print stuff on stdout unless -q was specified
#
say()
{
	if test -z "$quiet"
	then
		echo "$@"
	fi
}

# NEEDSWORK: identical function exists in get_repo_base in clone.sh
get_repo_base() {
	(
		cd "`/bin/pwd`" &&
		cd "$1" || cd "$1.git" &&
		{
			cd .git
			pwd
		}
	) 2>/dev/null
}

#
# Map submodule path to submodule name
#
# $1 = path
#
module_name()
{
	# Do we have "submodule.<something>.path = $1" defined in .gitmodules file?
	re=$(printf '%s' "$1" | sed -e 's/[].[^$\\*]/\\&/g')
	name=$( GIT_CONFIG=.gitmodules \
		git config --get-regexp '^submodule\..*\.path$' |
		sed -n -e 's|^submodule\.\(.*\)\.path '"$re"'$|\1|p' )
       test -z "$name" &&
       die "No submodule mapping found in .gitmodules for path '$path'"
       echo "$name"
}

#
# Clone a submodule
#
# Prior to calling, modules_update checks that a possibly existing
# path is not a git repository.
# Likewise, module_add checks that path does not exist at all,
# since it is the location of a new submodule.
#
module_clone()
{
	path=$1
	url=$2

	# If there already is a directory at the submodule path,
	# expect it to be empty (since that is the default checkout
	# action) and try to remove it.
	# Note: if $path is a symlink to a directory the test will
	# succeed but the rmdir will fail. We might want to fix this.
	if test -d "$path"
	then
		rmdir "$path" 2>/dev/null ||
		die "Directory '$path' exist, but is neither empty nor a git repository"
	fi

	test -e "$path" &&
	die "A file already exist at path '$path'"

	git-clone -n "$url" "$path" ||
	die "Clone of '$url' into submodule path '$path' failed"
}

#
# Add a new submodule to the working tree, .gitmodules and the index
#
# $@ = repo [path]
#
# optional branch is stored in global branch variable
#
module_add()
{
	repo=$1
	path=$2

	if test -z "$repo"; then
		usage
	fi

	# Turn the source into an absolute path if
	# it is local
	if base=$(get_repo_base "$repo"); then
		repo="$base"
	fi

	# Guess path from repo if not specified or strip trailing slashes
	if test -z "$path"; then
		path=$(echo "$repo" | sed -e 's|/*$||' -e 's|:*/*\.git$||' -e 's|.*[/:]||g')
	else
		path=$(echo "$path" | sed -e 's|/*$||')
	fi

	test -e "$path" &&
	die "'$path' already exists"

	git ls-files --error-unmatch "$path" > /dev/null 2>&1 &&
	die "'$path' already exists in the index"

	module_clone "$path" "$repo" || exit
	(unset GIT_DIR && cd "$path" && git checkout -q ${branch:+-b "$branch" "origin/$branch"}) ||
	die "Unable to checkout submodule '$path'"
	git add "$path" ||
	die "Failed to add submodule '$path'"

	GIT_CONFIG=.gitmodules git config submodule."$path".path "$path" &&
	GIT_CONFIG=.gitmodules git config submodule."$path".url "$repo" &&
	git add .gitmodules ||
	die "Failed to register submodule '$path'"
}

#
# Register submodules in .git/config
#
# $@ = requested paths (default to all)
#
modules_init()
{
	echo in modules init with "$@" - `git-ls-files --stage` - `git ls-files --stage -- "$@" | grep -e '^160000 '` - `pwd`
	git ls-files --stage -- "$@" | grep -e '^160000 ' |
	while read mode sha1 stage path
	do
		echo in while loop before parsing of registered names
		# Skip already registered paths
		name=$(module_name "$path") || exit
		echo passed skip place in init
		url=$(git config submodule."$name".url)
		test -z "$url" || continue

		url=$(GIT_CONFIG=.gitmodules git config submodule."$name".url)
		test -z "$url" &&
		die "No url found for submodule path '$path' in .gitmodules"

		git config submodule."$name".url "$url" ||
		die "Failed to register url for submodule path '$path'"

		say "Submodule '$name' ($url) registered for path '$path'"
	done
}

#
# Update each submodule path to correct revision, using clone and checkout as needed
#
# $@ = requested paths (default to all)
#
modules_update()
{
	git ls-files --stage -- "$@" | grep -e '^160000 ' |
	while read mode sha1 stage path
	do
		name=$(module_name "$path") || exit
		url=$(git config submodule."$name".url)
		if test -z "$url"
		then
			# Only mention uninitialized submodules when its
			# path have been specified
			test "$#" != "0" &&
			say "Submodule path '$path' not initialized"
			continue
		fi

		if ! test -d "$path"/.git
		then
			module_clone "$path" "$url" || exit
			subsha1=
		else
			subsha1=$(unset GIT_DIR && cd "$path" &&
				git rev-parse --verify HEAD) ||
			die "Unable to find current revision in submodule path '$path'"
		fi

		if test "$subsha1" != "$sha1"
		then
			(unset GIT_DIR && cd "$path" && git-fetch &&
				git-checkout -q "$sha1") ||
			die "Unable to checkout '$sha1' in submodule path '$path'"

			say "Submodule path '$path': checked out '$sha1'"
		fi
	done
}

set_name_rev () {
	revname=$( (
		unset GIT_DIR &&
		cd "$1" && {
			git describe "$2" 2>/dev/null ||
			git describe --tags "$2" 2>/dev/null ||
			git describe --contains --tags "$2"
		}
	) )
	test -z "$revname" || revname=" ($revname)"
}

#
# List all submodules, prefixed with:
#  - submodule not initialized
#  + different revision checked out
#
# If --cached was specified the revision in the index will be printed
# instead of the currently checked out revision.
#
# $@ = requested paths (default to all)
#
modules_list()
{
	git ls-files --stage -- "$@" | grep -e '^160000 ' |
	while read mode sha1 stage path
	do
		name=$(module_name "$path") || exit
		url=$(git config submodule."$name".url)
		if test -z "url" || ! test -d "$path"/.git
		then
			say "-$sha1 $path"
			continue;
		fi
		set_name_rev "$path" "$sha1"
		if git diff-files --quiet -- "$path"
		then
			say " $sha1 $path$revname"
		else
			if test -z "$cached"
			then
				sha1=$(unset GIT_DIR && cd "$path" && git rev-parse --verify HEAD)
				set_name_rev "$path" "$sha1"
			fi
			say "+$sha1 $path$revname"
		fi
	done
}

# Simply checks whether the submodule is initialized
# or not. If not initialized it does so.
initializeSubModule() {
	if [ ! -d "$1"/.git ]; then
		if [ $recurse_verbose -eq 1 ]; then
			echo Initializing and updating "$1"
		fi
		git-submodule init "$1"; git-submodule update "$1"
	fi
}

# This actually traverses the module; checks
# whether the module is initialized or not.
# if not initialized, then done so and then the
# intended command is evaluated. Then it
# recursively goes into it modules.
traverseModule() {
	current_dir=`pwd`
	dir_path="$current_dir:$dir_path"
	initializeSubModule "$1"
        cd "$1"
	if [ $recurse_verbose -eq 1 ]; then
		echo Working in mod $1 @ `pwd` with $2
	fi
        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)}'`
}

# Propagates or recurses over all the submodules at any 
# depth with any git command, e.g. git-clone, git-status,
# git-commit etc., with the arguments supplied exactly as
# it would have been supplied to the command otherwise.
# This actually starts the recursive propagation
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
		if [ $recurse_verbose -eq 1 ]; then
			echo GIT Command git-$git_command with arguments\($#\) "$command_arguments"
		fi
		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
}

echo COMMAND: $0 "$@"

recurse_verbose=0
while test $# != 0
do
	case "$1" in
	add)
		add=1
		;;
	init)
		init=1
		;;
	update)
		update=1
		;;
	status)
		status=1
		;;
	-q|--quiet)
		quiet=1
		;;
	-b|--branch)
		case "$2" in
		'')
			usage
			;;
		esac
		branch="$2"; shift
		;;
	--cached)
		cached=1
		;;
	--)
		break
		;;
	-*)
		usage
		;;
	recurse)
		recurse=1
		case "$2" in
			-v)
				recurse_verbose=1
				shift
				;;
		esac
		shift
		break
		;;
	*)
		break
		;;
	esac
	shift
done

case "$add,$branch" in
1,*)
	;;
,)
	;;
,*)
	usage
	;;
esac

echo Command after parse: "$add,$init,$update,$recurse,$status,$cached"

case "$add,$init,$update,$recurse,$status,$cached" in
1,,,,,)
	module_add "$@"
	;;
,1,,,,)
	modules_init "$@"
	;;
,,1,,,)
	modules_update "$@"
	;;
,,,1,,)
	propagate "$@"
	;;
,,,,*,*)
	modules_list "$@"
	;;
*)
	usage
	;;
esac

^ permalink raw reply

* Re: rm and mv commands: should I use them?
From: David Brown @ 2008-01-07  5:01 UTC (permalink / raw)
  To: Jay Soffian; +Cc: Jon Hancock, git
In-Reply-To: <76718490801061905k30c1ac86r51a65165d47807d4@mail.gmail.com>

On Sun, Jan 06, 2008 at 10:05:34PM -0500, Jay Soffian wrote:
>On 1/6/08, Jon Hancock <redstarling@gmail.com> wrote:
>> Additionally, is there
>> a simple procedure with git to say: "I want to version exactly what is
>> in my working tree.  If I removed something or added something, just
>> handle it".
>
>>From http://www-cs-students.stanford.edu/~blynn/gitmagic/ch05.html#id2553633
>is the helpful hint:
>
>$ git-ls-files -d -m -o -z | xargs -0 git-update-index --add --remove

As long as your git is new enough to have git-add -u, you should be able to
do:

   $ git add .
   $ git add -u

and have the index match the working tree (keeping excludes out).

Dave

^ permalink raw reply

* Re: Problem with git ls-files
From: Imran M Yousuf @ 2008-01-07  4:48 UTC (permalink / raw)
  To: git
In-Reply-To: <7bfdc29a0801062038j269466fcgaffd2b90d59ebfb4@mail.gmail.com>

For output of git-ls-files is

100644 c462997b94c371248bf17895ee18e7fbea5bce9b 0 .gitmodules
160000 091158296a8f57322f70f3c17e5fcb66687a0970 0 a
160000 6397239aeb662ba96f61b59ccc0a0d0812f48435 0 b
160000 c9f0a7dedcb4a9daf5a68c37109577d7d177e10b 0 c
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 main.txt

Sorry for the mistake earlier.

The pastes are also available here.
http://git.pastebin.com/f632762aa

Please help.

Best regards & thank you,

Imran

On Jan 7, 2008 10:38 AM, Imran M Yousuf <imyousuf@gmail.com> wrote:
> Hi all,
>
> I am facing a strange problem with git ls-files in git-submodule. When I do -
> echo in modules init with "$@" - `git-ls-files --stage` - `git
> ls-files --stage -- "$@" | grep -e '^160000 '` - `pwd`
> The output is =
>
> in modules init with d - 100644
> c462997b94c371248bf17895ee18e7fbea5bce9b 0 .gitmodules 160000
> 091158296a8f57322f70f3c17e5fcb66687a0970 0 a 160000
> 6397239aeb662ba96f61b59ccc0a0d0812f48435 0 b 160000
> c9f0a7dedcb4a9daf5a68c37109577d7d177e10b 0 c 100644
> e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 main.txt - -
> /home/imyousuf/projects/git-projs/test/super-project/a
>
> If we format the above output of git list-files --stage we can see the following
>
> 100644 c462997b94c371248bf17895ee18e7fbea5bce9b 0 .gitmodules
> 160000 091158296a8f57322f70f3c17e5fcb66687a0970 0 a
> 160000 6397239aeb662ba96f61b59ccc0a0d0812f48435 0 b
> 160000 c9f0a7dedcb4a9daf5a68c37109577d7d177e10b 0 c
> 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 main.txt
>
> In the output please note the path
> /home/imyousuf/projects/git-projs/test/super-project/a
>
> Now I am providing the output of -
> ls -al /home/imyousuf/projects/git-projs/test/super-project/a
>
>  drwxr-xr-x 4 imyousuf imyousuf 4096 2008-01-07 10:22 .
>  drwxr-xr-x 6 imyousuf imyousuf 4096 2008-01-07 10:22 ..
>  -rw-r--r-- 1 imyousuf imyousuf  130 2008-01-07 10:22 a.txt
>  drwxr-xr-x 2 imyousuf imyousuf 4096 2008-01-07 10:22 d
>  drwxr-xr-x 8 imyousuf imyousuf 4096 2008-01-07 10:22 .git
>  -rw-r--r-- 1 imyousuf imyousuf   95 2008-01-07 10:22 .gitmodules
>
>
> Now this is getting really confusing for me, because I get the strange
> output when I call the git submodule from shell script but after the
> shell script is executed if I do the same command copy and paste in
> gnome-terminal it works fine.
>
> Can someone please tell me what I am doing wrong?
>
> Thank you,
>
> Imran
>



-- 
Imran M Yousuf
Entrepreneur & Software Engineer
Smart IT Engineering
Dhaka, Bangladesh
Email: imran@smartitengineering.com
Mobile: +880-1711402557

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox