diff options
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/blame.c | 33 | ||||
-rw-r--r-- | builtin/bundle.c | 4 | ||||
-rw-r--r-- | builtin/cat-file.c | 2 | ||||
-rw-r--r-- | builtin/checkout-index.c | 2 | ||||
-rw-r--r-- | builtin/checkout.c | 2 | ||||
-rw-r--r-- | builtin/clean.c | 8 | ||||
-rw-r--r-- | builtin/commit-tree.c | 14 | ||||
-rw-r--r-- | builtin/fetch.c | 2 | ||||
-rw-r--r-- | builtin/grep.c | 2 | ||||
-rw-r--r-- | builtin/index-pack.c | 2 | ||||
-rw-r--r-- | builtin/ls-files.c | 2 | ||||
-rw-r--r-- | builtin/ls-tree.c | 2 | ||||
-rw-r--r-- | builtin/mailsplit.c | 2 | ||||
-rw-r--r-- | builtin/merge-file.c | 7 | ||||
-rw-r--r-- | builtin/merge-recursive.c | 15 | ||||
-rw-r--r-- | builtin/merge.c | 20 | ||||
-rw-r--r-- | builtin/pack-objects.c | 10 | ||||
-rw-r--r-- | builtin/remote.c | 2 | ||||
-rw-r--r-- | builtin/rev-list.c | 14 | ||||
-rw-r--r-- | builtin/send-pack.c | 2 | ||||
-rw-r--r-- | builtin/show-branch.c | 2 | ||||
-rw-r--r-- | builtin/update-index.c | 2 |
22 files changed, 72 insertions, 79 deletions
diff --git a/builtin/blame.c b/builtin/blame.c index 101535448..f5fccc1f6 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -83,6 +83,7 @@ struct origin { struct commit *commit; mmfile_t file; unsigned char blob_sha1[20]; + unsigned mode; char path[FLEX_ARRAY]; }; @@ -92,6 +93,7 @@ struct origin { * Return 1 if the conversion succeeds, 0 otherwise. */ int textconv_object(const char *path, + unsigned mode, const unsigned char *sha1, char **buf, unsigned long *buf_size) @@ -100,7 +102,7 @@ int textconv_object(const char *path, struct userdiff_driver *textconv; df = alloc_filespec(path); - fill_filespec(df, sha1, S_IFREG | 0664); + fill_filespec(df, sha1, mode); textconv = get_textconv(df); if (!textconv) { free_filespec(df); @@ -125,7 +127,7 @@ static void fill_origin_blob(struct diff_options *opt, num_read_blob++; if (DIFF_OPT_TST(opt, ALLOW_TEXTCONV) && - textconv_object(o->path, o->blob_sha1, &file->ptr, &file_size)) + textconv_object(o->path, o->mode, o->blob_sha1, &file->ptr, &file_size)) ; else file->ptr = read_sha1_file(o->blob_sha1, &type, &file_size); @@ -313,21 +315,23 @@ static struct origin *get_origin(struct scoreboard *sb, * for an origin is also used to pass the blame for the entire file to * the parent to detect the case where a child's blob is identical to * that of its parent's. + * + * This also fills origin->mode for corresponding tree path. */ -static int fill_blob_sha1(struct origin *origin) +static int fill_blob_sha1_and_mode(struct origin *origin) { - unsigned mode; if (!is_null_sha1(origin->blob_sha1)) return 0; if (get_tree_entry(origin->commit->object.sha1, origin->path, - origin->blob_sha1, &mode)) + origin->blob_sha1, &origin->mode)) goto error_out; if (sha1_object_info(origin->blob_sha1, NULL) != OBJ_BLOB) goto error_out; return 0; error_out: hashclr(origin->blob_sha1); + origin->mode = S_IFINVALID; return -1; } @@ -360,12 +364,14 @@ static struct origin *find_origin(struct scoreboard *sb, /* * If the origin was newly created (i.e. get_origin * would call make_origin if none is found in the - * scoreboard), it does not know the blob_sha1, + * scoreboard), it does not know the blob_sha1/mode, * so copy it. Otherwise porigin was in the - * scoreboard and already knows blob_sha1. + * scoreboard and already knows blob_sha1/mode. */ - if (porigin->refcnt == 1) + if (porigin->refcnt == 1) { hashcpy(porigin->blob_sha1, cached->blob_sha1); + porigin->mode = cached->mode; + } return porigin; } /* otherwise it was not very useful; free it */ @@ -400,6 +406,7 @@ static struct origin *find_origin(struct scoreboard *sb, /* The path is the same as parent */ porigin = get_origin(sb, parent, origin->path); hashcpy(porigin->blob_sha1, origin->blob_sha1); + porigin->mode = origin->mode; } else { /* * Since origin->path is a pathspec, if the parent @@ -425,6 +432,7 @@ static struct origin *find_origin(struct scoreboard *sb, case 'M': porigin = get_origin(sb, parent, origin->path); hashcpy(porigin->blob_sha1, p->one->sha1); + porigin->mode = p->one->mode; break; case 'A': case 'T': @@ -444,6 +452,7 @@ static struct origin *find_origin(struct scoreboard *sb, cached = make_origin(porigin->commit, porigin->path); hashcpy(cached->blob_sha1, porigin->blob_sha1); + cached->mode = porigin->mode; parent->util = cached; } return porigin; @@ -486,6 +495,7 @@ static struct origin *find_rename(struct scoreboard *sb, !strcmp(p->two->path, origin->path)) { porigin = get_origin(sb, parent, p->one->path); hashcpy(porigin->blob_sha1, p->one->sha1); + porigin->mode = p->one->mode; break; } } @@ -1099,6 +1109,7 @@ static int find_copy_in_parent(struct scoreboard *sb, norigin = get_origin(sb, parent, p->one->path); hashcpy(norigin->blob_sha1, p->one->sha1); + norigin->mode = p->one->mode; fill_origin_blob(&sb->revs->diffopt, norigin, &file_p); if (!file_p.ptr) continue; @@ -2075,7 +2086,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt, switch (st.st_mode & S_IFMT) { case S_IFREG: if (DIFF_OPT_TST(opt, ALLOW_TEXTCONV) && - textconv_object(read_from, null_sha1, &buf.buf, &buf_len)) + textconv_object(read_from, mode, null_sha1, &buf.buf, &buf_len)) buf.len = buf_len; else if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size) die_errno("cannot open or read '%s'", read_from); @@ -2455,11 +2466,11 @@ parse_done: } else { o = get_origin(&sb, sb.final, path); - if (fill_blob_sha1(o)) + if (fill_blob_sha1_and_mode(o)) die("no such path %s in %s", path, final_commit_name); if (DIFF_OPT_TST(&sb.revs->diffopt, ALLOW_TEXTCONV) && - textconv_object(path, o->blob_sha1, (char **) &sb.final_buf, + textconv_object(path, o->mode, o->blob_sha1, (char **) &sb.final_buf, &sb.final_buf_size)) ; else diff --git a/builtin/bundle.c b/builtin/bundle.c index 80649ba0b..9b87fb9ac 100644 --- a/builtin/bundle.c +++ b/builtin/bundle.c @@ -12,8 +12,8 @@ static const char builtin_bundle_usage[] = "git bundle create <file> <git-rev-list args>\n" " or: git bundle verify <file>\n" - " or: git bundle list-heads <file> [refname...]\n" - " or: git bundle unbundle <file> [refname...]"; + " or: git bundle list-heads <file> [<refname>...]\n" + " or: git bundle unbundle <file> [<refname>...]"; int cmd_bundle(int argc, const char **argv, const char *prefix) { diff --git a/builtin/cat-file.c b/builtin/cat-file.c index 76ec3fec9..94632dbdb 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -143,7 +143,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name) die("git cat-file --textconv %s: <object> must be <sha1:path>", obj_name); - if (!textconv_object(obj_context.path, sha1, &buf, &size)) + if (!textconv_object(obj_context.path, obj_context.mode, sha1, &buf, &size)) die("git cat-file --textconv: unable to run textconv on %s", obj_name); break; diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c index a7a5ee10f..65cbee055 100644 --- a/builtin/checkout-index.c +++ b/builtin/checkout-index.c @@ -155,7 +155,7 @@ static void checkout_all(const char *prefix, int prefix_length) } static const char * const builtin_checkout_index_usage[] = { - "git checkout-index [options] [--] <file>...", + "git checkout-index [options] [--] [<file>...]", NULL }; diff --git a/builtin/checkout.c b/builtin/checkout.c index a54583b3a..9240fafb2 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -161,7 +161,7 @@ static int checkout_merged(int pos, struct checkout *state) * merge.renormalize set, too */ status = ll_merge(&result_buf, path, &ancestor, "base", - &ours, "ours", &theirs, "theirs", 0); + &ours, "ours", &theirs, "theirs", NULL); free(ancestor.ptr); free(ours.ptr); free(theirs.ptr); diff --git a/builtin/clean.c b/builtin/clean.c index c8798f549..fb2403075 100644 --- a/builtin/clean.c +++ b/builtin/clean.c @@ -38,7 +38,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) { int i; int show_only = 0, remove_directories = 0, quiet = 0, ignored = 0; - int ignored_only = 0, baselen = 0, config_set = 0, errors = 0; + int ignored_only = 0, config_set = 0, errors = 0; int rm_flags = REMOVE_DIR_KEEP_NESTED_GIT; struct strbuf directory = STRBUF_INIT; struct dir_struct dir; @@ -138,7 +138,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) if (pathspec) { memset(seen, 0, argc > 0 ? argc : 1); matches = match_pathspec(pathspec, ent->name, len, - baselen, seen); + 0, seen); } if (S_ISDIR(st.st_mode)) { @@ -153,7 +153,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) printf("Removing %s\n", qname); if (remove_dir_recursively(&directory, rm_flags) != 0) { - warning("failed to remove '%s'", qname); + warning("failed to remove %s", qname); errors++; } } else if (show_only) { @@ -173,7 +173,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) printf("Removing %s\n", qname); } if (unlink(ent->name) != 0) { - warning("failed to remove '%s'", qname); + warning("failed to remove %s", qname); errors++; } } diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c index 87f0591c2..d083795e2 100644 --- a/builtin/commit-tree.c +++ b/builtin/commit-tree.c @@ -9,7 +9,7 @@ #include "builtin.h" #include "utf8.h" -static const char commit_tree_usage[] = "git commit-tree <sha1> [-p <sha1>]* < changelog"; +static const char commit_tree_usage[] = "git commit-tree <sha1> [(-p <sha1>)...] < changelog"; static void new_parent(struct commit *parent, struct commit_list **parents_p) { @@ -56,10 +56,12 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) if (strbuf_read(&buffer, 0, 0) < 0) die_errno("git commit-tree: failed to read"); - if (!commit_tree(buffer.buf, tree_sha1, parents, commit_sha1, NULL)) { - printf("%s\n", sha1_to_hex(commit_sha1)); - return 0; - } - else + if (commit_tree(buffer.buf, tree_sha1, parents, commit_sha1, NULL)) { + strbuf_release(&buffer); return 1; + } + + printf("%s\n", sha1_to_hex(commit_sha1)); + strbuf_release(&buffer); + return 0; } diff --git a/builtin/fetch.c b/builtin/fetch.c index 6fc504770..d35f000c0 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -16,7 +16,7 @@ static const char * const builtin_fetch_usage[] = { "git fetch [<options>] [<repository> [<refspec>...]]", "git fetch [<options>] <group>", - "git fetch --multiple [<options>] [<repository> | <group>]...", + "git fetch --multiple [<options>] [(<repository> | <group>)...]", "git fetch --all [<options>]", NULL }; diff --git a/builtin/grep.c b/builtin/grep.c index da32f3df3..3d5f6ace9 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -24,7 +24,7 @@ #endif static char const * const grep_usage[] = { - "git grep [options] [-e] <pattern> [<rev>...] [[--] path...]", + "git grep [options] [-e] <pattern> [<rev>...] [[--] <path>...]", NULL }; diff --git a/builtin/index-pack.c b/builtin/index-pack.c index e243d9d22..8dc5c0b54 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -11,7 +11,7 @@ #include "exec_cmd.h" static const char index_pack_usage[] = -"git index-pack [-v] [-o <index-file>] [{ --keep | --keep=<msg> }] [--strict] { <pack-file> | --stdin [--fix-thin] [<pack-file>] }"; +"git index-pack [-v] [-o <index-file>] [ --keep | --keep=<msg> ] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])"; struct object_entry { diff --git a/builtin/ls-files.c b/builtin/ls-files.c index bb4f612b3..6a307ab78 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -424,7 +424,7 @@ int report_path_error(const char *ps_matched, const char **pathspec, int prefix_ } static const char * const ls_files_usage[] = { - "git ls-files [options] [<file>]*", + "git ls-files [options] [<file>...]", NULL }; diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c index a8187568b..f73e6bd96 100644 --- a/builtin/ls-tree.c +++ b/builtin/ls-tree.c @@ -24,7 +24,7 @@ static int chomp_prefix; static const char *ls_tree_prefix; static const char * const ls_tree_usage[] = { - "git ls-tree [<options>] <tree-ish> [path...]", + "git ls-tree [<options>] <tree-ish> [<path>...]", NULL }; diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c index 99654d022..2d4327801 100644 --- a/builtin/mailsplit.c +++ b/builtin/mailsplit.c @@ -10,7 +10,7 @@ #include "strbuf.h" static const char git_mailsplit_usage[] = -"git mailsplit [-d<prec>] [-f<n>] [-b] [--keep-cr] -o<directory> [<mbox>|<Maildir>...]"; +"git mailsplit [-d<prec>] [-f<n>] [-b] [--keep-cr] -o<directory> [(<mbox>|<Maildir>)...]"; static int is_from_line(const char *line, int len) { diff --git a/builtin/merge-file.c b/builtin/merge-file.c index b6664d49b..6c4afb5a3 100644 --- a/builtin/merge-file.c +++ b/builtin/merge-file.c @@ -28,6 +28,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix) xmparam_t xmp = {{0}}; int ret = 0, i = 0, to_stdout = 0; int quiet = 0; + int prefixlen = 0; struct option options[] = { OPT_BOOLEAN('p', "stdout", &to_stdout, "send results to standard output"), OPT_SET_INT(0, "diff3", &xmp.style, "use a diff3 based merge", XDL_MERGE_DIFF3), @@ -65,10 +66,14 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix) "%s\n", strerror(errno)); } + if (prefix) + prefixlen = strlen(prefix); + for (i = 0; i < 3; i++) { + const char *fname = prefix_filename(prefix, prefixlen, argv[i]); if (!names[i]) names[i] = argv[i]; - if (read_mmfile(mmfs + i, argv[i])) + if (read_mmfile(mmfs + i, fname)) return -1; if (buffer_is_binary(mmfs[i].ptr, mmfs[i].size)) return error("Cannot merge binary files: %s\n", diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c index 78b9db76a..c33091b3e 100644 --- a/builtin/merge-recursive.c +++ b/builtin/merge-recursive.c @@ -2,6 +2,7 @@ #include "commit.h" #include "tag.h" #include "merge-recursive.h" +#include "xdiff-interface.h" static const char builtin_merge_recursive_usage[] = "git %s <base>... -- <head> <remote> ..."; @@ -40,19 +41,7 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix) if (!prefixcmp(arg, "--")) { if (!arg[2]) break; - if (!strcmp(arg+2, "ours")) - o.recursive_variant = MERGE_RECURSIVE_OURS; - else if (!strcmp(arg+2, "theirs")) - o.recursive_variant = MERGE_RECURSIVE_THEIRS; - else if (!strcmp(arg+2, "subtree")) - o.subtree_shift = ""; - else if (!prefixcmp(arg+2, "subtree=")) - o.subtree_shift = arg + 10; - else if (!strcmp(arg+2, "renormalize")) - o.renormalize = 1; - else if (!strcmp(arg+2, "no-renormalize")) - o.renormalize = 0; - else + if (parse_merge_opt(&o, arg + 2)) die("Unknown option %s", arg); continue; } diff --git a/builtin/merge.c b/builtin/merge.c index 2dba3b990..10f091b51 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -639,25 +639,9 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common, o.renormalize = option_renormalize; - /* - * NEEDSWORK: merge with table in builtin/merge-recursive - */ - for (x = 0; x < xopts_nr; x++) { - if (!strcmp(xopts[x], "ours")) - o.recursive_variant = MERGE_RECURSIVE_OURS; - else if (!strcmp(xopts[x], "theirs")) - o.recursive_variant = MERGE_RECURSIVE_THEIRS; - else if (!strcmp(xopts[x], "subtree")) - o.subtree_shift = ""; - else if (!prefixcmp(xopts[x], "subtree=")) - o.subtree_shift = xopts[x]+8; - else if (!strcmp(xopts[x], "renormalize")) - o.renormalize = 1; - else if (!strcmp(xopts[x], "no-renormalize")) - o.renormalize = 0; - else + for (x = 0; x < xopts_nr; x++) + if (parse_merge_opt(&o, xopts[x])) die("Unknown option for merge-recursive: -X%s", xopts[x]); - } o.branch1 = head_arg; o.branch2 = remoteheads->item->util; diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index d5a8db1bb..f8eba53c8 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -23,15 +23,15 @@ #endif static const char pack_usage[] = - "git pack-objects [{ -q | --progress | --all-progress }]\n" + "git pack-objects [ -q | --progress | --all-progress ]\n" " [--all-progress-implied]\n" - " [--max-pack-size=N] [--local] [--incremental]\n" - " [--window=N] [--window-memory=N] [--depth=N]\n" + " [--max-pack-size=<n>] [--local] [--incremental]\n" + " [--window=<n>] [--window-memory=<n>] [--depth=<n>]\n" " [--no-reuse-delta] [--no-reuse-object] [--delta-base-offset]\n" - " [--threads=N] [--non-empty] [--revs [--unpacked | --all]*]\n" + " [--threads=<n>] [--non-empty] [--revs [--unpacked | --all]]\n" " [--reflog] [--stdout | base-name] [--include-tag]\n" " [--keep-unreachable | --unpack-unreachable]\n" - " [<ref-list | <object-list]"; + " [< ref-list | < object-list]"; struct object_entry { struct pack_idx_entry idx; diff --git a/builtin/remote.c b/builtin/remote.c index 48e0a6bf2..e9a6e0925 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -15,7 +15,7 @@ static const char * const builtin_remote_usage[] = { "git remote set-head <name> (-a | -d | <branch>)", "git remote [-v | --verbose] show [-n] <name>", "git remote prune [-n | --dry-run] <name>", - "git remote [-v | --verbose] update [-p | --prune] [group | remote]", + "git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]", "git remote set-branches <name> [--add] <branch>...", "git remote set-url <name> <newurl> [<oldurl>]", "git remote set-url --add <name> <newurl>", diff --git a/builtin/rev-list.c b/builtin/rev-list.c index efe9360e2..ba27d39f9 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -11,9 +11,9 @@ static const char rev_list_usage[] = "git rev-list [OPTION] <commit-id>... [ -- paths... ]\n" " limiting output:\n" -" --max-count=nr\n" -" --max-age=epoch\n" -" --min-age=epoch\n" +" --max-count=<n>\n" +" --max-age=<epoch>\n" +" --min-age=<epoch>\n" " --sparse\n" " --no-merges\n" " --remove-empty\n" @@ -33,7 +33,7 @@ static const char rev_list_usage[] = " --objects | --objects-edge\n" " --unpacked\n" " --header | --pretty\n" -" --abbrev=nr | --no-abbrev\n" +" --abbrev=<n> | --no-abbrev\n" " --abbrev-commit\n" " --left-right\n" " special purpose:\n" @@ -147,8 +147,10 @@ static void show_commit(struct commit *commit, void *data) } } else { if (revs->commit_format != CMIT_FMT_USERFORMAT || - buf.len) - printf("%s%c", buf.buf, info->hdr_termination); + buf.len) { + fwrite(buf.buf, 1, buf.len, stdout); + putchar(info->hdr_termination); + } } strbuf_release(&buf); } else { diff --git a/builtin/send-pack.c b/builtin/send-pack.c index efd9be67b..2cd1c40b7 100644 --- a/builtin/send-pack.c +++ b/builtin/send-pack.c @@ -104,7 +104,7 @@ static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *ext } if (finish_command(&po)) - return error("pack-objects died with strange error"); + return -1; return 0; } diff --git a/builtin/show-branch.c b/builtin/show-branch.c index e8719aa9e..8663ccaa9 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -6,7 +6,7 @@ #include "parse-options.h" static const char* show_branch_usage[] = { - "git show-branch [-a|--all] [-r|--remotes] [--topo-order | --date-order] [--current] [--color[=<when>] | --no-color] [--sparse] [--more=<n> | --list | --independent | --merge-base] [--no-name | --sha1-name] [--topics] [<rev> | <glob>]...", + "git show-branch [-a|--all] [-r|--remotes] [--topo-order | --date-order] [--current] [--color[=<when>] | --no-color] [--sparse] [--more=<n> | --list | --independent | --merge-base] [--no-name | --sha1-name] [--topics] [(<rev> | <glob>)...]", "git show-branch (-g|--reflog)[=<n>[,<base>]] [--list] [<ref>]", NULL }; diff --git a/builtin/update-index.c b/builtin/update-index.c index 3ab214d24..62d9f3f0f 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -398,7 +398,7 @@ static void read_index_info(int line_termination) } static const char update_index_usage[] = -"git update-index [-q] [--add] [--replace] [--remove] [--unmerged] [--refresh] [--really-refresh] [--cacheinfo] [--chmod=(+|-)x] [--assume-unchanged] [--skip-worktree|--no-skip-worktree] [--info-only] [--force-remove] [--stdin] [--index-info] [--unresolve] [--again | -g] [--ignore-missing] [-z] [--verbose] [--] <file>..."; +"git update-index [-q] [--add] [--replace] [--remove] [--unmerged] [--refresh] [--really-refresh] [--cacheinfo] [--chmod=(+|-)x] [--assume-unchanged] [--skip-worktree|--no-skip-worktree] [--info-only] [--force-remove] [--stdin] [--index-info] [--unresolve] [--again | -g] [--ignore-missing] [-z] [--verbose] [--] [<file>...]"; static unsigned char head_sha1[20]; static unsigned char merge_head_sha1[20]; |