1
0
mirror of https://github.com/git/git.git synced 2025-03-28 16:53:51 +00:00

Merge branch 'jk/printf-format'

Code clean-up to avoid using a variable string that compilers may
feel untrustable as printf-style format given to write_file()
helper function.

* jk/printf-format:
  commit.c: remove print_commit_list()
  avoid using sha1_to_hex output as printf format
  walker: let walker_say take arbitrary formats
This commit is contained in:
Junio C Hamano 2016-07-19 13:22:22 -07:00
commit 96e08010ee
6 changed files with 14 additions and 20 deletions

@ -646,7 +646,10 @@ static void exit_if_skipped_commits(struct commit_list *tried,
printf("There are only 'skip'ped commits left to test.\n"
"The first %s commit could be any of:\n", term_bad);
print_commit_list(tried, "%s\n", "%s\n");
for ( ; tried; tried = tried->next)
printf("%s\n", oid_to_hex(&tried->item->object.oid));
if (bad)
printf("%s\n", oid_to_hex(bad));
printf(_("We cannot bisect more!\n"));

@ -262,7 +262,7 @@ static int add_worktree(const char *path, const char *refname,
*/
strbuf_reset(&sb);
strbuf_addf(&sb, "%s/HEAD", sb_repo.buf);
write_file(sb.buf, sha1_to_hex(null_sha1));
write_file(sb.buf, "%s", sha1_to_hex(null_sha1));
strbuf_reset(&sb);
strbuf_addf(&sb, "%s/commondir", sb_repo.buf);
write_file(sb.buf, "../..");

@ -1622,16 +1622,6 @@ struct commit_list **commit_list_append(struct commit *commit,
return &new->next;
}
void print_commit_list(struct commit_list *list,
const char *format_cur,
const char *format_last)
{
for ( ; list; list = list->next) {
const char *format = list->next ? format_cur : format_last;
printf(format, oid_to_hex(&list->item->object.oid));
}
}
const char *find_commit_header(const char *msg, const char *key, size_t *out_len)
{
int key_len = strlen(key);

@ -377,10 +377,6 @@ extern int parse_signed_commit(const struct commit *commit,
struct strbuf *message, struct strbuf *signature);
extern int remove_signature(struct strbuf *buf);
extern void print_commit_list(struct commit_list *list,
const char *format_cur,
const char *format_last);
/*
* Check the signature of the given commit. The result of the check is stored
* in sig->check_result, 'G' for a good signature, 'U' for a good signature

@ -9,10 +9,14 @@
static unsigned char current_commit_sha1[20];
void walker_say(struct walker *walker, const char *fmt, const char *hex)
void walker_say(struct walker *walker, const char *fmt, ...)
{
if (walker->get_verbosely)
fprintf(stderr, fmt, hex);
if (walker->get_verbosely) {
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
}
}
static void report_missing(const struct object *obj)

@ -19,7 +19,8 @@ struct walker {
};
/* Report what we got under get_verbosely */
void walker_say(struct walker *walker, const char *, const char *);
__attribute__((format (printf, 2, 3)))
void walker_say(struct walker *walker, const char *fmt, ...);
/* Load pull targets from stdin */
int walker_targets_stdin(char ***target, const char ***write_ref);