# RFC: Folder Git

6 messages from 2011-04-25 to 2011-04-26. Participants: Victor Engmark, Jon Seymour, Jakub Narebski.
Thread: https://gitlist.dev/t/27172

## Victor Engmark, 2011-04-25 08:32

Subject: RFC: Folder Git
Message-ID: <BANLkTim=xKxN9JovToVuOg=SQ2Mba1LvxQ@mail.gmail.com>
URL: https://gitlist.dev/e/BANLkTim%3DxKxN9JovToVuOg%3DSQ2Mba1LvxQ%40mail.gmail.com

```
Most days I work on more than one repository, and on more than one
machine. I've never needed the "--" argument separator so far. This
combination makes it useful to have a way to run Git commands on
several repositories at once. A one-time solution would of course be a
for-loop which checks for a .git directory before running the given
command, but this operation ended up being frequent enough that I
wrote a script for it: fgit
<https://github.com/l0b0/fgit/blob/master/fgit.sh>. Features include:
* Runs the Git command given in all specified directories which have a
.git subdirectory, and warns about any that lack this directory.
* Should work with any path, containing spaces, newlines or other
exotic characters.
* Should work with any Git command that doesn't require the "--"
separator between the options and arguments.
* Prints the Git command before running it, for logging and repetition.
* errexit and nounset are active for each line, with one exception:
errexit is disabled for the running of the command, to allow it to
continue to other repositories.

Issues:
* Don't know if anyone else has used it. Probably not, so there's
bound to be issues (especially since it's been changed quite a bit the
last couple days for this RFC).

Is there a place for such a tool in Git porcelain or elsewhere in the
Git project, or should it be kept completely separate?

-- 
Victor Engmark

```

## Jon Seymour, 2011-04-25 08:52

Subject: Re: RFC: Folder Git
Message-ID: <BANLkTimnyv_+NCc3yOSswJeqHo_zsGwCDA@mail.gmail.com>
URL: https://gitlist.dev/e/BANLkTimnyv_%2BNCc3yOSswJeqHo_zsGwCDA%40mail.gmail.com
In-Reply-To: <BANLkTim=xKxN9JovToVuOg=SQ2Mba1LvxQ@mail.gmail.com>

```
On Mon, Apr 25, 2011 at 6:32 PM, Victor Engmark
<victor.engmark@gmail.com> wrote:
continue to other repositories.
>
> Issues:
> * Don't know if anyone else has used it. Probably not, so there's
> bound to be issues (especially since it's been changed quite a bit the
> last couple days for this RFC).
>

Victor,

Certainly seems like a common need. I had a similar solution which I
used for a while.

In the end, however, I found that creating a super-module in the top
directory that contains
the other git directories as git submodules allowed me to use a
standard feature of git to achieve the same effect.

So:

    git submodule foreach git gc --aggressive

I know this won't suit every use case, but it does work in an
environment where the set of repos you are operating on have a degree
of coherence and it makes sense to set up a submodule for them.  In
this particular case this is the only reason why I use submodules - I
don't use them for configuration management, for example, simply as a
handy way to exploit git submodule foreach.

Have you considered using git submodules in this way?

jon.

```

## Jakub Narebski, 2011-04-25 10:39

Subject: Re: RFC: Folder Git
Message-ID: <m3fwp6wr7h.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m3fwp6wr7h.fsf%40localhost.localdomain
In-Reply-To: <BANLkTim=xKxN9JovToVuOg=SQ2Mba1LvxQ@mail.gmail.com>

```
Victor Engmark <victor.engmark@gmail.com> writes:

[...]
> I wrote a script for it: fgit
> <https://github.com/l0b0/fgit/blob/master/fgit.sh>. Features include:
> * Runs the Git command given in all specified directories which have a
> .git subdirectory, and warns about any that lack this directory.
> * Should work with any path, containing spaces, newlines or other
> exotic characters.
> * Should work with any Git command that doesn't require the "--"
> separator between the options and arguments.
> * Prints the Git command before running it, for logging and repetition.
> * errexit and nounset are active for each line, with one exception:
> errexit is disabled for the running of the command, to allow it to
> continue to other repositories.

Do you think this tool is mature and stable enough to add it to

  https://git.wiki.kernel.org/index.php/InterfacesFrontendsAndTools

page on Git Wiki?
-- 
Jakub Narebski
Poland
ShadeHawk on #git

```

## Victor Engmark, 2011-04-26 06:47

Subject: Re: RFC: Folder Git
Message-ID: <BANLkTikkFgCQP9DA5VwMCMzDCiTnEENvOg@mail.gmail.com>
URL: https://gitlist.dev/e/BANLkTikkFgCQP9DA5VwMCMzDCiTnEENvOg%40mail.gmail.com
In-Reply-To: <BANLkTimnyv_+NCc3yOSswJeqHo_zsGwCDA@mail.gmail.com>

```
On Mon, Apr 25, 2011 at 10:52 AM, Jon Seymour <jon.seymour@gmail.com> wrote:
> On Mon, Apr 25, 2011 at 6:32 PM, Victor Engmark
> <victor.engmark@gmail.com> wrote:
> continue to other repositories.
>>
>> Issues:
>> * Don't know if anyone else has used it. Probably not, so there's
>> bound to be issues (especially since it's been changed quite a bit the
>> last couple days for this RFC).
>>
>
> Victor,
>
> Certainly seems like a common need. I had a similar solution which I
> used for a while.
>
> In the end, however, I found that creating a super-module in the top
> directory that contains
> the other git directories as git submodules allowed me to use a
> standard feature of git to achieve the same effect.
>
> So:
>
>    git submodule foreach git gc --aggressive
>
> I know this won't suit every use case, but it does work in an
> environment where the set of repos you are operating on have a degree
> of coherence and it makes sense to set up a submodule for them.  In
> this particular case this is the only reason why I use submodules - I
> don't use them for configuration management, for example, simply as a
> handy way to exploit git submodule foreach.
>
> Have you considered using git submodules in this way?

I didn't know you could use them this way, and it's a nicely "Gitonic"
way of doing it. I don't think this would fit my case, since the repos
are not much related and it's a more verbose solution which takes
longer to set up than copying a single script. A compromise could be
to set up a Git alias `sgit="git submodule foreach git"`, if that'll
work as expected.

-- 
Victor Engmark

```

## Victor Engmark, 2011-04-26 06:59

Subject: Re: RFC: Folder Git
Message-ID: <BANLkTinK40EQzog6WyZCyUGKN4DpYJ-YwA@mail.gmail.com>
URL: https://gitlist.dev/e/BANLkTinK40EQzog6WyZCyUGKN4DpYJ-YwA%40mail.gmail.com
In-Reply-To: <m3fwp6wr7h.fsf@localhost.localdomain>

```
On Mon, Apr 25, 2011 at 12:39 PM, Jakub Narebski <jnareb@gmail.com> wrote:
> Victor Engmark <victor.engmark@gmail.com> writes:
>
> [...]
>> I wrote a script for it: fgit
>> <https://github.com/l0b0/fgit/blob/master/fgit.sh>. Features include:
>> * Runs the Git command given in all specified directories which have a
>> .git subdirectory, and warns about any that lack this directory.
>> * Should work with any path, containing spaces, newlines or other
>> exotic characters.
>> * Should work with any Git command that doesn't require the "--"
>> separator between the options and arguments.
>> * Prints the Git command before running it, for logging and repetition.
>> * errexit and nounset are active for each line, with one exception:
>> errexit is disabled for the running of the command, to allow it to
>> continue to other repositories.
>
> Do you think this tool is mature and stable enough to add it to
>
>  https://git.wiki.kernel.org/index.php/InterfacesFrontendsAndTools
>
> page on Git Wiki?

It's already there, so I guess someone thought it was :) I'll try to
fix the description as soon as the web page works with Firefox (I
could only load the contents with wget).

-- 
Victor Engmark

```

## Jon Seymour, 2011-04-26 07:03

Subject: Re: RFC: Folder Git
Message-ID: <BANLkTin5JV3WSMDvA3E-oJUMCxsy8uByhw@mail.gmail.com>
URL: https://gitlist.dev/e/BANLkTin5JV3WSMDvA3E-oJUMCxsy8uByhw%40mail.gmail.com
In-Reply-To: <BANLkTikkFgCQP9DA5VwMCMzDCiTnEENvOg@mail.gmail.com>

```
A concept I played with at one point was to have the idea of a working
set, which is a list repos.

You could then apply to the whole working set any command after
changing to the root directory of each repo, much like git submodules
does, but without any suggestion of any other relationship between the
repos.

The details working set were stored in the global git configuration.

In principle, you could have multiple working sets and switch which
one was active at a given time.

So, you'd do something like:

git working-set foreach {cmd} {args...}
git working-set activate working-set-name
git working-set add repo-url
git working-set remove repo-url

and so on...

jon.

On Tue, Apr 26, 2011 at 4:47 PM, Victor Engmark
<victor.engmark@gmail.com> wrote:
> On Mon, Apr 25, 2011 at 10:52 AM, Jon Seymour <jon.seymour@gmail.com> wrote:
>> On Mon, Apr 25, 2011 at 6:32 PM, Victor Engmark
>> <victor.engmark@gmail.com> wrote:
>> continue to other repositories.
>>>
>>> Issues:
>>> * Don't know if anyone else has used it. Probably not, so there's
>>> bound to be issues (especially since it's been changed quite a bit the
>>> last couple days for this RFC).
>>>
>>
>> Victor,
>>
>> Certainly seems like a common need. I had a similar solution which I
>> used for a while.
>>
>> In the end, however, I found that creating a super-module in the top
>> directory that contains
>> the other git directories as git submodules allowed me to use a
>> standard feature of git to achieve the same effect.
>>
>> So:
>>
>>    git submodule foreach git gc --aggressive
>>
>> I know this won't suit every use case, but it does work in an
>> environment where the set of repos you are operating on have a degree
>> of coherence and it makes sense to set up a submodule for them.  In
>> this particular case this is the only reason why I use submodules - I
>> don't use them for configuration management, for example, simply as a
>> handy way to exploit git submodule foreach.
>>
>> Have you considered using git submodules in this way?
>
> I didn't know you could use them this way, and it's a nicely "Gitonic"
> way of doing it. I don't think this would fit my case, since the repos
> are not much related and it's a more verbose solution which takes
> longer to set up than copying a single script. A compromise could be
> to set up a Git alias `sgit="git submodule foreach git"`, if that'll
> work as expected.
>
> --
> Victor Engmark
>

```
