* [PATCH 1/4] refresh_index: rename format variables
2011-11-14 22:50 ` Jeff King
@ 2011-11-14 22:51 ` Jeff King
2011-11-14 22:52 ` [PATCH 2/4] refresh_index: mark deletions in porcelain output Jeff King
` (2 subsequent siblings)
3 siblings, 0 replies; 18+ messages in thread
From: Jeff King @ 2011-11-14 22:51 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Carlos Martín Nieto, git
When refreshing the index, for modified (or unmerged) files
we will print "needs update" (or "needs merge") for plumbing,
or a "diff --name-status"-ish line for porcelain.
The variables holding which type of message to show are
named after the plumbing messages. However, as we begin to
differentiate more cases at the porcelain level (with the
plumbing message stayin the same), that naming scheme will
become awkward.
Instead, name the variables after which case we found
(modified or unmerged), not what we will output.
Signed-off-by: Jeff King <peff@peff.net>
---
read-cache.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index 5790a91..eb3aae3 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1102,11 +1102,11 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
int first = 1;
int in_porcelain = (flags & REFRESH_IN_PORCELAIN);
unsigned int options = really ? CE_MATCH_IGNORE_VALID : 0;
- const char *needs_update_fmt;
- const char *needs_merge_fmt;
+ const char *modified_fmt;
+ const char *unmerged_fmt;
- needs_update_fmt = (in_porcelain ? "M\t%s\n" : "%s: needs update\n");
- needs_merge_fmt = (in_porcelain ? "U\t%s\n" : "%s: needs merge\n");
+ modified_fmt = (in_porcelain ? "M\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;
@@ -1122,7 +1122,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
i--;
if (allow_unmerged)
continue;
- show_file(needs_merge_fmt, ce->name, in_porcelain, &first, header_msg);
+ show_file(unmerged_fmt, ce->name, in_porcelain, &first, header_msg);
has_errors = 1;
continue;
}
@@ -1145,7 +1145,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
}
if (quiet)
continue;
- show_file(needs_update_fmt, ce->name, in_porcelain, &first, header_msg);
+ show_file(modified_fmt, ce->name, in_porcelain, &first, header_msg);
has_errors = 1;
continue;
}
--
1.7.7.3.8.g38efa
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 2/4] refresh_index: mark deletions in porcelain output
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 ` 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 ` [PATCH 4/4] refresh_index: notice typechanges in output Jeff King
3 siblings, 0 replies; 18+ messages in thread
From: Jeff King @ 2011-11-14 22:52 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Carlos Martín Nieto, git
If you have a deleted file and a porcelain refreshes the
cache, we print:
Unstaged changes after reset:
M file
This is technically correct, in that the file is modified,
but it's friendlier to the user if we further differentiate
the case of a deleted file (especially because this output
looks a lot like "diff --name-status", which would also make
the distinction).
The plumbing version stays as "needs update" for historical
compatibility.
Signed-off-by: Jeff King <peff@peff.net>
---
read-cache.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index eb3aae3..046cf7e 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1103,9 +1103,11 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
int in_porcelain = (flags & REFRESH_IN_PORCELAIN);
unsigned int options = really ? CE_MATCH_IGNORE_VALID : 0;
const char *modified_fmt;
+ const char *deleted_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");
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;
@@ -1145,7 +1147,9 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
}
if (quiet)
continue;
- show_file(modified_fmt, ce->name, in_porcelain, &first, header_msg);
+ show_file((cache_errno == ENOENT ? deleted_fmt :
+ modified_fmt),
+ ce->name, in_porcelain, &first, header_msg);
has_errors = 1;
continue;
}
--
1.7.7.3.8.g38efa
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 3/4] read-cache: let refresh_cache_ent pass up changed flags
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 ` Jeff King
2011-11-14 22:56 ` [PATCH 4/4] refresh_index: notice typechanges in output Jeff King
3 siblings, 0 replies; 18+ messages in thread
From: Jeff King @ 2011-11-14 22:52 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Carlos Martín Nieto, git
This will enable refresh_cache to differentiate more cases
of modification (such as typechange) when telling the user
what isn't fresh.
Signed-off-by: Jeff King <peff@peff.net>
---
There's only a single layer of call-stack to modify, and there's only
one other caller, so it turned out to be a pretty minor change.
read-cache.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index 046cf7e..83fb19c 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1001,7 +1001,8 @@ int add_index_entry(struct index_state *istate, struct cache_entry *ce, int opti
*/
static struct cache_entry *refresh_cache_ent(struct index_state *istate,
struct cache_entry *ce,
- unsigned int options, int *err)
+ unsigned int options, int *err,
+ int *changed_ret)
{
struct stat st;
struct cache_entry *updated;
@@ -1033,6 +1034,8 @@ int add_index_entry(struct index_state *istate, struct cache_entry *ce, int opti
}
changed = ie_match_stat(istate, ce, &st, options);
+ if (changed_ret)
+ *changed_ret = changed;
if (!changed) {
/*
* The path is unchanged. If we were told to ignore
@@ -1132,7 +1135,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);
+ new = refresh_cache_ent(istate, ce, options, &cache_errno, NULL);
if (new == ce)
continue;
if (!new) {
@@ -1161,7 +1164,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
static struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really)
{
- return refresh_cache_ent(&the_index, ce, really, NULL);
+ return refresh_cache_ent(&the_index, ce, really, NULL, NULL);
}
static int verify_hdr(struct cache_header *hdr, unsigned long size)
--
1.7.7.3.8.g38efa
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 4/4] refresh_index: notice typechanges in output
2011-11-14 22:50 ` Jeff King
` (2 preceding siblings ...)
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
2011-11-15 0:08 ` Junio C Hamano
3 siblings, 1 reply; 18+ messages in thread
From: Jeff King @ 2011-11-14 22:56 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Carlos Martín Nieto, git
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
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH 4/4] refresh_index: notice typechanges in output
2011-11-14 22:56 ` [PATCH 4/4] refresh_index: notice typechanges in output Jeff King
@ 2011-11-15 0:08 ` Junio C Hamano
2011-11-15 2:05 ` Jeff King
0 siblings, 1 reply; 18+ messages in thread
From: Junio C Hamano @ 2011-11-15 0:08 UTC (permalink / raw)
To: Jeff King; +Cc: Junio C Hamano, Carlos Martín Nieto, git
Jeff King <peff@peff.net> writes:
> 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.
I agree that we should not say that an intent-to-add entry has changed
type relative to whatever, as by definition there is nothing to compare
against. "A" that stands for "A"dd is a lot more sensible here, I would
think.
read-cache.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index 0e17add..27e9fc6 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1108,11 +1108,13 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
const char *modified_fmt;
const char *deleted_fmt;
const char *typechange_fmt;
+ const char *added_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");
+ added_fmt = (in_porcelain ? "A\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;
@@ -1142,6 +1144,8 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
if (new == ce)
continue;
if (!new) {
+ const char *fmt;
+
if (not_new && cache_errno == ENOENT)
continue;
if (really && cache_errno == EINVAL) {
@@ -1153,9 +1157,16 @@ 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),
+
+ if (cache_errno == ENOENT)
+ fmt = deleted_fmt;
+ else if (ce->ce_flags & CE_INTENT_TO_ADD)
+ fmt = added_fmt; /* must be before other checks */
+ else if (changed & TYPE_CHANGED)
+ fmt = typechange_fmt;
+ else
+ fmt = modified_fmt;
+ show_file(fmt,
ce->name, in_porcelain, &first, header_msg);
has_errors = 1;
continue;
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH 4/4] refresh_index: notice typechanges in output
2011-11-15 0:08 ` Junio C Hamano
@ 2011-11-15 2:05 ` Jeff King
2011-11-18 11:09 ` Jeff King
0 siblings, 1 reply; 18+ messages in thread
From: Jeff King @ 2011-11-15 2:05 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Carlos Martín Nieto, git
On Mon, Nov 14, 2011 at 04:08:32PM -0800, Junio C Hamano wrote:
> I agree that we should not say that an intent-to-add entry has changed
> type relative to whatever, as by definition there is nothing to compare
> against. "A" that stands for "A"dd is a lot more sensible here, I would
> think.
Yeah, that makes sense to me.
> + if (cache_errno == ENOENT)
> + fmt = deleted_fmt;
> + else if (ce->ce_flags & CE_INTENT_TO_ADD)
> + fmt = added_fmt; /* must be before other checks */
Thanks, I was trying to figure out how to tell an intent-to-add file
from the 'changed' flag, but obviously looking for the bit in the cache
entry is the right thing.
Do you want to add your patch on top, or do you want me to re-roll with
this squashed in? I can also hold the re-roll until post-release if you
want.
-Peff
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 4/4] refresh_index: notice typechanges in output
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
` (3 more replies)
0 siblings, 4 replies; 18+ messages in thread
From: Jeff King @ 2011-11-18 11:09 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Carlos Martín Nieto, git
On Mon, Nov 14, 2011 at 09:05:06PM -0500, Jeff King wrote:
> Do you want to add your patch on top, or do you want me to re-roll with
> this squashed in? I can also hold the re-roll until post-release if you
> want.
You mentioned squashing in the "what's cooking" message. Rather than
squashing just the typechange bits, how about this re-roll, which I
think is a little easier to follow:
[1/3]: read-cache: let refresh_cache_ent pass up changed flags
[2/3]: refresh_index: rename format variables
[3/3]: refresh_index: make porcelain output more specific
-Peff
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCHv2 1/3] read-cache: let refresh_cache_ent pass up changed flags
2011-11-18 11:09 ` Jeff King
@ 2011-11-18 11:11 ` Jeff King
2011-11-18 11:11 ` [PATCHv2 2/3] refresh_index: rename format variables Jeff King
` (2 subsequent siblings)
3 siblings, 0 replies; 18+ messages in thread
From: Jeff King @ 2011-11-18 11:11 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Carlos Martín Nieto, git
This will enable refresh_cache to differentiate more cases
of modification (such as typechange) when telling the user
what isn't fresh.
Signed-off-by: Jeff King <peff@peff.net>
---
Same as 3/4 from my v1 series.
read-cache.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index 5790a91..8e69ea3 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1001,7 +1001,8 @@ int add_index_entry(struct index_state *istate, struct cache_entry *ce, int opti
*/
static struct cache_entry *refresh_cache_ent(struct index_state *istate,
struct cache_entry *ce,
- unsigned int options, int *err)
+ unsigned int options, int *err,
+ int *changed_ret)
{
struct stat st;
struct cache_entry *updated;
@@ -1033,6 +1034,8 @@ int add_index_entry(struct index_state *istate, struct cache_entry *ce, int opti
}
changed = ie_match_stat(istate, ce, &st, options);
+ if (changed_ret)
+ *changed_ret = changed;
if (!changed) {
/*
* The path is unchanged. If we were told to ignore
@@ -1130,7 +1133,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);
+ new = refresh_cache_ent(istate, ce, options, &cache_errno, NULL);
if (new == ce)
continue;
if (!new) {
@@ -1157,7 +1160,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
static struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really)
{
- return refresh_cache_ent(&the_index, ce, really, NULL);
+ return refresh_cache_ent(&the_index, ce, really, NULL, NULL);
}
static int verify_hdr(struct cache_header *hdr, unsigned long size)
--
1.7.7.3.8.g38efa
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCHv2 2/3] refresh_index: rename format variables
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 ` 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
3 siblings, 0 replies; 18+ messages in thread
From: Jeff King @ 2011-11-18 11:11 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Carlos Martín Nieto, git
When refreshing the index, for modified (or unmerged) files
we will print "needs update" (or "needs merge") for plumbing,
or a "diff --name-status"-ish line for porcelain.
The variables holding which type of message to show are
named after the plumbing messages. However, as we begin to
differentiate more cases at the porcelain level (with the
plumbing message stayin the same), that naming scheme will
become awkward.
Instead, name the variables after which case we found
(modified or unmerged), not what we will output.
Signed-off-by: Jeff King <peff@peff.net>
---
Same as 1/4 from my v1 series.
read-cache.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index 8e69ea3..f19b2f1 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1105,11 +1105,11 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
int first = 1;
int in_porcelain = (flags & REFRESH_IN_PORCELAIN);
unsigned int options = really ? CE_MATCH_IGNORE_VALID : 0;
- const char *needs_update_fmt;
- const char *needs_merge_fmt;
+ const char *modified_fmt;
+ const char *unmerged_fmt;
- needs_update_fmt = (in_porcelain ? "M\t%s\n" : "%s: needs update\n");
- needs_merge_fmt = (in_porcelain ? "U\t%s\n" : "%s: needs merge\n");
+ modified_fmt = (in_porcelain ? "M\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;
@@ -1125,7 +1125,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
i--;
if (allow_unmerged)
continue;
- show_file(needs_merge_fmt, ce->name, in_porcelain, &first, header_msg);
+ show_file(unmerged_fmt, ce->name, in_porcelain, &first, header_msg);
has_errors = 1;
continue;
}
@@ -1148,7 +1148,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
}
if (quiet)
continue;
- show_file(needs_update_fmt, ce->name, in_porcelain, &first, header_msg);
+ show_file(modified_fmt, ce->name, in_porcelain, &first, header_msg);
has_errors = 1;
continue;
}
--
1.7.7.3.8.g38efa
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 3/3] refresh_index: make porcelain output more specific
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 ` Jeff King
2011-11-18 20:40 ` [PATCH 4/4] refresh_index: notice typechanges in output Junio C Hamano
3 siblings, 0 replies; 18+ messages in thread
From: Jeff King @ 2011-11-18 11:13 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Carlos Martín Nieto, git
If you have a deleted file and a porcelain refreshes the
cache, we print:
Unstaged changes after reset:
M file
This is technically correct, in that the file is modified,
but it's friendlier to the user if we further differentiate
the case of a deleted file (especially because this output
looks a lot like "diff --name-status", which would also make
the distinction).
Similarly, we can distinguish typechanges ("T") and
intent-to-add files ("A"), both of which appear as just "M"
in the current output.
The plumbing output for all cases remains "needs update" for
historical compatibility.
Signed-off-by: Jeff King <peff@peff.net>
---
This is my deletion and typechange patches squashed together with your
intent-to-add, and using an if/else series instead of the ternary
operator, as you did.
read-cache.c | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index f19b2f1..27e9fc6 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1106,13 +1106,20 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
int in_porcelain = (flags & REFRESH_IN_PORCELAIN);
unsigned int options = really ? CE_MATCH_IGNORE_VALID : 0;
const char *modified_fmt;
+ const char *deleted_fmt;
+ const char *typechange_fmt;
+ const char *added_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");
+ added_fmt = (in_porcelain ? "A\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))
@@ -1133,10 +1140,12 @@ 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) {
+ const char *fmt;
+
if (not_new && cache_errno == ENOENT)
continue;
if (really && cache_errno == EINVAL) {
@@ -1148,7 +1157,17 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
}
if (quiet)
continue;
- show_file(modified_fmt, ce->name, in_porcelain, &first, header_msg);
+
+ if (cache_errno == ENOENT)
+ fmt = deleted_fmt;
+ else if (ce->ce_flags & CE_INTENT_TO_ADD)
+ fmt = added_fmt; /* must be before other checks */
+ else if (changed & TYPE_CHANGED)
+ fmt = typechange_fmt;
+ else
+ fmt = modified_fmt;
+ show_file(fmt,
+ ce->name, in_porcelain, &first, header_msg);
has_errors = 1;
continue;
}
--
1.7.7.3.8.g38efa
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH 4/4] refresh_index: notice typechanges in output
2011-11-18 11:09 ` Jeff King
` (2 preceding siblings ...)
2011-11-18 11:13 ` [PATCH 3/3] refresh_index: make porcelain output more specific Jeff King
@ 2011-11-18 20:40 ` Junio C Hamano
3 siblings, 0 replies; 18+ messages in thread
From: Junio C Hamano @ 2011-11-18 20:40 UTC (permalink / raw)
To: Jeff King; +Cc: Carlos Martín Nieto, git
Jeff King <peff@peff.net> writes:
> On Mon, Nov 14, 2011 at 09:05:06PM -0500, Jeff King wrote:
>
>> Do you want to add your patch on top, or do you want me to re-roll with
>> this squashed in? I can also hold the re-roll until post-release if you
>> want.
>
> You mentioned squashing in the "what's cooking" message. Rather than
> squashing just the typechange bits, how about this re-roll, which I
> think is a little easier to follow:
>
> [1/3]: read-cache: let refresh_cache_ent pass up changed flags
> [2/3]: refresh_index: rename format variables
> [3/3]: refresh_index: make porcelain output more specific
Looks sensible; thanks. Will replace.
^ permalink raw reply [flat|nested] 18+ messages in thread