From: Jonathan Nieder <jrnieder@gmail.com>
To: Stefan Beller <sbeller@google.com>
Cc: gitster@pobox.com, git@vger.kernel.org
Subject: Re: [PATCH 7/7] submodule.c: correctly handle nested submodules in is_submodule_modified
Date: Fri, 24 Mar 2017 16:31:56 -0700 [thread overview]
Message-ID: <20170324233156.GL31294@aiede.mtv.corp.google.com> (raw)
In-Reply-To: <20170324182902.19280-8-sbeller@google.com>
Stefan Beller wrote:
> When a nested submodule has untracked files, it would be reported as
> "modified submodule" in the superproject, because submodules are not
> parsed correctly in is_submodule_modified as they are bucketed into
> the modified pile as "they are not an untracked file".
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
> submodule.c | 16 ++++++++++++++--
> t/t3600-rm.sh | 2 +-
> t/t7506-status-submodule.sh | 2 +-
> 3 files changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/submodule.c b/submodule.c
> index 467f1de763..ec7e9b1b06 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -1078,8 +1078,20 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)
> /* regular untracked files */
> if (buf.buf[0] == '?')
> dirty_submodule |= DIRTY_SUBMODULE_UNTRACKED;
> - else
> - dirty_submodule |= DIRTY_SUBMODULE_MODIFIED;
> +
> + /* regular unmerged and renamed files */
> + if (buf.buf[0] == 'u' ||
> + buf.buf[0] == '1' ||
> + buf.buf[0] == '2') {
> + if (buf.buf[5] == 'S') {
Can this overflow the buffer? Submodule state is supposed to be 4
characters, so could do
/*
* T XY SSSS:
* T = line type, XY = status, SSSS = submodule state
*/
if (buf.len < 1 + 1 + 2 + 1 + 4)
die("BUG: invalid status --porcelain=2 line %s",
buf.buf);
if (buf.buf[5] == 'S' && buf.buf[8] == 'U')
/* untracked file */
dirty_submodule |= DIRTY_SUBMODULE_UNTRACKED;
if (memcmp(buf.buf + 5, "S..U", 4))
/* other change */
dirty_submodule |= DIRTY_SUBMODULE_MODIFIED;
}
> + /* nested submodule handling */
> + if (buf.buf[6] == 'C' || buf.buf[7] == 'M')
> + dirty_submodule |= DIRTY_SUBMODULE_MODIFIED;
> + if (buf.buf[8] == 'U')
> + dirty_submodule |= DIRTY_SUBMODULE_UNTRACKED;
> + } else
> + dirty_submodule |= DIRTY_SUBMODULE_MODIFIED;
> + }
I get lost in these cases. What does it mean if we see S..., for
example?
As an example, if I am understanding correctly, before this patch, if
I have a submodule-in-submodule:
$ find . -name .git
.git
sub/.git
sub/subsub/.git
and I put a stray file in the sub-sub module:
$ echo stray-file >sub/subsub/x.o
then status --porcelain=2 tells me that sub is modified:
$ git status --porcelain=2
1 .M S.M. [...] sub
What should it say after the patch? Is the XY field ".." or ".M"?
Some tests covering these cases with --porcelain=2 and a brief mention
in documentation may help.
Thanks,
Jonathan
diff --git i/submodule.c w/submodule.c
index ec7e9b1b06..aec1b2cdca 100644
--- i/submodule.c
+++ w/submodule.c
@@ -1083,13 +1083,18 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)
if (buf.buf[0] == 'u' ||
buf.buf[0] == '1' ||
buf.buf[0] == '2') {
- if (buf.buf[5] == 'S') {
- /* nested submodule handling */
- if (buf.buf[6] == 'C' || buf.buf[7] == 'M')
- dirty_submodule |= DIRTY_SUBMODULE_MODIFIED;
- if (buf.buf[8] == 'U')
- dirty_submodule |= DIRTY_SUBMODULE_UNTRACKED;
- } else
+ /*
+ * T XY SSSS:
+ * T = line type, XY = status, SSSS = submodule state
+ */
+ if (buf.len < 1 + 1 + 2 + 1 + 4)
+ die("BUG: invalid status --porcelain=2 line %s",
+ buf.buf);
+ if (buf.buf[5] == 'S' && buf.buf[8] == 'U')
+ /* untracked file */
+ dirty_submodule |= DIRTY_SUBMODULE_UNTRACKED;
+ if (memcmp(buf.buf + 5, "S..U", 4))
+ /* other change */
dirty_submodule |= DIRTY_SUBMODULE_MODIFIED;
}
next prev parent reply other threads:[~2017-03-24 23:32 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-23 0:43 [PATCHv3 0/3] short status: improve reporting for submodule changes Stefan Beller
2017-03-23 0:43 ` [PATCH 1/3] submodule.c: port is_submodule_modified to use porcelain 2 Stefan Beller
2017-03-23 0:53 ` Jonathan Nieder
2017-03-23 6:09 ` Junio C Hamano
2017-03-23 18:47 ` Stefan Beller
2017-03-23 0:43 ` [PATCH 2/3] submodule.c, is_submodule_modified: stricter checking for submodules Stefan Beller
2017-03-23 0:54 ` Jonathan Nieder
2017-03-23 0:43 ` [PATCH 3/3] short status: improve reporting for submodule changes Stefan Beller
2017-03-23 1:06 ` Jonathan Nieder
2017-03-23 21:09 ` [PATCH 0/8] " Stefan Beller
2017-03-23 21:09 ` [PATCH 1/8] submodule.c: port is_submodule_modified to use porcelain 2 Stefan Beller
2017-03-23 21:09 ` [PATCH 2/8] submodule.c: use argv_array in is_submodule_modified Stefan Beller
2017-03-23 21:09 ` [PATCH 3/8] submodule.c: convert is_submodule_modified to use strbuf_getwholeline_fd Stefan Beller
2017-03-23 21:09 ` [PATCH 4/8] submodule.c: port is_submodule_modified to use porcelain 2 Stefan Beller
2017-03-23 21:09 ` [PATCH 5/8] submodule.c: factor out early loop termination in is_submodule_modified Stefan Beller
2017-03-23 21:09 ` [PATCH 6/8] submodule.c: stricter checking for submodules " Stefan Beller
2017-03-23 21:09 ` [PATCH 7/8] short status: improve reporting for submodule changes Stefan Beller
2017-03-23 21:09 ` [PATCH 8/8] submodule.c: correctly handle nested submodules in is_submodule_modified Stefan Beller
2017-03-23 21:11 ` [PATCH 0/8] short status: improve reporting for submodule changes Stefan Beller
2017-03-23 22:33 ` [PATCH v5 0/7] " Stefan Beller
2017-03-23 22:33 ` [PATCH 1/7] submodule.c: use argv_array in is_submodule_modified Stefan Beller
2017-03-23 22:36 ` Jonathan Nieder
2017-03-23 22:33 ` [PATCH 2/7] submodule.c: convert is_submodule_modified to use strbuf_getwholeline_fd Stefan Beller
2017-03-23 22:50 ` Jonathan Nieder
2017-03-23 23:04 ` Stefan Beller
2017-03-23 23:11 ` Stefan Beller
2017-03-23 22:33 ` [PATCH 3/7] submodule.c: port is_submodule_modified to use porcelain 2 Stefan Beller
2017-03-23 22:33 ` [PATCH 4/7] submodule.c: factor out early loop termination in is_submodule_modified Stefan Beller
2017-03-23 22:33 ` [PATCH 5/7] submodule.c: stricter checking for submodules " Stefan Beller
2017-03-23 22:33 ` [PATCH 6/7] short status: improve reporting for submodule changes Stefan Beller
2017-03-24 18:28 ` [PATCH v6 0/7] " Stefan Beller
2017-03-24 18:28 ` [PATCH 1/7] submodule.c: use argv_array in is_submodule_modified Stefan Beller
2017-03-24 22:25 ` Jonathan Nieder
2017-03-24 18:28 ` [PATCH 2/7] submodule.c: factor out early loop termination " Stefan Beller
2017-03-24 22:30 ` Jonathan Nieder
2017-03-24 18:28 ` [PATCH 3/7] submodule.c: convert is_submodule_modified to use strbuf_getwholeline Stefan Beller
2017-03-24 22:38 ` Jonathan Nieder
2017-03-25 0:12 ` Stefan Beller
2017-03-24 18:28 ` [PATCH 4/7] submodule.c: port is_submodule_modified to use porcelain 2 Stefan Beller
2017-03-24 22:41 ` Jonathan Nieder
2017-03-24 18:29 ` [PATCH 5/7] submodule.c: stricter checking for submodules in is_submodule_modified Stefan Beller
2017-03-24 22:42 ` Jonathan Nieder
2017-03-24 18:29 ` [PATCH 6/7] short status: improve reporting for submodule changes Stefan Beller
2017-03-24 23:06 ` Jonathan Nieder
2017-03-24 18:29 ` [PATCH 7/7] submodule.c: correctly handle nested submodules in is_submodule_modified Stefan Beller
2017-03-24 23:31 ` Jonathan Nieder [this message]
2017-03-25 0:25 ` Stefan Beller
2017-03-25 0:36 ` [PATCH v7 0/7] short status: improve reporting for submodule changes Stefan Beller
2017-03-25 0:36 ` [PATCH 1/7] submodule.c: use argv_array in is_submodule_modified Stefan Beller
2017-03-25 0:36 ` [PATCH 2/7] submodule.c: factor out early loop termination " Stefan Beller
2017-03-25 0:36 ` [PATCH 3/7] submodule.c: convert is_submodule_modified to use strbuf_getwholeline Stefan Beller
2017-03-25 0:36 ` [PATCH 4/7] submodule.c: port is_submodule_modified to use porcelain 2 Stefan Beller
2017-03-25 0:36 ` [PATCH 5/7] submodule.c: stricter checking for submodules in is_submodule_modified Stefan Beller
2017-03-25 0:36 ` [PATCH 6/7] short status: improve reporting for submodule changes Stefan Beller
2017-03-25 0:36 ` [PATCH 7/7] submodule.c: correctly handle nested submodules in is_submodule_modified Stefan Beller
2017-03-27 21:46 ` Junio C Hamano
2017-03-28 1:05 ` Jonathan Nieder
2017-03-30 18:18 ` Junio C Hamano
2017-03-28 21:20 ` Stefan Beller
2017-03-25 1:35 ` [PATCH v7 0/7] short status: improve reporting for submodule changes Jonathan Nieder
2017-03-28 23:09 ` [PATCH v8 " Stefan Beller
2017-03-28 23:09 ` [PATCH 1/2] " Stefan Beller
2017-03-28 23:24 ` Jonathan Nieder
2017-03-28 23:09 ` [PATCH 2/2] submodule.c: correctly handle nested submodules in is_submodule_modified Stefan Beller
2017-03-28 23:42 ` Jonathan Nieder
2017-03-29 22:00 ` Stefan Beller
2017-03-29 22:26 ` [PATCHv9 (6,7)/7] short status: improve reporting for submodule changes Stefan Beller
2017-03-29 22:26 ` [PATCH 1/2] " Stefan Beller
2017-03-29 23:09 ` Jonathan Nieder
2017-03-29 22:26 ` [PATCH 2/2] submodule.c: correctly handle nested submodules in is_submodule_modified Stefan Beller
2017-03-29 23:13 ` Jonathan Nieder
2017-03-30 18:28 ` Junio C Hamano
2017-03-23 22:33 ` [PATCH 7/7] " Stefan Beller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170324233156.GL31294@aiede.mtv.corp.google.com \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.