зеркало из https://github.com/microsoft/git.git
Merge branch 'rs/cocci'
Code cleanup. * rs/cocci: use strbuf_add_unique_abbrev() for adding short hashes, part 3 remove unnecessary NULL check before free(3)
This commit is contained in:
Коммит
69e6544998
|
@ -0,0 +1,5 @@
|
||||||
|
@@
|
||||||
|
expression E;
|
||||||
|
@@
|
||||||
|
- if (E)
|
||||||
|
free(E);
|
|
@ -202,9 +202,9 @@ static void output_commit_title(struct merge_options *o, struct commit *commit)
|
||||||
strbuf_addf(&o->obuf, "virtual %s\n",
|
strbuf_addf(&o->obuf, "virtual %s\n",
|
||||||
merge_remote_util(commit)->name);
|
merge_remote_util(commit)->name);
|
||||||
else {
|
else {
|
||||||
strbuf_addf(&o->obuf, "%s ",
|
strbuf_add_unique_abbrev(&o->obuf, commit->object.oid.hash,
|
||||||
find_unique_abbrev(commit->object.oid.hash,
|
DEFAULT_ABBREV);
|
||||||
DEFAULT_ABBREV));
|
strbuf_addch(&o->obuf, ' ');
|
||||||
if (parse_commit(commit) != 0)
|
if (parse_commit(commit) != 0)
|
||||||
strbuf_addstr(&o->obuf, _("(bad commit)\n"));
|
strbuf_addstr(&o->obuf, _("(bad commit)\n"));
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -211,8 +211,7 @@ int parse_opt_passthru(const struct option *opt, const char *arg, int unset)
|
||||||
if (recreate_opt(&sb, opt, arg, unset) < 0)
|
if (recreate_opt(&sb, opt, arg, unset) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (*opt_value)
|
free(*opt_value);
|
||||||
free(*opt_value);
|
|
||||||
|
|
||||||
*opt_value = strbuf_detach(&sb, NULL);
|
*opt_value = strbuf_detach(&sb, NULL);
|
||||||
|
|
||||||
|
|
12
pretty.c
12
pretty.c
|
@ -544,15 +544,13 @@ static void add_merge_info(const struct pretty_print_context *pp,
|
||||||
strbuf_addstr(sb, "Merge:");
|
strbuf_addstr(sb, "Merge:");
|
||||||
|
|
||||||
while (parent) {
|
while (parent) {
|
||||||
struct commit *p = parent->item;
|
struct object_id *oidp = &parent->item->object.oid;
|
||||||
const char *hex = NULL;
|
strbuf_addch(sb, ' ');
|
||||||
if (pp->abbrev)
|
if (pp->abbrev)
|
||||||
hex = find_unique_abbrev(p->object.oid.hash, pp->abbrev);
|
strbuf_add_unique_abbrev(sb, oidp->hash, pp->abbrev);
|
||||||
if (!hex)
|
else
|
||||||
hex = oid_to_hex(&p->object.oid);
|
strbuf_addstr(sb, oid_to_hex(oidp));
|
||||||
parent = parent->next;
|
parent = parent->next;
|
||||||
|
|
||||||
strbuf_addf(sb, " %s", hex);
|
|
||||||
}
|
}
|
||||||
strbuf_addch(sb, '\n');
|
strbuf_addch(sb, '\n');
|
||||||
}
|
}
|
||||||
|
|
|
@ -371,10 +371,9 @@ static void show_submodule_header(FILE *f, const char *path,
|
||||||
}
|
}
|
||||||
|
|
||||||
output_header:
|
output_header:
|
||||||
strbuf_addf(&sb, "%s%sSubmodule %s %s..", line_prefix, meta, path,
|
strbuf_addf(&sb, "%s%sSubmodule %s ", line_prefix, meta, path);
|
||||||
find_unique_abbrev(one->hash, DEFAULT_ABBREV));
|
strbuf_add_unique_abbrev(&sb, one->hash, DEFAULT_ABBREV);
|
||||||
if (!fast_backward && !fast_forward)
|
strbuf_addstr(&sb, (fast_backward || fast_forward) ? ".." : "...");
|
||||||
strbuf_addch(&sb, '.');
|
|
||||||
strbuf_add_unique_abbrev(&sb, two->hash, DEFAULT_ABBREV);
|
strbuf_add_unique_abbrev(&sb, two->hash, DEFAULT_ABBREV);
|
||||||
if (message)
|
if (message)
|
||||||
strbuf_addf(&sb, " %s%s\n", message, reset);
|
strbuf_addf(&sb, " %s%s\n", message, reset);
|
||||||
|
|
10
wt-status.c
10
wt-status.c
|
@ -1110,7 +1110,6 @@ static void abbrev_sha1_in_line(struct strbuf *line)
|
||||||
split = strbuf_split_max(line, ' ', 3);
|
split = strbuf_split_max(line, ' ', 3);
|
||||||
if (split[0] && split[1]) {
|
if (split[0] && split[1]) {
|
||||||
unsigned char sha1[20];
|
unsigned char sha1[20];
|
||||||
const char *abbrev;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* strbuf_split_max left a space. Trim it and re-add
|
* strbuf_split_max left a space. Trim it and re-add
|
||||||
|
@ -1118,9 +1117,10 @@ static void abbrev_sha1_in_line(struct strbuf *line)
|
||||||
*/
|
*/
|
||||||
strbuf_trim(split[1]);
|
strbuf_trim(split[1]);
|
||||||
if (!get_sha1(split[1]->buf, sha1)) {
|
if (!get_sha1(split[1]->buf, sha1)) {
|
||||||
abbrev = find_unique_abbrev(sha1, DEFAULT_ABBREV);
|
|
||||||
strbuf_reset(split[1]);
|
strbuf_reset(split[1]);
|
||||||
strbuf_addf(split[1], "%s ", abbrev);
|
strbuf_add_unique_abbrev(split[1], sha1,
|
||||||
|
DEFAULT_ABBREV);
|
||||||
|
strbuf_addch(split[1], ' ');
|
||||||
strbuf_reset(line);
|
strbuf_reset(line);
|
||||||
for (i = 0; split[i]; i++)
|
for (i = 0; split[i]; i++)
|
||||||
strbuf_addbuf(line, split[i]);
|
strbuf_addbuf(line, split[i]);
|
||||||
|
@ -1343,10 +1343,8 @@ static char *get_branch(const struct worktree *wt, const char *path)
|
||||||
else if (starts_with(sb.buf, "refs/"))
|
else if (starts_with(sb.buf, "refs/"))
|
||||||
;
|
;
|
||||||
else if (!get_sha1_hex(sb.buf, sha1)) {
|
else if (!get_sha1_hex(sb.buf, sha1)) {
|
||||||
const char *abbrev;
|
|
||||||
abbrev = find_unique_abbrev(sha1, DEFAULT_ABBREV);
|
|
||||||
strbuf_reset(&sb);
|
strbuf_reset(&sb);
|
||||||
strbuf_addstr(&sb, abbrev);
|
strbuf_add_unique_abbrev(&sb, sha1, DEFAULT_ABBREV);
|
||||||
} else if (!strcmp(sb.buf, "detached HEAD")) /* rebase */
|
} else if (!strcmp(sb.buf, "detached HEAD")) /* rebase */
|
||||||
goto got_nothing;
|
goto got_nothing;
|
||||||
else /* bisect */
|
else /* bisect */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче