aboutsummaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-01-16 18:42:53 +0100
committerJunio C Hamano <gitster@pobox.com>2010-01-16 16:40:56 -0800
commit8e08b4198c40cd6d3a5d1a7e60a599adabece08e (patch)
treebb1809acf909c66a5632185c1cddb7ac83517d45 /diff.c
parentee6fc514f2df821c2719cc49499a56ef2fb136b0 (diff)
downloadgit-8e08b4198c40cd6d3a5d1a7e60a599adabece08e.tar.gz
git-8e08b4198c40cd6d3a5d1a7e60a599adabece08e.tar.xz
Teach diff that modified submodule directory is dirty
A diff run in superproject only compares the name of the commit object bound at the submodule paths. When we compare with a work tree and the checked out submodule directory is dirty (e.g. has either staged or unstaged changes, or has new files the user forgot to add to the index), show the work tree side as "dirty". Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/diff.c b/diff.c
index 04beb26a6..750c066a5 100644
--- a/diff.c
+++ b/diff.c
@@ -2029,9 +2029,14 @@ static int populate_from_stdin(struct diff_filespec *s)
static int diff_populate_gitlink(struct diff_filespec *s, int size_only)
{
int len;
- char *data = xmalloc(100);
+ char *data = xmalloc(100), *dirty = "";
+
+ /* Are we looking at the work tree? */
+ if (!s->sha1_valid && is_submodule_modified(s->path))
+ dirty = "-dirty";
+
len = snprintf(data, 100,
- "Subproject commit %s\n", sha1_to_hex(s->sha1));
+ "Subproject commit %s%s\n", sha1_to_hex(s->sha1), dirty);
s->data = data;
s->size = len;
s->should_free = 1;