git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Message from git reset: confusing?

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
Aug 6, 2009, 09:42 UTC
Message-ID
<vpqprb946sk.fsf@bauges.imag.fr>
In-Reply-To
<fabb9a1e0908051125n3e125209n88a9fd86d6fa7534@mail.gmail.com>
Sverre Rabbelier <srabbelier@gmail.com> writes:
Show 7 quoted lines
> Heya,
>
> On Wed, Aug 5, 2009 at 10:42, Avery Pennarun<apenwarr@gmail.com> wrote:
>> Yes.  I think the problem is that the current output looks more like
>> an error message than a status report.
>
> Definitely.

This is my biggest issue, indeed. Actually, several things bother me (by decreasing annoyance):

1) It looks like an error message, and user can think git reset
failed.
2) It's inconsistant with the usual status display. I'd prefer an
output like "git diff --name-only" or "git status".
3) It's verbose. Junio's reply addresses this point. I'm not really
convinced that verbosity by default is a good thing, but I don't think
I can convince Junio either ;-), and I don't care that much.
So, let's address 1) and 2) only.
Show 6 quoted lines
>> I would find it very pleasant if the output looked more like the
>> output of "git checkout" (no parameters) in the no-files-specified
>> case.
>
> Perhaps instead we could get away with simply adding a header like
> 'git status' does? And perhaps change the wording some.

Just this patch would already solve 1) above mostly. At first, I wanted the message to say "reset successfull", but it's harder than it seems, since the output is printf-ed as the work is done, so one knows that reset is successful only after displaying the whole thing:

diff --git a/builtin-reset.c b/builtin-reset.c
index 5fa1789..6b16a00 100644
--- a/builtin-reset.c
+++ b/builtin-reset.c
@@ -108,6 +108,7 @@ static int update_index_refresh(int fd, struct lock_file *index_lock, int flags)
        if (read_cache() < 0)
                return error("Could not read index");
 
+       printf("Unstaged changes after reset:\n");
        result = refresh_cache(flags) ? 1 : 0;
        if (write_cache(fd, active_cache, active_nr) ||
                        commit_locked_index(index_lock))

For 2), something along the lines of:

diff --git a/read-cache.c b/read-cache.c
index 4e3e272..3a99a2b 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1075,10 +1075,13 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
        int not_new = (flags & REFRESH_IGNORE_MISSING) != 0;
        int ignore_submodules = (flags & REFRESH_IGNORE_SUBMODULES) != 0;
        unsigned int options = really ? CE_MATCH_IGNORE_VALID : 0;
-       const char *needs_update_message;
+       const char *needs_update_fmt;
+       const char *needs_merge_fmt;
 
-       needs_update_message = ((flags & REFRESH_SAY_CHANGED)
-                               ? "locally modified" : "needs update");
+       needs_update_fmt = ((flags & REFRESH_SAY_CHANGED)
+                               ? "M\t%s\n" : "%s: needs update\n");
+       needs_merge_fmt = ((flags & REFRESH_SAY_CHANGED)
+                               ? "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;
@@ -1094,7 +1097,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
                        i--;
                        if (allow_unmerged)
                                continue;
-                       printf("%s: needs merge\n", ce->name);
+                       printf(needs_merge_fmt, ce->name);
                        has_errors = 1;
                        continue;
                }
@@ -1117,7 +1120,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
                        }
                        if (quiet)
                                continue;
-                       printf("%s: %s\n", ce->name, needs_update_message);
+                       printf(needs_update_fmt, ce->name);
                        has_errors = 1;
                        continue;
                }

would do. See d14e7407b3 ("needs update" considered harmful, Sun Jul
20 00:21:38 2008) for the previous improvement on the subject. The
problem with this second patch is that it says "M" where "diff
--name-status" would say "D" for example, which is a bit strange. If
the idea of the patch is accepted, REFRESH_SAY_CHANGED should also be
renamed to reflect its new nature, to stg like
REFRESH_PORCELAIN_OUTPUT.

Any opinion? Am I going in the right direction?
-- 
Matthieu
Previous: Sverre RabbelierNext: Junio C Hamano
Message 6 of 20 in “Message from git reset: confusing?”
  1. Matthieu MoyAug 5, 2009
  2. Junio C HamanoAug 5, 2009
  3. Avery PennarunAug 5, 2009
  4. John TapsellAug 5, 2009
  5. Sverre RabbelierAug 5, 2009
  6. Matthieu MoyAug 6, 2009
  7. Junio C HamanoAug 6, 2009
  8. 1/2 Rename REFRESH_SAY_CHANGED to REFRESH_IN_PORCELAIN.Matthieu Moy, Aug 7, 2009
  9. 2/2 reset: make the output more user-friendly.Matthieu Moy, Aug 7, 2009
  10. Junio C HamanoAug 7, 2009
  11. Matthieu MoyAug 8, 2009
  12. Matthieu MoyAug 17, 2009
  13. Junio C HamanoAug 17, 2009
  14. 1/2 Rename REFRESH_SAY_CHANGED to REFRESH_IN_PORCELAIN.Matthieu Moy, Aug 21, 2009
  15. 2/2 reset: make the output more user-friendly.Matthieu Moy, Aug 21, 2009
  16. Junio C HamanoAug 22, 2009
  17. Matthieu MoyAug 22, 2009
  18. Junio C HamanoAug 23, 2009
  19. Matthieu MoyAug 23, 2009
  20. Reece DunnAug 23, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.