зеркало из https://github.com/microsoft/git.git
Merge branch 'jl/diff-submodule-ignore'
* jl/diff-submodule-ignore: Teach diff --submodule that modified submodule directory is dirty git diff: Don't test submodule dirtiness with --ignore-submodules Make ce_uptodate() trustworthy again
This commit is contained in:
Коммит
d539de9f25
12
diff-lib.c
12
diff-lib.c
|
@ -161,7 +161,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ce_uptodate(ce) && !S_ISGITLINK(ce->ce_mode)) || ce_skip_worktree(ce))
|
if (ce_uptodate(ce) || ce_skip_worktree(ce))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* If CE_VALID is set, don't look at workdir for file removal */
|
/* If CE_VALID is set, don't look at workdir for file removal */
|
||||||
|
@ -179,6 +179,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
|
||||||
}
|
}
|
||||||
changed = ce_match_stat(ce, &st, ce_option);
|
changed = ce_match_stat(ce, &st, ce_option);
|
||||||
if (S_ISGITLINK(ce->ce_mode)
|
if (S_ISGITLINK(ce->ce_mode)
|
||||||
|
&& !DIFF_OPT_TST(&revs->diffopt, IGNORE_SUBMODULES)
|
||||||
&& (!changed || (revs->diffopt.output_format & DIFF_FORMAT_PATCH))
|
&& (!changed || (revs->diffopt.output_format & DIFF_FORMAT_PATCH))
|
||||||
&& is_submodule_modified(ce->name)) {
|
&& is_submodule_modified(ce->name)) {
|
||||||
changed = 1;
|
changed = 1;
|
||||||
|
@ -220,7 +221,7 @@ static int get_stat_data(struct cache_entry *ce,
|
||||||
const unsigned char **sha1p,
|
const unsigned char **sha1p,
|
||||||
unsigned int *modep,
|
unsigned int *modep,
|
||||||
int cached, int match_missing,
|
int cached, int match_missing,
|
||||||
unsigned *dirty_submodule, int output_format)
|
unsigned *dirty_submodule, struct diff_options *diffopt)
|
||||||
{
|
{
|
||||||
const unsigned char *sha1 = ce->sha1;
|
const unsigned char *sha1 = ce->sha1;
|
||||||
unsigned int mode = ce->ce_mode;
|
unsigned int mode = ce->ce_mode;
|
||||||
|
@ -241,7 +242,8 @@ static int get_stat_data(struct cache_entry *ce,
|
||||||
}
|
}
|
||||||
changed = ce_match_stat(ce, &st, 0);
|
changed = ce_match_stat(ce, &st, 0);
|
||||||
if (S_ISGITLINK(ce->ce_mode)
|
if (S_ISGITLINK(ce->ce_mode)
|
||||||
&& (!changed || (output_format & DIFF_FORMAT_PATCH))
|
&& !DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES)
|
||||||
|
&& (!changed || (diffopt->output_format & DIFF_FORMAT_PATCH))
|
||||||
&& is_submodule_modified(ce->name)) {
|
&& is_submodule_modified(ce->name)) {
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dirty_submodule = 1;
|
*dirty_submodule = 1;
|
||||||
|
@ -270,7 +272,7 @@ static void show_new_file(struct rev_info *revs,
|
||||||
* the working copy.
|
* the working copy.
|
||||||
*/
|
*/
|
||||||
if (get_stat_data(new, &sha1, &mode, cached, match_missing,
|
if (get_stat_data(new, &sha1, &mode, cached, match_missing,
|
||||||
&dirty_submodule, revs->diffopt.output_format) < 0)
|
&dirty_submodule, &revs->diffopt) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
diff_index_show_file(revs, "+", new, sha1, mode, dirty_submodule);
|
diff_index_show_file(revs, "+", new, sha1, mode, dirty_submodule);
|
||||||
|
@ -287,7 +289,7 @@ static int show_modified(struct rev_info *revs,
|
||||||
unsigned dirty_submodule = 0;
|
unsigned dirty_submodule = 0;
|
||||||
|
|
||||||
if (get_stat_data(new, &sha1, &mode, cached, match_missing,
|
if (get_stat_data(new, &sha1, &mode, cached, match_missing,
|
||||||
&dirty_submodule, revs->diffopt.output_format) < 0) {
|
&dirty_submodule, &revs->diffopt) < 0) {
|
||||||
if (report_missing)
|
if (report_missing)
|
||||||
diff_index_show_file(revs, "-", old,
|
diff_index_show_file(revs, "-", old,
|
||||||
old->sha1, old->ce_mode, 0);
|
old->sha1, old->ce_mode, 0);
|
||||||
|
|
2
diff.c
2
diff.c
|
@ -1615,7 +1615,7 @@ static void builtin_diff(const char *name_a,
|
||||||
const char *del = diff_get_color_opt(o, DIFF_FILE_OLD);
|
const char *del = diff_get_color_opt(o, DIFF_FILE_OLD);
|
||||||
const char *add = diff_get_color_opt(o, DIFF_FILE_NEW);
|
const char *add = diff_get_color_opt(o, DIFF_FILE_NEW);
|
||||||
show_submodule_summary(o->file, one ? one->path : two->path,
|
show_submodule_summary(o->file, one ? one->path : two->path,
|
||||||
one->sha1, two->sha1,
|
one->sha1, two->sha1, two->dirty_submodule,
|
||||||
del, add, reset);
|
del, add, reset);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,8 @@ static void *preload_thread(void *_data)
|
||||||
|
|
||||||
if (ce_stage(ce))
|
if (ce_stage(ce))
|
||||||
continue;
|
continue;
|
||||||
|
if (S_ISGITLINK(ce->ce_mode))
|
||||||
|
continue;
|
||||||
if (ce_uptodate(ce))
|
if (ce_uptodate(ce))
|
||||||
continue;
|
continue;
|
||||||
if (!ce_path_match(ce, p->pathspec))
|
if (!ce_path_match(ce, p->pathspec))
|
||||||
|
|
|
@ -612,7 +612,8 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
|
||||||
if (alias && !ce_stage(alias) && !ie_match_stat(istate, alias, st, ce_option)) {
|
if (alias && !ce_stage(alias) && !ie_match_stat(istate, alias, st, ce_option)) {
|
||||||
/* Nothing changed, really */
|
/* Nothing changed, really */
|
||||||
free(ce);
|
free(ce);
|
||||||
ce_mark_uptodate(alias);
|
if (!S_ISGITLINK(alias->ce_mode))
|
||||||
|
ce_mark_uptodate(alias);
|
||||||
alias->ce_flags |= CE_ADDED;
|
alias->ce_flags |= CE_ADDED;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1050,7 +1051,8 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
|
||||||
* because CE_UPTODATE flag is in-core only;
|
* because CE_UPTODATE flag is in-core only;
|
||||||
* we are not going to write this change out.
|
* we are not going to write this change out.
|
||||||
*/
|
*/
|
||||||
ce_mark_uptodate(ce);
|
if (!S_ISGITLINK(ce->ce_mode))
|
||||||
|
ce_mark_uptodate(ce);
|
||||||
return ce;
|
return ce;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ static int add_submodule_odb(const char *path)
|
||||||
|
|
||||||
void show_submodule_summary(FILE *f, const char *path,
|
void show_submodule_summary(FILE *f, const char *path,
|
||||||
unsigned char one[20], unsigned char two[20],
|
unsigned char one[20], unsigned char two[20],
|
||||||
|
unsigned dirty_submodule,
|
||||||
const char *del, const char *add, const char *reset)
|
const char *del, const char *add, const char *reset)
|
||||||
{
|
{
|
||||||
struct rev_info rev;
|
struct rev_info rev;
|
||||||
|
@ -85,6 +86,8 @@ void show_submodule_summary(FILE *f, const char *path,
|
||||||
if (!fast_backward && !fast_forward)
|
if (!fast_backward && !fast_forward)
|
||||||
strbuf_addch(&sb, '.');
|
strbuf_addch(&sb, '.');
|
||||||
strbuf_addf(&sb, "%s", find_unique_abbrev(two, DEFAULT_ABBREV));
|
strbuf_addf(&sb, "%s", find_unique_abbrev(two, DEFAULT_ABBREV));
|
||||||
|
if (dirty_submodule)
|
||||||
|
strbuf_add(&sb, "-dirty", 6);
|
||||||
if (message)
|
if (message)
|
||||||
strbuf_addf(&sb, " %s\n", message);
|
strbuf_addf(&sb, " %s\n", message);
|
||||||
else
|
else
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
void show_submodule_summary(FILE *f, const char *path,
|
void show_submodule_summary(FILE *f, const char *path,
|
||||||
unsigned char one[20], unsigned char two[20],
|
unsigned char one[20], unsigned char two[20],
|
||||||
|
unsigned dirty_submodule,
|
||||||
const char *del, const char *add, const char *reset);
|
const char *del, const char *add, const char *reset);
|
||||||
int is_submodule_modified(const char *path);
|
int is_submodule_modified(const char *path);
|
||||||
|
|
||||||
|
|
|
@ -191,6 +191,73 @@ EOF
|
||||||
"
|
"
|
||||||
|
|
||||||
commit_file sm1 &&
|
commit_file sm1 &&
|
||||||
|
test_expect_success 'submodule is up to date' "
|
||||||
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
|
diff actual - <<-EOF
|
||||||
|
EOF
|
||||||
|
"
|
||||||
|
|
||||||
|
test_expect_success 'submodule contains untracked content' "
|
||||||
|
echo new > sm1/new-file &&
|
||||||
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
|
diff actual - <<-EOF
|
||||||
|
Submodule sm1 $head6..$head6-dirty:
|
||||||
|
EOF
|
||||||
|
"
|
||||||
|
|
||||||
|
test_expect_success 'submodule contains untracked and modifed content' "
|
||||||
|
echo new > sm1/foo6 &&
|
||||||
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
|
diff actual - <<-EOF
|
||||||
|
Submodule sm1 $head6..$head6-dirty:
|
||||||
|
EOF
|
||||||
|
"
|
||||||
|
|
||||||
|
test_expect_success 'submodule contains modifed content' "
|
||||||
|
rm -f sm1/new-file &&
|
||||||
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
|
diff actual - <<-EOF
|
||||||
|
Submodule sm1 $head6..$head6-dirty:
|
||||||
|
EOF
|
||||||
|
"
|
||||||
|
|
||||||
|
(cd sm1; git commit -mchange foo6 >/dev/null) &&
|
||||||
|
head8=$(cd sm1; git rev-parse --verify HEAD | cut -c1-7) &&
|
||||||
|
test_expect_success 'submodule is modified' "
|
||||||
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
|
diff actual - <<-EOF
|
||||||
|
Submodule sm1 $head6..$head8:
|
||||||
|
> change
|
||||||
|
EOF
|
||||||
|
"
|
||||||
|
|
||||||
|
test_expect_success 'modified submodule contains untracked content' "
|
||||||
|
echo new > sm1/new-file &&
|
||||||
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
|
diff actual - <<-EOF
|
||||||
|
Submodule sm1 $head6..$head8-dirty:
|
||||||
|
> change
|
||||||
|
EOF
|
||||||
|
"
|
||||||
|
|
||||||
|
test_expect_success 'modified submodule contains untracked and modifed content' "
|
||||||
|
echo modification >> sm1/foo6 &&
|
||||||
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
|
diff actual - <<-EOF
|
||||||
|
Submodule sm1 $head6..$head8-dirty:
|
||||||
|
> change
|
||||||
|
EOF
|
||||||
|
"
|
||||||
|
|
||||||
|
test_expect_success 'modified submodule contains modifed content' "
|
||||||
|
rm -f sm1/new-file &&
|
||||||
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
|
diff actual - <<-EOF
|
||||||
|
Submodule sm1 $head6..$head8-dirty:
|
||||||
|
> change
|
||||||
|
EOF
|
||||||
|
"
|
||||||
|
|
||||||
rm -rf sm1
|
rm -rf sm1
|
||||||
test_expect_success 'deleted submodule' "
|
test_expect_success 'deleted submodule' "
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
|
|
Загрузка…
Ссылка в новой задаче