From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Carlos Martín Nieto" <cmn@elego.de>, git@vger.kernel.org
Subject: [PATCH 4/4] refresh_index: notice typechanges in output
Date: Mon, 14 Nov 2011 17:56:51 -0500 [thread overview]
Message-ID: <20111114225651.GD3993@sigill.intra.peff.net> (raw)
In-Reply-To: <20111114225056.GA27370@sigill.intra.peff.net>
If a file changes type and a porcelain updates the index, we
will print "M file". Instead, let's be more specific and
print "T file", which matches actual diff and status output.
The plumbing version remains "needs update" for historical
compatibility.
Signed-off-by: Jeff King <peff@peff.net>
---
The "changed" flag comes from refresh_cache_ent, which in turn gets it
from ie_modified_stat. The one hesitation I have is that intent-to-add
entries get the TYPE_CHANGED flag set, which means they will get a "T"
output. Whereas I actually think "M" is a little more sensible.
For "git reset", I'm not sure if it matters, since resetting the index
will always drop such an entry anyway. But you can see it with:
git add -N file
git add --refresh -v other
read-cache.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index 83fb19c..0e17add 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1107,14 +1107,17 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
unsigned int options = really ? CE_MATCH_IGNORE_VALID : 0;
const char *modified_fmt;
const char *deleted_fmt;
+ const char *typechange_fmt;
const char *unmerged_fmt;
modified_fmt = (in_porcelain ? "M\t%s\n" : "%s: needs update\n");
deleted_fmt = (in_porcelain ? "D\t%s\n" : "%s: needs update\n");
+ typechange_fmt = (in_porcelain ? "T\t%s\n" : "%s needs update\n");
unmerged_fmt = (in_porcelain ? "U\t%s\n" : "%s: needs merge\n");
for (i = 0; i < istate->cache_nr; i++) {
struct cache_entry *ce, *new;
int cache_errno = 0;
+ int changed = 0;
ce = istate->cache[i];
if (ignore_submodules && S_ISGITLINK(ce->ce_mode))
@@ -1135,7 +1138,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
if (pathspec && !match_pathspec(pathspec, ce->name, strlen(ce->name), 0, seen))
continue;
- new = refresh_cache_ent(istate, ce, options, &cache_errno, NULL);
+ new = refresh_cache_ent(istate, ce, options, &cache_errno, &changed);
if (new == ce)
continue;
if (!new) {
@@ -1151,6 +1154,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
if (quiet)
continue;
show_file((cache_errno == ENOENT ? deleted_fmt :
+ changed & TYPE_CHANGED ? typechange_fmt :
modified_fmt),
ce->name, in_porcelain, &first, header_msg);
has_errors = 1;
--
1.7.7.3.8.g38efa
next prev parent reply other threads:[~2011-11-14 22:56 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-07 9:43 reset reports file as modified when it's in fact deleted Carlos Martín Nieto
2011-11-07 16:26 ` Jeff King
2011-11-11 14:08 ` Carlos Martín Nieto
2011-11-11 16:43 ` Junio C Hamano
2011-11-11 18:21 ` Jeff King
2011-11-12 0:11 ` Junio C Hamano
2011-11-14 22:50 ` Jeff King
2011-11-14 22:51 ` [PATCH 1/4] refresh_index: rename format variables Jeff King
2011-11-14 22:52 ` [PATCH 2/4] refresh_index: mark deletions in porcelain output Jeff King
2011-11-14 22:52 ` [PATCH 3/4] read-cache: let refresh_cache_ent pass up changed flags Jeff King
2011-11-14 22:56 ` Jeff King [this message]
2011-11-15 0:08 ` [PATCH 4/4] refresh_index: notice typechanges in output Junio C Hamano
2011-11-15 2:05 ` Jeff King
2011-11-18 11:09 ` Jeff King
2011-11-18 11:11 ` [PATCHv2 1/3] read-cache: let refresh_cache_ent pass up changed flags Jeff King
2011-11-18 11:11 ` [PATCHv2 2/3] refresh_index: rename format variables Jeff King
2011-11-18 11:13 ` [PATCH 3/3] refresh_index: make porcelain output more specific Jeff King
2011-11-18 20:40 ` [PATCH 4/4] refresh_index: notice typechanges in output Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111114225651.GD3993@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=cmn@elego.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).