Re: [PATCH 3/5 v2] unpack_trees_options: update porcelain messages
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- Jun 15, 2010, 13:05 UTC
- Message-ID
- <vpqfx0ozbs5.fsf@bauges.imag.fr>
- In-Reply-To
- <1276604576-28092-4-git-send-email-diane.gasselin@ensimag.imag.fr>
Diane Gasselin <diane.gasselin@ensimag.imag.fr> writes:
Show 5 quoted lines
> - msgs.would_overwrite = malloc(sizeof(char) * 72); > + msgs.would_overwrite = malloc(sizeof(char) * 80); > sprintf((char *)msgs.would_overwrite, > - "Your local changes to '%%s' would be overwritten by %s. Aborting.", > + "Your local changes to the following files would be overwritten by %s:\n%%s",
I hate hardcoded string length (these magic 80 and 72). Can't it be stg like
const char * const msg = "Your local changes to ...."; msg.would_overwrite = malloc(strlen(msg) + strlen(cmd) + something); sprintf(msg.would_overwrite, msg, ...);
instead?
-- Matthieu Moy http://www-verimag.imag.fr/~moy/