From: Damien Robert <damien.olivier.robert@gmail.com>
To: Philippe Blain <levraiphilippeblain@gmail.com>
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
git <git@vger.kernel.org>, "Junio C Hamano" <gitster@pobox.com>,
"Jeff King" <peff@peff.net>
Subject: Re: GIT_DIR in aliases [Re: Spurious GIT_DIR set when in a worktree [was Re: Nested submodule status bug]
Date: Tue, 3 Mar 2020 22:56:50 +0100 [thread overview]
Message-ID: <20200303215650.vpsfgcjrsv42dqob@doriath> (raw)
In-Reply-To: <6D4FEE68-EF3C-491E-A7C1-3454B88977C3@gmail.com>
> If that’s what your are trying to do, ‘git submodule foreach’ [1] seems like a better way to go.
> For example I have an alias ‘st-sub’ that calls git status in the superproject and then recursively in the submodules:
>
> $ cat ~/.gitconfig | grep st-sub
> st-sub = !git status "$@" && git sub foreach --recursive git status "$@"
I have almost the same aliases :)
s = status --short --branch
subfor="submodule foreach --recursive"
subs="!f() { git subfor git s \"$@\";}; f"
recs="!f() { git s \"$@\"; git subs \"$@\";}; f"
But in practice I often want to run commands only in *changed* submodules.
For instance with the above 'git subs' yields a lot of non informative
messages like:
Entering 'non/changed/submodule'
## master...origin/master
(and git foreach --quiet) removes the first line but not the second.
This is also useful for an alias like 'recursive_commit' where I only want
to commit changed submodules, to not get a lot of messages like
nothing to commit, working tree clean.
So I wrote a script that parses the output of 'git status --porcelain=v2'
and run a command only in changed submodules (where I can specify if
changed means 'C', 'M' or 'U'). Except that I did not think about unseting
GIT_DIR and stumbled into this bug (I am sorry I went a bit on a wild chase
in this mailing list but I had already spent quite some time in trying to
find a minimal exemple, I first thought that my program had a parsing bug).
Now that I think about it, I probably also could do that with 'git
submodule foreach', by testing 'git diff --no-ext-diff [--cached] --quiet'
first before running the subcommand. This would give me the 'M' submodules,
but it is not clear to me how I could test for 'C' changed submodules with
this method.
--
Damien Robert
http://www.normalesup.org/~robert/pro
prev parent reply other threads:[~2020-03-03 21:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-14 22:42 Nested submodule checkout Damien Robert
2020-02-17 4:51 ` Philippe Blain
2020-02-18 17:08 ` Damien Robert
2020-02-19 4:19 ` Philippe Blain
2020-02-26 17:23 ` Nested submodule status bug Damien Robert
2020-02-27 10:05 ` Damien Robert
2020-02-27 10:43 ` Spurious GIT_DIR set when in a worktree [was Re: Nested submodule status bug] Damien Robert
2020-02-27 15:50 ` GIT_DIR in aliases [Re: " Damien Robert
2020-02-28 19:02 ` Jeff King
2020-02-28 20:22 ` Junio C Hamano
2020-03-03 22:44 ` Damien Robert
2020-02-29 1:42 ` Philippe Blain
2020-03-03 21:56 ` Damien Robert [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200303215650.vpsfgcjrsv42dqob@doriath \
--to=damien.olivier.robert@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=levraiphilippeblain@gmail.com \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).