Re: [PATCH] git-diff: Output a warning about stale files in the index
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:27
Steven Grimm [off-list ref] writes:
Signed-off-by: Steven Grimm <redacted> --- This is based on (and includes) Junio's patch. This should hopefully address the "I want to know when my index is very stale" problem with both his original patch and mine. If we are running a pager, I output the warning to standard output so it doesn't get immediately scrolled off the screen by the paged diff output. Otherwise I output to standard error which is really the more appropriate place for the warning. Obviously that is no good if the user is running his own pager, but I'm not sure how to detect that and not cause problems for diffs that are piped into other programs.
Hmph. One way to avoid causing problems for diffs that are
piped into other programs and still give the "index of sync"
warning is to emit "diff --git" line and no patch body fot
textual diffs, or 0{40} SHA-1 on the right hand side for --raw
format diffs.
Jokes aside...
For textual diffs, I think we can always spit out the warning
message at the beginning of at the end on the standard output
without harming any of the patch based toolchain.
So how about...
- If and only if the output format asks for textual diff
(DIFF_FORMAT_PATCH), we do this "stat-dirty-removal";
otherwise we do not spend extra cycles and keep the current
behaviour.
- At the end of patch text, show "stat-dirty-removal" warning
on stdout.