From: Junio C Hamano Date: Mon, 19 Dec 2016 22:45:31 +0000 (-0800) Subject: Merge branch 'sb/unpack-trees-grammofix' X-Git-Tag: v2.12.0-rc0~140 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/0f30315ba15f792fac6f901ca486900a74fdb86d?hp=-c Merge branch 'sb/unpack-trees-grammofix' * sb/unpack-trees-grammofix: unpack-trees: fix grammar for untracked files in directories --- 0f30315ba15f792fac6f901ca486900a74fdb86d diff --combined t/t7609-merge-co-error-msgs.sh index f80bdb81e1,85cd971f24..e90413204e --- a/t/t7609-merge-co-error-msgs.sh +++ b/t/t7609-merge-co-error-msgs.sh @@@ -31,7 -31,7 +31,7 @@@ error: The following untracked working four three two -Please move or remove them before you can merge. +Please move or remove them before you merge. Aborting EOF @@@ -53,10 -53,10 +53,10 @@@ error: Your local changes to the follow four three two -Please commit your changes or stash them before you can merge. +Please commit your changes or stash them before you merge. error: The following untracked working tree files would be overwritten by merge: five -Please move or remove them before you can merge. +Please move or remove them before you merge. Aborting EOF @@@ -72,7 -72,7 +72,7 @@@ cat >expect <<\EO error: Your local changes to the following files would be overwritten by checkout: rep/one rep/two -Please commit your changes or stash them before you can switch branches. +Please commit your changes or stash them before you switch branches. Aborting EOF @@@ -94,7 -94,7 +94,7 @@@ cat >expect <<\EO error: Your local changes to the following files would be overwritten by checkout: rep/one rep/two -Please commit your changes or stash them before you can switch branches. +Please commit your changes or stash them before you switch branches. Aborting EOF @@@ -105,7 -105,7 +105,7 @@@ test_expect_success 'not uptodate file ' cat >expect <<\EOF - error: Updating the following directories would lose untracked files in it: + error: Updating the following directories would lose untracked files in them: rep rep2 diff --combined unpack-trees.c index ea6bdd20e0,129a3547dc..7a6df99d10 --- a/unpack-trees.c +++ b/unpack-trees.c @@@ -62,55 -62,55 +62,55 @@@ void setup_unpack_trees_porcelain(struc if (!strcmp(cmd, "checkout")) msg = advice_commit_before_merge ? _("Your local changes to the following files would be overwritten by checkout:\n%%s" - "Please commit your changes or stash them before you can switch branches.") + "Please commit your changes or stash them before you switch branches.") : _("Your local changes to the following files would be overwritten by checkout:\n%%s"); else if (!strcmp(cmd, "merge")) msg = advice_commit_before_merge ? _("Your local changes to the following files would be overwritten by merge:\n%%s" - "Please commit your changes or stash them before you can merge.") + "Please commit your changes or stash them before you merge.") : _("Your local changes to the following files would be overwritten by merge:\n%%s"); else msg = advice_commit_before_merge ? _("Your local changes to the following files would be overwritten by %s:\n%%s" - "Please commit your changes or stash them before you can %s.") + "Please commit your changes or stash them before you %s.") : _("Your local changes to the following files would be overwritten by %s:\n%%s"); msgs[ERROR_WOULD_OVERWRITE] = msgs[ERROR_NOT_UPTODATE_FILE] = xstrfmt(msg, cmd, cmd); msgs[ERROR_NOT_UPTODATE_DIR] = - _("Updating the following directories would lose untracked files in it:\n%s"); + _("Updating the following directories would lose untracked files in them:\n%s"); if (!strcmp(cmd, "checkout")) msg = advice_commit_before_merge ? _("The following untracked working tree files would be removed by checkout:\n%%s" - "Please move or remove them before you can switch branches.") + "Please move or remove them before you switch branches.") : _("The following untracked working tree files would be removed by checkout:\n%%s"); else if (!strcmp(cmd, "merge")) msg = advice_commit_before_merge ? _("The following untracked working tree files would be removed by merge:\n%%s" - "Please move or remove them before you can merge.") + "Please move or remove them before you merge.") : _("The following untracked working tree files would be removed by merge:\n%%s"); else msg = advice_commit_before_merge ? _("The following untracked working tree files would be removed by %s:\n%%s" - "Please move or remove them before you can %s.") + "Please move or remove them before you %s.") : _("The following untracked working tree files would be removed by %s:\n%%s"); msgs[ERROR_WOULD_LOSE_UNTRACKED_REMOVED] = xstrfmt(msg, cmd, cmd); if (!strcmp(cmd, "checkout")) msg = advice_commit_before_merge ? _("The following untracked working tree files would be overwritten by checkout:\n%%s" - "Please move or remove them before you can switch branches.") + "Please move or remove them before you switch branches.") : _("The following untracked working tree files would be overwritten by checkout:\n%%s"); else if (!strcmp(cmd, "merge")) msg = advice_commit_before_merge ? _("The following untracked working tree files would be overwritten by merge:\n%%s" - "Please move or remove them before you can merge.") + "Please move or remove them before you merge.") : _("The following untracked working tree files would be overwritten by merge:\n%%s"); else msg = advice_commit_before_merge ? _("The following untracked working tree files would be overwritten by %s:\n%%s" - "Please move or remove them before you can %s.") + "Please move or remove them before you %s.") : _("The following untracked working tree files would be overwritten by %s:\n%%s"); msgs[ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN] = xstrfmt(msg, cmd, cmd); @@@ -123,9 -123,9 +123,9 @@@ msgs[ERROR_SPARSE_NOT_UPTODATE_FILE] = _("Cannot update sparse checkout: the following entries are not up-to-date:\n%s"); msgs[ERROR_WOULD_LOSE_ORPHANED_OVERWRITTEN] = - _("The following Working tree files would be overwritten by sparse checkout update:\n%s"); + _("The following working tree files would be overwritten by sparse checkout update:\n%s"); msgs[ERROR_WOULD_LOSE_ORPHANED_REMOVED] = - _("The following Working tree files would be removed by sparse checkout update:\n%s"); + _("The following working tree files would be removed by sparse checkout update:\n%s"); opts->show_all_errors = 1; /* rejected paths may not have a static buffer */ @@@ -218,8 -218,8 +218,8 @@@ static void unlink_entry(const struct c schedule_dir_for_removal(ce->name, ce_namelen(ce)); } -static struct checkout state; -static int check_updates(struct unpack_trees_options *o) +static int check_updates(struct unpack_trees_options *o, + const struct checkout *state) { unsigned cnt = 0, total = 0; struct progress *progress = NULL; @@@ -264,7 -264,7 +264,7 @@@ display_progress(progress, ++cnt); ce->ce_flags &= ~CE_UPDATE; if (o->update && !o->dry_run) { - errs |= checkout_entry(ce, &state, NULL); + errs |= checkout_entry(ce, state, NULL); } } } @@@ -509,7 -509,7 +509,7 @@@ static int traverse_trees_recursive(in for (i = 0; i < n; i++, dirmask >>= 1) { const unsigned char *sha1 = NULL; if (dirmask & 1) - sha1 = names[i].sha1; + sha1 = names[i].oid->hash; buf[i] = fill_tree_descriptor(t+i, sha1); } @@@ -625,7 -625,7 +625,7 @@@ static struct cache_entry *create_ce_en ce->ce_mode = create_ce_mode(n->mode); ce->ce_flags = create_ce_flags(stage); ce->ce_namelen = len; - hashcpy(ce->sha1, n->sha1); + oidcpy(&ce->oid, n->oid); make_traverse_path(ce->name, info, n); return ce; @@@ -1094,10 -1094,11 +1094,10 @@@ int unpack_trees(unsigned len, struct t int i, ret; static struct cache_entry *dfc; struct exclude_list el; + struct checkout state = CHECKOUT_INIT; if (len > MAX_UNPACK_TREES) die("unpack_trees takes at most %d trees", MAX_UNPACK_TREES); - memset(&state, 0, sizeof(state)); - state.base_dir = ""; state.force = 1; state.quiet = 1; state.refresh_cache = 1; @@@ -1238,7 -1239,7 +1238,7 @@@ } o->src_index = NULL; - ret = check_updates(o) ? (-2) : 0; + ret = check_updates(o, &state) ? (-2) : 0; if (o->dst_index) { if (!ret) { if (!o->result.cache_tree) @@@ -1286,7 -1287,7 +1286,7 @@@ static int same(const struct cache_entr if ((a->ce_flags | b->ce_flags) & CE_CONFLICTED) return 0; return a->ce_mode == b->ce_mode && - !hashcmp(a->sha1, b->sha1); + !oidcmp(&a->oid, &b->oid); } @@@ -1392,7 -1393,7 +1392,7 @@@ static int verify_clean_subdirectory(co /* If we are not going to update the submodule, then * we don't care. */ - if (!hashcmp(sha1, ce->sha1)) + if (!hashcmp(sha1, ce->oid.hash)) return 0; return verify_clean_submodule(ce, error_type, o); } @@@ -1532,7 -1533,8 +1532,7 @@@ static int verify_absent_1(const struc path = xmemdupz(ce->name, len); if (lstat(path, &st)) - ret = error("cannot stat '%s': %s", path, - strerror(errno)); + ret = error_errno("cannot stat '%s'", path); else ret = check_ok_to_remove(path, len, DT_UNKNOWN, NULL, &st, error_type, o); @@@ -1540,7 -1542,8 +1540,7 @@@ return ret; } else if (lstat(ce->name, &st)) { if (errno != ENOENT) - return error("cannot stat '%s': %s", ce->name, - strerror(errno)); + return error_errno("cannot stat '%s'", ce->name); return 0; } else { return check_ok_to_remove(ce->name, ce_namelen(ce), @@@ -1664,7 -1667,7 +1664,7 @@@ static void show_stage_entry(FILE *o fprintf(o, "%s%06o %s %d\t%s\n", label, ce->ce_mode, - sha1_to_hex(ce->sha1), + oid_to_hex(&ce->oid), ce_stage(ce), ce->name); }