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

Re: Minor cosmetic defect in git-pack-objects output

From
Antonio Ospite <ospite@studenti.unina.it>
Date
Mar 29, 2011, 20:48 UTC
Message-ID
<20110329224834.62393f3c.ospite@studenti.unina.it>
In-Reply-To
<4D923D59.3070301@lsrfire.ath.cx>

On Tue, 29 Mar 2011 22:13:13 +0200 René Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:

Show 32 quoted lines
> Am 29.03.2011 12:10, schrieb Antonio Ospite:
> > Hi,
> > 
> > in some cases, on git-pack-objects failure, there is a small defect in
> > the output, see:
> > 
> > # git gc --aggressive
> > Counting objects: 1954118, done.
> > Delta compression using up to 2 threads.
> > warning: suboptimal pack - out of memory02)
> > Compressing objects: 100% (1936802/1936802), done.
> > Writing objects: 100% (1954118/1954118), done.
> > Total 1954118 (delta 1618716), reused 0 (delta 0)
> > 
> > The defect is here:
> > warning: suboptimal pack - out of memory02)
> >                                          ^^^
> > the trailing chars are from the replaced line which was ending in
> > 1936802)
> > 
> > AFAICS this is basically what is happening:
> > #include "git-compat-util.h"
> > fprintf(stderr, "Compressing objects:  15% (296661/1936802)\r");
> >                   warning("suboptimal pack - out of memory");
> > 
> > I can think to a dumb workaround for this particular path but maybe
> > there are other places when this can happen as well.
> 
> The following patch should avoid it by clearing the the rest of the
> line after warnings, error messages, usage notes etc. if stderr is a
> terminal.
>

Cool, this is working indeed on the terminal, I don't know if introducing a CLEARLINE macro would look prettier.

Thanks René.
Regards,
   Antonio
Show 21 quoted lines
> René
> 
> ---
>  usage.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/usage.c b/usage.c
> index b5e67e3..36f1968 100644
> --- a/usage.c
> +++ b/usage.c
> @@ -9,7 +9,7 @@ void vreportf(const char *prefix, const char *err, va_list params)
>  {
>  	char msg[4096];
>  	vsnprintf(msg, sizeof(msg), err, params);
> -	fprintf(stderr, "%s%s\n", prefix, msg);
> +	fprintf(stderr, "%s%s%s\n", prefix, msg, isatty(2) ? "\033[K" : "");
>  }
>  
>  static NORETURN void usage_builtin(const char *err, va_list params)
> 
> 
-- 
Antonio Ospite
http://ao2.it

PGP public key ID: 0x4553B001

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
Previous: René Scharfe
Message 3 of 3 in “Minor cosmetic defect in git-pack-objects output”
  1. Antonio OspiteMar 29, 2011
  2. René ScharfeMar 29, 2011
  3. Antonio OspiteMar 29, 2011

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.