summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 85adbf2)
raw | patch | inline | side by side (parent: 85adbf2)
author | Jens Lehmann <Jens.Lehmann@web.de> | |
Sat, 13 Mar 2010 22:00:27 +0000 (23:00 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 14 Mar 2010 05:56:35 +0000 (21:56 -0800) |
Since 1.7.0 submodules are considered dirty when they contain untracked
files. But when git status is called with the "-uno" option, the user
asked to ignore untracked files, so they must be ignored in submodules
too. To achieve this, the new flag DIFF_OPT_IGNORE_UNTRACKED_IN_SUBMODULES
is introduced.
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
files. But when git status is called with the "-uno" option, the user
asked to ignore untracked files, so they must be ignored in submodules
too. To achieve this, the new flag DIFF_OPT_IGNORE_UNTRACKED_IN_SUBMODULES
is introduced.
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff-lib.c | patch | blob | history | |
diff.h | patch | blob | history | |
submodule.c | patch | blob | history | |
submodule.h | patch | blob | history | |
t/t7506-status-submodule.sh | patch | blob | history | |
wt-status.c | patch | blob | history |
diff --git a/diff-lib.c b/diff-lib.c
index 87a259111a7f6bcce3a06f288f5fda89df6dd34e..c50f7e39847a5363c8d8859e381259ffd6e57f0b 100644 (file)
--- a/diff-lib.c
+++ b/diff-lib.c
if (S_ISGITLINK(ce->ce_mode)
&& !DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES)
&& (!changed || DIFF_OPT_TST(diffopt, DIRTY_SUBMODULES))) {
- *dirty_submodule = is_submodule_modified(ce->name);
+ *dirty_submodule = is_submodule_modified(ce->name, DIFF_OPT_TST(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES));
}
return changed;
}
index 95ed7f8ed76c9345f1e4a282744a74934a370ce4..6a71013dc63fc0912fd4f3d27f70ae909917f1f6 100644 (file)
--- a/diff.h
+++ b/diff.h
#define DIFF_OPT_DIFF_FROM_CONTENTS (1 << 22)
#define DIFF_OPT_SUBMODULE_LOG (1 << 23)
#define DIFF_OPT_DIRTY_SUBMODULES (1 << 24)
+#define DIFF_OPT_IGNORE_UNTRACKED_IN_SUBMODULES (1 << 25)
#define DIFF_OPT_TST(opts, flag) ((opts)->flags & DIFF_OPT_##flag)
#define DIFF_OPT_SET(opts, flag) ((opts)->flags |= DIFF_OPT_##flag)
diff --git a/submodule.c b/submodule.c
index 714ca976b85c5501011e40b82dc7da065003744b..b3b8bc147909f81be6a387318ad0601dae50460f 100644 (file)
--- a/submodule.c
+++ b/submodule.c
strbuf_release(&sb);
}
-unsigned is_submodule_modified(const char *path)
+unsigned is_submodule_modified(const char *path, int ignore_untracked)
{
int i;
ssize_t len;
"status",
"--porcelain",
NULL,
+ NULL,
};
const char *env[LOCAL_REPO_ENV_SIZE + 3];
struct strbuf buf = STRBUF_INIT;
env[i++] = strbuf_detach(&buf, NULL);
env[i] = NULL;
+ if (ignore_untracked)
+ argv[2] = "-uno";
+
memset(&cp, 0, sizeof(cp));
cp.argv = argv;
cp.env = env;
break;
} else {
dirty_submodule |= DIRTY_SUBMODULE_MODIFIED;
- if (dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)
+ if (ignore_untracked ||
+ (dirty_submodule & DIRTY_SUBMODULE_UNTRACKED))
break;
}
next_line = strchr(line, '\n');
diff --git a/submodule.h b/submodule.h
index 267881cbe438c1a83c76d23d130a54757d661f84..dbda270873171c41f20c0f07b70773ce67c6a303 100644 (file)
--- a/submodule.h
+++ b/submodule.h
unsigned char one[20], unsigned char two[20],
unsigned dirty_submodule,
const char *del, const char *add, const char *reset);
-unsigned is_submodule_modified(const char *path);
+unsigned is_submodule_modified(const char *path, int ignore_untracked);
#endif
index dc9150a71f70e76a89c3ef5e4a715c8fba69e01c..aeec1f6142e622ffc7b0ef8a68fe7734c02d24d0 100755 (executable)
grep "modified: sub (untracked content)" output
'
+test_expect_success 'status -uno with untracked file in submodule' '
+ git status -uno >output &&
+ grep "^nothing to commit" output
+'
+
test_expect_success 'status with untracked file in submodule (porcelain)' '
git status --porcelain >output &&
diff output - <<-\EOF
diff --git a/wt-status.c b/wt-status.c
index e0e915e46a5cf973b7bfbf583d04ba976c279e9a..5848f1c90802e8833c43c6e395420cf13e9a8a6a 100644 (file)
--- a/wt-status.c
+++ b/wt-status.c
setup_revisions(0, NULL, &rev, NULL);
rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
DIFF_OPT_SET(&rev.diffopt, DIRTY_SUBMODULES);
+ if (!s->show_untracked_files)
+ DIFF_OPT_SET(&rev.diffopt, IGNORE_UNTRACKED_IN_SUBMODULES);
rev.diffopt.format_callback = wt_status_collect_changed_cb;
rev.diffopt.format_callback_data = s;
rev.prune_data = s->pathspec;