threads / discuss / 27172

RFC: Folder Git

Subject: RFC: Folder Git

## tl;dr

6 messages between Apr 25, 2011 and Apr 26, 2011.

replies: 5people: 3as markdown or json

Victor Engmark· Apr 25, 2011, 08:32 UTC · lore
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· Apr 25, 2011, 08:52 UTC · re: Victor Engmark · lore

Re: RFC: Folder Git

On Mon, Apr 25, 2011 at 6:32 PM, Victor Engmark <victor.engmark@gmail.com> wrote: continue to other repositories.

Show 6 quoted lines
>
> 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.
Victor Engmark· Apr 26, 2011, 06:47 UTC · re: Jon Seymour · lore

Re: RFC: Folder Git

On Mon, Apr 25, 2011 at 10:52 AM, Jon Seymour <jon.seymour@gmail.com> wrote:
Show 32 quoted lines
> 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
Jon Seymour· Apr 26, 2011, 07:03 UTC · re: Victor Engmark · lore

Re: RFC: Folder Git

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:

Show 44 quoted lines
> 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
>
Jakub Narebski· Apr 25, 2011, 10:39 UTC · re: Victor Engmark · lore

Re: RFC: Folder Git

Victor Engmark <victor.engmark@gmail.com> writes:
[...]
Show 12 quoted lines
> 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· Apr 26, 2011, 06:59 UTC · re: Jakub Narebski · lore

Re: RFC: Folder Git

On Mon, Apr 25, 2011 at 12:39 PM, Jakub Narebski <jnareb@gmail.com> wrote:
Show 21 quoted lines
> 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

← back to recent threads