Re: [RFC] Silent File Mods Being Committed
Jon Loeliger <jdl@jdl.com> writes:
Show 13 quoted lines
> However, 'git status' didn't show that output....
>
> And that is because it is driven by the diffcore instead!
> So I _think_ diff_resolve_rename_copy() has to be consulted
> to get that DIFF_STATUS_MODIFIED indicator. Except that it is
> shared with the SHA1 compare too:
>
> else if (memcmp(p->one->sha1, p->two->sha1, 20) ||
> p->one->mode != p->two->mode)
> p->status = DIFF_STATUS_MODIFIED;
>
> But I haven't tracked it back to see how to propagate that
> status back up to show_modified() in diff-files.c yet...
I think the cleanest way would be either
(1) define another output format to diffcore similar to
--name-status, let that format perform most of what
DIFF_FORMAT_NAME_STATUS does, and update
diff.c:diff_flush_raw() to show the mode change as M+ (old
was not executable but new is) or M- (the other way); or (2) audit all the scripts to make sure they do not get upset if
we add trailing +/- to the status letter, and do that
unconditionally, like the attached patch does.If you go the latter route, you would get something like this:
$ ./git-diff-files --abbrev
:100644 100755 c0548ee... 0000000... M+ diff.c
$ ./git-diff-files --name-status
M+ diff.c---
diff --git a/diff.c b/diff.c
index c0548ee..09b8f7e 100644
--- a/diff.c
+++ b/diff.c
@@ -1034,6 +1034,10 @@ static void diff_flush_raw(struct diff_f
status[0] = p->status;
status[1] = 0;
}
+
+ if (p->one->mode && p->two->mode && p->one->mode != p->two->mode)
+ strcat(status, (p->two->mode & 01) ? "+" : "-");
+
switch (p->status) {
case DIFF_STATUS_COPIED:
case DIFF_STATUS_RENAMED: