summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
Diffstat (limited to 'builtin')
-rw-r--r--builtin/add.c18
-rw-r--r--builtin/bisect--helper.c192
-rw-r--r--builtin/blame.c10
-rw-r--r--builtin/branch.c53
-rw-r--r--builtin/check-mailmap.c2
-rw-r--r--builtin/checkout-index.c35
-rw-r--r--builtin/checkout.c3
-rw-r--r--builtin/clean.c2
-rw-r--r--builtin/clone.c34
-rw-r--r--builtin/commit.c2
-rw-r--r--builtin/describe.c2
-rw-r--r--builtin/diff-files.c8
-rw-r--r--builtin/diff-index.c4
-rw-r--r--builtin/diff-tree.c5
-rw-r--r--builtin/diff.c12
-rw-r--r--builtin/fast-import.c8
-rw-r--r--builtin/fetch-pack.c3
-rw-r--r--builtin/fetch.c242
-rw-r--r--builtin/for-each-ref.c2
-rw-r--r--builtin/fsck.c20
-rw-r--r--builtin/gc.c91
-rw-r--r--builtin/grep.c18
-rw-r--r--builtin/index-pack.c104
-rw-r--r--builtin/init-db.c4
-rw-r--r--builtin/log.c59
-rw-r--r--builtin/ls-files.c81
-rw-r--r--builtin/ls-remote.c11
-rw-r--r--builtin/merge.c5
-rw-r--r--builtin/mktag.c235
-rw-r--r--builtin/mv.c2
-rw-r--r--builtin/name-rev.c10
-rw-r--r--builtin/notes.c22
-rw-r--r--builtin/pack-objects.c394
-rw-r--r--builtin/pack-redundant.c15
-rw-r--r--builtin/push.c2
-rw-r--r--builtin/range-diff.c30
-rw-r--r--builtin/rebase.c20
-rw-r--r--builtin/receive-pack.c18
-rw-r--r--builtin/reflog.c3
-rw-r--r--builtin/remote.c4
-rw-r--r--builtin/repack.c216
-rw-r--r--builtin/rev-list.c46
-rw-r--r--builtin/shortlog.c16
-rw-r--r--builtin/show-ref.c2
-rw-r--r--builtin/sparse-checkout.c13
-rw-r--r--builtin/stash.c66
-rw-r--r--builtin/submodule--helper.c2
-rw-r--r--builtin/tag.c64
-rw-r--r--builtin/unpack-objects.c4
-rw-r--r--builtin/worktree.c110
50 files changed, 1605 insertions, 719 deletions
diff --git a/builtin/add.c b/builtin/add.c
index a825887c50..ea762a41e3 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -38,19 +38,27 @@ struct update_callback_data {
int add_errors;
};
-static void chmod_pathspec(struct pathspec *pathspec, char flip)
+static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)
{
- int i;
+ int i, ret = 0;
for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i];
+ int err;
if (pathspec && !ce_path_match(&the_index, ce, pathspec, NULL))
continue;
- if (chmod_cache_entry(ce, flip) < 0)
- fprintf(stderr, "cannot chmod %cx '%s'\n", flip, ce->name);
+ if (!show_only)
+ err = chmod_cache_entry(ce, flip);
+ else
+ err = S_ISREG(ce->ce_mode) ? 0 : -1;
+
+ if (err < 0)
+ ret = error(_("cannot chmod %cx '%s'"), flip, ce->name);
}
+
+ return ret;
}
static int fix_unmerged_status(struct diff_filepair *p,
@@ -609,7 +617,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
exit_status |= add_files(&dir, flags);
if (chmod_arg && pathspec.nr)
- chmod_pathspec(&pathspec, chmod_arg[0]);
+ exit_status |= chmod_pathspec(&pathspec, chmod_arg[0], show_only);
unplug_bulk_checkin();
finish:
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index 709eb713a3..1fdb7d9d10 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -21,16 +21,15 @@ static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT")
static const char * const git_bisect_helper_usage[] = {
N_("git bisect--helper --bisect-reset [<commit>]"),
- N_("git bisect--helper --bisect-write [--no-log] <state> <revision> <good_term> <bad_term>"),
- N_("git bisect--helper --bisect-check-and-set-terms <command> <good_term> <bad_term>"),
N_("git bisect--helper --bisect-next-check <good_term> <bad_term> [<term>]"),
N_("git bisect--helper --bisect-terms [--term-good | --term-old | --term-bad | --term-new]"),
N_("git bisect--helper --bisect-start [--term-{new,bad}=<term> --term-{old,good}=<term>]"
" [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<paths>...]"),
N_("git bisect--helper --bisect-next"),
- N_("git bisect--helper --bisect-auto-next"),
N_("git bisect--helper --bisect-state (bad|new) [<rev>]"),
N_("git bisect--helper --bisect-state (good|old) [<rev>...]"),
+ N_("git bisect--helper --bisect-replay <filename>"),
+ N_("git bisect--helper --bisect-skip [(<rev>|<range>)...]"),
NULL
};
@@ -875,12 +874,19 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, const char **a
*/
for (; argc; argc--, argv++) {
+ struct commit *commit;
+
if (get_oid(*argv, &oid)){
error(_("Bad rev input: %s"), *argv);
oid_array_clear(&revs);
return BISECT_FAILED;
}
- oid_array_append(&revs, &oid);
+
+ commit = lookup_commit_reference(the_repository, &oid);
+ if (!commit)
+ die(_("Bad rev input (not a commit): %s"), *argv);
+
+ oid_array_append(&revs, &commit->object.oid);
}
if (strbuf_read_file(&buf, git_path_bisect_expected_rev(), 0) < the_hash_algo->hexsz ||
@@ -904,28 +910,148 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, const char **a
return bisect_auto_next(terms, NULL);
}
+static enum bisect_error bisect_log(void)
+{
+ int fd, status;
+ const char* filename = git_path_bisect_log();
+
+ if (is_empty_or_missing_file(filename))
+ return error(_("We are not bisecting."));
+
+ fd = open(filename, O_RDONLY);
+ if (fd < 0)
+ return BISECT_FAILED;
+
+ status = copy_fd(fd, STDOUT_FILENO);
+ close(fd);
+ return status ? BISECT_FAILED : BISECT_OK;
+}
+
+static int process_replay_line(struct bisect_terms *terms, struct strbuf *line)
+{
+ const char *p = line->buf + strspn(line->buf, " \t");
+ char *word_end, *rev;
+
+ if ((!skip_prefix(p, "git bisect", &p) &&
+ !skip_prefix(p, "git-bisect", &p)) || !isspace(*p))
+ return 0;
+ p += strspn(p, " \t");
+
+ word_end = (char *)p + strcspn(p, " \t");
+ rev = word_end + strspn(word_end, " \t");
+ *word_end = '\0'; /* NUL-terminate the word */
+
+ get_terms(terms);
+ if (check_and_set_terms(terms, p))
+ return -1;
+
+ if (!strcmp(p, "start")) {
+ struct strvec argv = STRVEC_INIT;
+ int res;
+ sq_dequote_to_strvec(rev, &argv);
+ res = bisect_start(terms, argv.v, argv.nr);
+ strvec_clear(&argv);
+ return res;
+ }
+
+ if (one_of(p, terms->term_good,
+ terms->term_bad, "skip", NULL))
+ return bisect_write(p, rev, terms, 0);
+
+ if (!strcmp(p, "terms")) {
+ struct strvec argv = STRVEC_INIT;
+ int res;
+ sq_dequote_to_strvec(rev, &argv);
+ res = bisect_terms(terms, argv.nr == 1 ? argv.v[0] : NULL);
+ strvec_clear(&argv);
+ return res;
+ }
+ error(_("'%s'?? what are you talking about?"), p);
+
+ return -1;
+}
+
+static enum bisect_error bisect_replay(struct bisect_terms *terms, const char *filename)
+{
+ FILE *fp = NULL;
+ enum bisect_error res = BISECT_OK;
+ struct strbuf line = STRBUF_INIT;
+
+ if (is_empty_or_missing_file(filename))
+ return error(_("cannot read file '%s' for replaying"), filename);
+
+ if (bisect_reset(NULL))
+ return BISECT_FAILED;
+
+ fp = fopen(filename, "r");
+ if (!fp)
+ return BISECT_FAILED;
+
+ while ((strbuf_getline(&line, fp) != EOF) && !res)
+ res = process_replay_line(terms, &line);
+
+ strbuf_release(&line);
+ fclose(fp);
+
+ if (res)
+ return BISECT_FAILED;
+
+ return bisect_auto_next(terms, NULL);
+}
+
+static enum bisect_error bisect_skip(struct bisect_terms *terms, const char **argv, int argc)
+{
+ int i;
+ enum bisect_error res;
+ struct strvec argv_state = STRVEC_INIT;
+
+ strvec_push(&argv_state, "skip");
+
+ for (i = 0; i < argc; i++) {
+ const char *dotdot = strstr(argv[i], "..");
+
+ if (dotdot) {
+ struct rev_info revs;
+ struct commit *commit;
+
+ init_revisions(&revs, NULL);
+ setup_revisions(2, argv + i - 1, &revs, NULL);
+
+ if (prepare_revision_walk(&revs))
+ die(_("revision walk setup failed\n"));
+ while ((commit = get_revision(&revs)) != NULL)
+ strvec_push(&argv_state,
+ oid_to_hex(&commit->object.oid));
+
+ reset_revision_walk();
+ } else {
+ strvec_push(&argv_state, argv[i]);
+ }
+ }
+ res = bisect_state(terms, argv_state.v, argv_state.nr);
+
+ strvec_clear(&argv_state);
+ return res;
+}
+
int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
{
enum {
BISECT_RESET = 1,
- BISECT_WRITE,
- CHECK_AND_SET_TERMS,
BISECT_NEXT_CHECK,
BISECT_TERMS,
BISECT_START,
BISECT_AUTOSTART,
BISECT_NEXT,
- BISECT_AUTO_NEXT,
- BISECT_STATE
+ BISECT_STATE,
+ BISECT_LOG,
+ BISECT_REPLAY,
+ BISECT_SKIP
} cmdmode = 0;
int res = 0, nolog = 0;
struct option options[] = {
OPT_CMDMODE(0, "bisect-reset", &cmdmode,
N_("reset the bisection state"), BISECT_RESET),
- OPT_CMDMODE(0, "bisect-write", &cmdmode,
- N_("write out the bisection state in BISECT_LOG"), BISECT_WRITE),
- OPT_CMDMODE(0, "check-and-set-terms", &cmdmode,
- N_("check and set terms in a bisection state"), CHECK_AND_SET_TERMS),
OPT_CMDMODE(0, "bisect-next-check", &cmdmode,
N_("check whether bad or good terms exist"), BISECT_NEXT_CHECK),
OPT_CMDMODE(0, "bisect-terms", &cmdmode,
@@ -934,10 +1060,14 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
N_("start the bisect session"), BISECT_START),
OPT_CMDMODE(0, "bisect-next", &cmdmode,
N_("find the next bisection commit"), BISECT_NEXT),
- OPT_CMDMODE(0, "bisect-auto-next", &cmdmode,
- N_("verify the next bisection state then checkout the next bisection commit"), BISECT_AUTO_NEXT),
OPT_CMDMODE(0, "bisect-state", &cmdmode,
N_("mark the state of ref (or refs)"), BISECT_STATE),
+ OPT_CMDMODE(0, "bisect-log", &cmdmode,
+ N_("list the bisection steps so far"), BISECT_LOG),
+ OPT_CMDMODE(0, "bisect-replay", &cmdmode,
+ N_("replay the bisection process from the given file"), BISECT_REPLAY),
+ OPT_CMDMODE(0, "bisect-skip", &cmdmode,
+ N_("skip some commits for checkout"), BISECT_SKIP),
OPT_BOOL(0, "no-log", &nolog,
N_("no log for BISECT_WRITE")),
OPT_END()
@@ -955,18 +1085,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
case BISECT_RESET:
if (argc > 1)
return error(_("--bisect-reset requires either no argument or a commit"));
- return !!bisect_reset(argc ? argv[0] : NULL);
- case BISECT_WRITE:
- if (argc != 4 && argc != 5)
- return error(_("--bisect-write requires either 4 or 5 arguments"));
- set_terms(&terms, argv[3], argv[2]);
- res = bisect_write(argv[0], argv[1], &terms, nolog);
- break;
- case CHECK_AND_SET_TERMS:
- if (argc != 3)
- return error(_("--check-and-set-terms requires 3 arguments"));
- set_terms(&terms, argv[2], argv[1]);
- res = check_and_set_terms(&terms, argv[0]);
+ res = bisect_reset(argc ? argv[0] : NULL);
break;
case BISECT_NEXT_CHECK:
if (argc != 2 && argc != 3)
@@ -989,17 +1108,26 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
get_terms(&terms);
res = bisect_next(&terms, prefix);
break;
- case BISECT_AUTO_NEXT:
- if (argc)
- return error(_("--bisect-auto-next requires 0 arguments"));
- get_terms(&terms);
- res = bisect_auto_next(&terms, prefix);
- break;
case BISECT_STATE:
set_terms(&terms, "bad", "good");
get_terms(&terms);
res = bisect_state(&terms, argv, argc);
break;
+ case BISECT_LOG:
+ if (argc)
+ return error(_("--bisect-log requires 0 arguments"));
+ res = bisect_log();
+ break;
+ case BISECT_REPLAY:
+ if (argc != 1)
+ return error(_("no logfile given"));
+ set_terms(&terms, "bad", "good");
+ res = bisect_replay(&terms, argv[0]);
+ break;
+ case BISECT_SKIP:
+ set_terms(&terms, "bad", "good");
+ res = bisect_skip(&terms, argv, argc);
+ break;
default:
BUG("unknown subcommand %d", cmdmode);
}
diff --git a/builtin/blame.c b/builtin/blame.c
index 2c1c02c455..641523ff9a 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -425,13 +425,11 @@ static void setup_default_color_by_age(void)
parse_color_fields("blue,12 month ago,white,1 month ago,red");
}
-static void determine_line_heat(struct blame_entry *ent, const char **dest_color)
+static void determine_line_heat(struct commit_info *ci, const char **dest_color)
{
int i = 0;
- struct commit_info ci;
- get_commit_info(ent->suspect->commit, &ci, 1);
- while (i < colorfield_nr && ci.author_time > colorfield[i].hop)
+ while (i < colorfield_nr && ci->author_time > colorfield[i].hop)
i++;
*dest_color = colorfield[i].col;
@@ -453,7 +451,7 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int
cp = blame_nth_line(sb, ent->lno);
if (opt & OUTPUT_SHOW_AGE_WITH_COLOR) {
- determine_line_heat(ent, &default_color);
+ determine_line_heat(&ci, &default_color);
color = default_color;
reset = GIT_COLOR_RESET;
}
@@ -1151,7 +1149,7 @@ parse_done:
sb.xdl_opts = xdl_opts;
sb.no_whole_file_rename = no_whole_file_rename;
- read_mailmap(&mailmap, NULL);
+ read_mailmap(&mailmap);
sb.found_guilty_entry = &found_guilty_entry;
sb.found_guilty_entry_data = &pi;
diff --git a/builtin/branch.c b/builtin/branch.c
index 9b68591add..bcc00bcf18 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -202,6 +202,9 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
int remote_branch = 0;
struct strbuf bname = STRBUF_INIT;
unsigned allowed_interpret;
+ struct string_list refs_to_delete = STRING_LIST_INIT_DUP;
+ struct string_list_item *item;
+ int branch_name_pos;
switch (kinds) {
case FILTER_REFS_REMOTES:
@@ -219,6 +222,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
default:
die(_("cannot use -a with -d"));
}
+ branch_name_pos = strcspn(fmt, "%");
if (!force) {
head_rev = lookup_commit_reference(the_repository, &head_oid);
@@ -265,30 +269,35 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
goto next;
}
- if (delete_ref(NULL, name, is_null_oid(&oid) ? NULL : &oid,
- REF_NO_DEREF)) {
- error(remote_branch
- ? _("Error deleting remote-tracking branch '%s'")
- : _("Error deleting branch '%s'"),
- bname.buf);
- ret = 1;
- goto next;
- }
- if (!quiet) {
- printf(remote_branch
- ? _("Deleted remote-tracking branch %s (was %s).\n")
- : _("Deleted branch %s (was %s).\n"),
- bname.buf,
- (flags & REF_ISBROKEN) ? "broken"
- : (flags & REF_ISSYMREF) ? target
- : find_unique_abbrev(&oid, DEFAULT_ABBREV));
- }
- delete_branch_config(bname.buf);
+ item = string_list_append(&refs_to_delete, name);
+ item->util = xstrdup((flags & REF_ISBROKEN) ? "broken"
+ : (flags & REF_ISSYMREF) ? target
+ : find_unique_abbrev(&oid, DEFAULT_ABBREV));
next:
free(target);
}
+ if (delete_refs(NULL, &refs_to_delete, REF_NO_DEREF))
+ ret = 1;
+
+ for_each_string_list_item(item, &refs_to_delete) {
+ char *describe_ref = item->util;
+ char *name = item->string;
+ if (!ref_exists(name)) {
+ char *refname = name + branch_name_pos;
+ if (!quiet)
+ printf(remote_branch
+ ? _("Deleted remote-tracking branch %s (was %s).\n")
+ : _("Deleted branch %s (was %s).\n"),
+ name + branch_name_pos, describe_ref);
+
+ delete_branch_config(refname);
+ }
+ free(describe_ref);
+ }
+ string_list_clear(&refs_to_delete, 0);
+
free(name);
strbuf_release(&bname);
@@ -726,7 +735,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
print_current_branch_name();
return 0;
} else if (list) {
- /* git branch --local also shows HEAD when it is detached */
+ /* git branch --list also shows HEAD when it is detached */
if ((filter.kind & FILTER_REFS_BRANCHES) && filter.detached)
filter.kind |= FILTER_REFS_DETACHED_HEAD;
filter.name_patterns = argv;
@@ -739,7 +748,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
*/
if (!sorting)
sorting = ref_default_sorting();
- ref_sorting_icase_all(sorting, icase);
+ ref_sorting_set_sort_flags_all(sorting, REF_SORTING_ICASE, icase);
+ ref_sorting_set_sort_flags_all(
+ sorting, REF_SORTING_DETACHED_HEAD_FIRST, 1);
print_ref_list(&filter, sorting, &format);
print_columns(&output, colopts, NULL);
string_list_clear(&output, 0);
diff --git a/builtin/check-mailmap.c b/builtin/check-mailmap.c
index cdce144f3b..7dc47e4793 100644
--- a/builtin/check-mailmap.c
+++ b/builtin/check-mailmap.c
@@ -47,7 +47,7 @@ int cmd_check_mailmap(int argc, const char **argv, const char *prefix)
if (argc == 0 && !use_stdin)
die(_("no contacts specified"));
- read_mailmap(&mailmap, NULL);
+ read_mailmap(&mailmap);
for (i = 0; i < argc; ++i)
check_mailmap(&mailmap, argv[i]);
diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c
index 4bbfc92dce..023e49e271 100644
--- a/builtin/checkout-index.c
+++ b/builtin/checkout-index.c
@@ -23,22 +23,35 @@ static struct checkout state = CHECKOUT_INIT;
static void write_tempfile_record(const char *name, const char *prefix)
{
int i;
+ int have_tempname = 0;
if (CHECKOUT_ALL == checkout_stage) {
- for (i = 1; i < 4; i++) {
- if (i > 1)
- putchar(' ');
- if (topath[i][0])
- fputs(topath[i], stdout);
- else
- putchar('.');
+ for (i = 1; i < 4; i++)
+ if (topath[i][0]) {
+ have_tempname = 1;
+ break;
+ }
+
+ if (have_tempname) {
+ for (i = 1; i < 4; i++) {
+ if (i > 1)
+ putchar(' ');
+ if (topath[i][0])
+ fputs(topath[i], stdout);
+ else
+ putchar('.');
+ }
}
- } else
+ } else if (topath[checkout_stage][0]) {
+ have_tempname = 1;
fputs(topath[checkout_stage], stdout);
+ }
- putchar('\t');
- write_name_quoted_relative(name, prefix, stdout,
- nul_term_line ? '\0' : '\n');
+ if (have_tempname) {
+ putchar('\t');
+ write_name_quoted_relative(name, prefix, stdout,
+ nul_term_line ? '\0' : '\n');
+ }
for (i = 0; i < 4; i++) {
topath[i][0] = 0;
diff --git a/builtin/checkout.c b/builtin/checkout.c
index c9ba23c279..2d6550bc3c 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -821,9 +821,6 @@ static int merge_working_tree(const struct checkout_opts *opts,
}
}
- if (!active_cache_tree)
- active_cache_tree = cache_tree();
-
if (!cache_tree_fully_valid(active_cache_tree))
cache_tree_update(&the_index, WRITE_TREE_SILENT | WRITE_TREE_REPAIR);
diff --git a/builtin/clean.c b/builtin/clean.c
index 687ab473c2..995053b791 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -623,7 +623,7 @@ static int *list_and_choose(struct menu_opts *opts, struct menu_stuff *stuff)
nr += chosen[i];
}
- result = xcalloc(st_add(nr, 1), sizeof(int));
+ CALLOC_ARRAY(result, st_add(nr, 1));
for (i = 0; i < stuff->nr && j < nr; i++) {
if (chosen[i])
result[j++] = i;
diff --git a/builtin/clone.c b/builtin/clone.c
index e335734b4c..51e844a2de 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -979,7 +979,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
int err = 0, complete_refs_before_fetch = 1;
int submodule_progress;
- struct strvec ref_prefixes = STRVEC_INIT;
+ struct transport_ls_refs_options transport_ls_refs_options =
+ TRANSPORT_LS_REFS_OPTIONS_INIT;
packet_trace_identity("clone");
@@ -1257,14 +1258,17 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
transport->smart_options->check_self_contained_and_connected = 1;
- strvec_push(&ref_prefixes, "HEAD");
- refspec_ref_prefixes(&remote->fetch, &ref_prefixes);
+ strvec_push(&transport_ls_refs_options.ref_prefixes, "HEAD");
+ refspec_ref_prefixes(&remote->fetch,
+ &transport_ls_refs_options.ref_prefixes);
if (option_branch)
- expand_ref_prefix(&ref_prefixes, option_branch);
+ expand_ref_prefix(&transport_ls_refs_options.ref_prefixes,
+ option_branch);
if (!option_no_tags)
- strvec_push(&ref_prefixes, "refs/tags/");
+ strvec_push(&transport_ls_refs_options.ref_prefixes,
+ "refs/tags/");
- refs = transport_get_remote_refs(transport, &ref_prefixes);
+ refs = transport_get_remote_refs(transport, &transport_ls_refs_options);
if (refs) {
int hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));
@@ -1326,8 +1330,19 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
remote_head = NULL;
option_no_checkout = 1;
if (!option_bare) {
- const char *branch = git_default_branch_name(0);
- char *ref = xstrfmt("refs/heads/%s", branch);
+ const char *branch;
+ char *ref;
+
+ if (transport_ls_refs_options.unborn_head_target &&
+ skip_prefix(transport_ls_refs_options.unborn_head_target,
+ "refs/heads/", &branch)) {
+ ref = transport_ls_refs_options.unborn_head_target;
+ transport_ls_refs_options.unborn_head_target = NULL;
+ create_symref("HEAD", ref, reflog_msg.buf);
+ } else {
+ branch = git_default_branch_name(0);
+ ref = xstrfmt("refs/heads/%s", branch);
+ }
install_branch_config(0, branch, remote_name, ref);
free(ref);
@@ -1380,6 +1395,7 @@ cleanup:
strbuf_release(&key);
junk_mode = JUNK_LEAVE_ALL;
- strvec_clear(&ref_prefixes);
+ strvec_clear(&transport_ls_refs_options.ref_prefixes);
+ free(transport_ls_refs_options.unborn_head_target);
return err;
}
diff --git a/builtin/commit.c b/builtin/commit.c
index 505fe60956..739110c5a7 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1039,7 +1039,7 @@ static const char *find_author_by_nickname(const char *name)
av[++ac] = NULL;
setup_revisions(ac, av, &revs, NULL);
revs.mailmap = &mailmap;
- read_mailmap(revs.mailmap, NULL);
+ read_mailmap(revs.mailmap);
if (prepare_revision_walk(&revs))
die(_("revision walk setup failed"));
diff --git a/builtin/describe.c b/builtin/describe.c
index 7668591d57..40482d8e9f 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -194,7 +194,7 @@ static int get_name(const char *path, const struct object_id *oid, int flag, voi
}
/* Is it annotated? */
- if (!peel_ref(path, &peeled)) {
+ if (!peel_iterated_oid(oid, &peeled)) {
is_annotated = !oideq(oid, &peeled);
} else {
oidcpy(&peeled, oid);
diff --git a/builtin/diff-files.c b/builtin/diff-files.c
index 1e352dd8f7..70103c4095 100644
--- a/builtin/diff-files.c
+++ b/builtin/diff-files.c
@@ -7,6 +7,7 @@
#include "cache.h"
#include "config.h"
#include "diff.h"
+#include "diff-merges.h"
#include "commit.h"
#include "revision.h"
#include "builtin.h"
@@ -35,7 +36,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
*/
rev.diffopt.ita_invisible_in_index = 1;
- precompose_argv(argc, argv);