summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4d34477)
raw | patch | inline | side by side (parent: 4d34477)
author | Jens Lehmann <Jens.Lehmann@web.de> | |
Sun, 24 Jan 2010 14:09:00 +0000 (15:09 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 25 Jan 2010 05:04:31 +0000 (21:04 -0800) |
Since commit 8e08b4 git diff does append "-dirty" to the work tree side
if the working directory of a submodule contains new or modified files.
Lets do the same when the --submodule option is used.
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
if the working directory of a submodule contains new or modified files.
Lets do the same when the --submodule option is used.
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c | patch | blob | history | |
submodule.c | patch | blob | history | |
submodule.h | patch | blob | history | |
t/t4041-diff-submodule.sh | patch | blob | history |
index 160dbfd7186ebaa34764a40dc7ba7d2338244a73..0190ec6d9f295fbd92b2cd3561b29ca0d0e0af1a 100644 (file)
--- a/diff.c
+++ b/diff.c
const char *del = diff_get_color_opt(o, DIFF_FILE_OLD);
const char *add = diff_get_color_opt(o, DIFF_FILE_NEW);
show_submodule_summary(o->file, one ? one->path : two->path,
- one->sha1, two->sha1,
+ one->sha1, two->sha1, two->dirty_submodule,
del, add, reset);
return;
}
diff --git a/submodule.c b/submodule.c
index f657bee379a6bc0fc7d6bd263c32e1b7e3e61efc..ca0527fbcbdf4838a50956704148744630b65775 100644 (file)
--- a/submodule.c
+++ b/submodule.c
void show_submodule_summary(FILE *f, const char *path,
unsigned char one[20], unsigned char two[20],
+ unsigned dirty_submodule,
const char *del, const char *add, const char *reset)
{
struct rev_info rev;
if (!fast_backward && !fast_forward)
strbuf_addch(&sb, '.');
strbuf_addf(&sb, "%s", find_unique_abbrev(two, DEFAULT_ABBREV));
+ if (dirty_submodule)
+ strbuf_add(&sb, "-dirty", 6);
if (message)
strbuf_addf(&sb, " %s\n", message);
else
diff --git a/submodule.h b/submodule.h
index 0773121eb525071b45d9faec0fbf38254488c045..233696555e913d20b6a6c7c21942586c93595541 100644 (file)
--- a/submodule.h
+++ b/submodule.h
void show_submodule_summary(FILE *f, const char *path,
unsigned char one[20], unsigned char two[20],
+ unsigned dirty_submodule,
const char *del, const char *add, const char *reset);
int is_submodule_modified(const char *path);
index 5bb4fed3f5056ddb6121b68bb43234870cb0f28f..464305405ac715411b9cc5faabf55d116f0c6ec7 100755 (executable)
"
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
test_expect_success 'deleted submodule' "
git diff-index -p --submodule=log HEAD >actual &&