Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'builtin')
-rw-r--r--builtin/add.c5
-rw-r--r--builtin/blame.c3
-rw-r--r--builtin/branch.c50
-rw-r--r--builtin/checkout.c2
-rw-r--r--builtin/clone.c6
-rw-r--r--builtin/commit.c10
-rw-r--r--builtin/diff.c7
-rw-r--r--builtin/fsck.c31
-rw-r--r--builtin/grep.c3
-rw-r--r--builtin/index-pack.c6
-rw-r--r--builtin/init-db.c14
-rw-r--r--builtin/log.c34
-rw-r--r--builtin/merge.c4
-rw-r--r--builtin/tag.c6
14 files changed, 99 insertions, 82 deletions
diff --git a/builtin/add.c b/builtin/add.c
index 12b964e642..1d74763f58 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -21,8 +21,7 @@ static const char * const builtin_add_usage[] = {
static int patch_interactive, add_interactive, edit_interactive;
static int take_worktree_changes;
-struct update_callback_data
-{
+struct update_callback_data {
int flags;
int add_errors;
};
@@ -317,7 +316,7 @@ static struct option builtin_add_options[] = {
OPT__VERBOSE(&verbose, "be verbose"),
OPT_GROUP(""),
OPT_BOOLEAN('i', "interactive", &add_interactive, "interactive picking"),
- OPT_BOOLEAN('p', "patch", &patch_interactive, "interactive patching"),
+ OPT_BOOLEAN('p', "patch", &patch_interactive, "select hunks interactively"),
OPT_BOOLEAN('e', "edit", &edit_interactive, "edit current diff and apply"),
OPT__FORCE(&ignored_too, "allow adding otherwise ignored files"),
OPT_BOOLEAN('u', "update", &take_worktree_changes, "update tracked files"),
diff --git a/builtin/blame.c b/builtin/blame.c
index aa30ec5269..f6b03f750a 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -1312,8 +1312,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
/*
* Information on commits, used for output.
*/
-struct commit_info
-{
+struct commit_info {
const char *author;
const char *author_mail;
unsigned long author_time;
diff --git a/builtin/branch.c b/builtin/branch.c
index 9e546e4a83..b9ba011f7b 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -134,7 +134,7 @@ static int branch_merged(int kind, const char *name,
in_merge_bases(rev, &head_rev, 1) != merged) {
if (merged)
warning("deleting branch '%s' that has been merged to\n"
- " '%s', but it is not yet merged to HEAD.",
+ " '%s', but not yet been merged to HEAD.",
name, reference_name);
else
warning("not deleting branch '%s' that is not yet merged to\n"
@@ -390,6 +390,30 @@ static int matches_merge_filter(struct commit *commit)
return (is_merged == (merge_filter == SHOW_MERGED));
}
+static void add_verbose_info(struct strbuf *out, struct ref_item *item,
+ int verbose, int abbrev)
+{
+ struct strbuf subject = STRBUF_INIT, stat = STRBUF_INIT;
+ const char *sub = " **** invalid ref ****";
+ struct commit *commit = item->commit;
+
+ if (commit && !parse_commit(commit)) {
+ struct pretty_print_context ctx = {0};
+ pretty_print_commit(CMIT_FMT_ONELINE, commit,
+ &subject, &ctx);
+ sub = subject.buf;
+ }
+
+ if (item->kind == REF_LOCAL_BRANCH)
+ fill_tracking_info(&stat, item->name, verbose > 1);
+
+ strbuf_addf(out, " %s %s%s",
+ find_unique_abbrev(item->commit->object.sha1, abbrev),
+ stat.buf, sub);
+ strbuf_release(&stat);
+ strbuf_release(&subject);
+}
+
static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
int abbrev, int current, char *prefix)
{
@@ -430,27 +454,9 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
if (item->dest)
strbuf_addf(&out, " -> %s", item->dest);
- else if (verbose) {
- struct strbuf subject = STRBUF_INIT, stat = STRBUF_INIT;
- const char *sub = " **** invalid ref ****";
-
- commit = item->commit;
- if (commit && !parse_commit(commit)) {
- struct pretty_print_context ctx = {0};
- pretty_print_commit(CMIT_FMT_ONELINE, commit,
- &subject, &ctx);
- sub = subject.buf;
- }
-
- if (item->kind == REF_LOCAL_BRANCH)
- fill_tracking_info(&stat, item->name, verbose > 1);
-
- strbuf_addf(&out, " %s %s%s",
- find_unique_abbrev(item->commit->object.sha1, abbrev),
- stat.buf, sub);
- strbuf_release(&stat);
- strbuf_release(&subject);
- }
+ else if (verbose)
+ /* " f7c0c00 [ahead 58, behind 197] vcs-svn: drop obj_pool.h" */
+ add_verbose_info(&out, item, verbose, abbrev);
printf("%s\n", out.buf);
strbuf_release(&name);
strbuf_release(&out);
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 757f9a08dd..cd7f56e6c4 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -404,7 +404,7 @@ static int merge_working_tree(struct checkout_opts *opts,
topts.dir->exclude_per_dir = ".gitignore";
tree = parse_tree_indirect(old->commit ?
old->commit->object.sha1 :
- (unsigned char *)EMPTY_TREE_SHA1_BIN);
+ EMPTY_TREE_SHA1_BIN);
init_tree_desc(&trees[0], tree->buffer, tree->size);
tree = parse_tree_indirect(new->commit->object.sha1);
init_tree_desc(&trees[1], tree->buffer, tree->size);
diff --git a/builtin/clone.c b/builtin/clone.c
index 61e0989b5a..60d9a64280 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -66,10 +66,10 @@ static struct option builtin_clone_options[] = {
"setup as shared repository"),
OPT_BOOLEAN(0, "recursive", &option_recursive,
"initialize submodules in the clone"),
- OPT_BOOLEAN(0, "recurse_submodules", &option_recursive,
+ OPT_BOOLEAN(0, "recurse-submodules", &option_recursive,
"initialize submodules in the clone"),
- OPT_STRING(0, "template", &option_template, "path",
- "path the template repository"),
+ OPT_STRING(0, "template", &option_template, "template-directory",
+ "directory from which templates will be used"),
OPT_STRING(0, "reference", &option_reference, "repo",
"reference repository"),
OPT_STRING('o', "origin", &option_origin, "branch",
diff --git a/builtin/commit.c b/builtin/commit.c
index 03cff5af63..d7f55e3d46 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -118,10 +118,10 @@ static struct option builtin_commit_options[] = {
OPT__VERBOSE(&verbose, "show diff in commit message template"),
OPT_GROUP("Commit message options"),
- OPT_FILENAME('F', "file", &logfile, "read log from file"),
+ OPT_FILENAME('F', "file", &logfile, "read message from file"),
OPT_STRING(0, "author", &force_author, "AUTHOR", "override author for commit"),
OPT_STRING(0, "date", &force_date, "DATE", "override date for commit"),
- OPT_CALLBACK('m', "message", &message, "MESSAGE", "specify commit message", opt_parse_m),
+ OPT_CALLBACK('m', "message", &message, "MESSAGE", "commit message", opt_parse_m),
OPT_STRING('c', "reedit-message", &edit_message, "COMMIT", "reuse and edit message from specified commit"),
OPT_STRING('C', "reuse-message", &use_message, "COMMIT", "reuse message from specified commit"),
OPT_STRING(0, "fixup", &fixup_message, "COMMIT", "use autosquash formatted message to fixup specified commit"),
@@ -145,12 +145,12 @@ static struct option builtin_commit_options[] = {
STATUS_FORMAT_SHORT),
OPT_BOOLEAN(0, "branch", &status_show_branch, "show branch information"),
OPT_SET_INT(0, "porcelain", &status_format,
- "show porcelain output format", STATUS_FORMAT_PORCELAIN),
+ "machine-readable output", STATUS_FORMAT_PORCELAIN),
OPT_BOOLEAN('z', "null", &null_termination,
"terminate entries with NUL"),
OPT_BOOLEAN(0, "amend", &amend, "amend previous commit"),
OPT_BOOLEAN(0, "no-post-rewrite", &no_post_rewrite, "bypass post-rewrite hook"),
- { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal, no (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
+ { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal, no. (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
/* end commit contents options */
{ OPTION_BOOLEAN, 0, "allow-empty", &allow_empty, NULL,
@@ -1092,7 +1092,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
OPT_BOOLEAN('b', "branch", &status_show_branch,
"show branch information"),
OPT_SET_INT(0, "porcelain", &status_format,
- "show porcelain output format",
+ "machine-readable output",
STATUS_FORMAT_PORCELAIN),
OPT_BOOLEAN('z', "null", &null_termination,
"terminate entries with NUL"),
diff --git a/builtin/diff.c b/builtin/diff.c
index 945e7583a8..42822cd537 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -330,8 +330,11 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
else if (!strcmp(arg, "--cached") ||
!strcmp(arg, "--staged")) {
add_head_to_pending(&rev);
- if (!rev.pending.nr)
- die("No HEAD commit to compare with (yet)");
+ if (!rev.pending.nr) {
+ struct tree *tree;
+ tree = lookup_tree((const unsigned char*)EMPTY_TREE_SHA1_BIN);
+ add_pending_object(&rev, &tree->object, "HEAD");
+ }
break;
}
}
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 6d5ebca7a9..795aba087f 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -74,7 +74,13 @@ static int mark_object(struct object *obj, int type, void *data)
{
struct object *parent = data;
+ /*
+ * The only case data is NULL or type is OBJ_ANY is when
+ * mark_object_reachable() calls us. All the callers of
+ * that function has non-NULL obj hence ...
+ */
if (!obj) {
+ /* ... these references to parent->fld are safe here */
printf("broken link from %7s %s\n",
typename(parent->type), sha1_to_hex(parent->sha1));
printf("broken link from %7s %s\n",
@@ -84,6 +90,7 @@ static int mark_object(struct object *obj, int type, void *data)
}
if (type != OBJ_ANY && obj->type != type)
+ /* ... and the reference to parent is safe here */
objerror(parent, "wrong object type in link");
if (obj->flags & REACHABLE)
@@ -109,7 +116,7 @@ static void mark_object_reachable(struct object *obj)
mark_object(obj, OBJ_ANY, NULL);
}
-static int traverse_one_object(struct object *obj, struct object *parent)
+static int traverse_one_object(struct object *obj)
{
int result;
struct tree *tree = NULL;
@@ -138,7 +145,7 @@ static int traverse_reachable(void)
entry = pending.objects + --pending.nr;
obj = entry->item;
parent = (struct object *) entry->name;
- result |= traverse_one_object(obj, parent);
+ result |= traverse_one_object(obj);
}
return !!result;
}
@@ -385,10 +392,20 @@ static void add_sha1_list(unsigned char *sha1, unsigned long ino)
sha1_list.nr = ++nr;
}
+static inline int is_loose_object_file(struct dirent *de,
+ char *name, unsigned char *sha1)
+{
+ if (strlen(de->d_name) != 38)
+ return 0;
+ memcpy(name + 2, de->d_name, 39);
+ return !get_sha1_hex(name, sha1);
+}
+
static void fsck_dir(int i, char *path)
{
DIR *dir = opendir(path);
struct dirent *de;
+ char name[100];
if (!dir)
return;
@@ -396,17 +413,13 @@ static void fsck_dir(int i, char *path)
if (verbose)
fprintf(stderr, "Checking directory %s\n", path);
+ sprintf(name, "%02x", i);
while ((de = readdir(dir)) != NULL) {
- char name[100];
unsigned char sha1[20];
if (is_dot_or_dotdot(de->d_name))
continue;
- if (strlen(de->d_name) == 38) {
- sprintf(name, "%02x", i);
- memcpy(name+2, de->d_name, 39);
- if (get_sha1_hex(name, sha1) < 0)
- break;
+ if (is_loose_object_file(de, name, sha1)) {
add_sha1_list(sha1, DIRENT_SORT_HINT(de));
continue;
}
@@ -556,8 +569,8 @@ static int fsck_cache_tree(struct cache_tree *it)
sha1_to_hex(it->sha1));
return 1;
}
- mark_object_reachable(obj);
obj->used = 1;
+ mark_object_reachable(obj);
if (obj->type != OBJ_TREE)
err |= objerror(obj, "non-tree in cache-tree");
}
diff --git a/builtin/grep.c b/builtin/grep.c
index fdf7131efd..34f9ae0304 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -40,8 +40,7 @@ enum work_type {WORK_SHA1, WORK_FILE};
* threads. The producer adds struct work_items to 'todo' and the
* consumers pick work items from the same array.
*/
-struct work_item
-{
+struct work_item {
enum work_type type;
char *name;
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 8dc5c0b541..c7e600db47 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -13,8 +13,7 @@
static const char index_pack_usage[] =
"git index-pack [-v] [-o <index-file>] [ --keep | --keep=<msg> ] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";
-struct object_entry
-{
+struct object_entry {
struct pack_idx_entry idx;
unsigned long size;
unsigned int hdr_size;
@@ -44,8 +43,7 @@ struct base_data {
#define FLAG_LINK (1u<<20)
#define FLAG_CHECKED (1u<<21)
-struct delta_entry
-{
+struct delta_entry {
union delta_base base;
int obj_no;
};
diff --git a/builtin/init-db.c b/builtin/init-db.c
index e3af9eaa87..fbeb380ee2 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -419,7 +419,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
unsigned int flags = 0;
const struct option init_db_options[] = {
OPT_STRING(0, "template", &template_dir, "template-directory",
- "provide the directory from which templates will be used"),
+ "directory from which templates will be used"),
OPT_SET_INT(0, "bare", &is_bare_repository_cfg,
"create a bare repository", 1),
{ OPTION_CALLBACK, 0, "shared", &init_shared_repository,
@@ -498,13 +498,11 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
is_bare_repository_cfg = guess_repository_type(git_dir);
if (!is_bare_repository_cfg) {
- if (git_dir) {
- const char *git_dir_parent = strrchr(git_dir, '/');
- if (git_dir_parent) {
- char *rel = xstrndup(git_dir, git_dir_parent - git_dir);
- git_work_tree_cfg = xstrdup(make_absolute_path(rel));
- free(rel);
- }
+ const char *git_dir_parent = strrchr(git_dir, '/');
+ if (git_dir_parent) {
+ char *rel = xstrndup(git_dir, git_dir_parent - git_dir);
+ git_work_tree_cfg = xstrdup(make_absolute_path(rel));
+ free(rel);
}
if (!git_work_tree_cfg) {
git_work_tree_cfg = xcalloc(PATH_MAX, 1);
diff --git a/builtin/log.c b/builtin/log.c
index d8c6c28d2f..0f43d2ec78 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1352,6 +1352,23 @@ static const char * const cherry_usage[] = {
NULL
};
+static void print_commit(char sign, struct commit *commit, int verbose,
+ int abbrev)
+{
+ if (!verbose) {
+ printf("%c %s\n", sign,
+ find_unique_abbrev(commit->object.sha1, abbrev));
+ } else {
+ struct strbuf buf = STRBUF_INIT;
+ struct pretty_print_context ctx = {0};
+ pretty_print_commit(CMIT_FMT_ONELINE, commit, &buf, &ctx);
+ printf("%c %s %s\n", sign,
+ find_unique_abbrev(commit->object.sha1, abbrev),
+ buf.buf);
+ strbuf_release(&buf);
+ }
+}
+
int cmd_cherry(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
@@ -1436,22 +1453,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
commit = list->item;
if (has_commit_patch_id(commit, &ids))
sign = '-';
-
- if (verbose) {
- struct strbuf buf = STRBUF_INIT;
- struct pretty_print_context ctx = {0};
- pretty_print_commit(CMIT_FMT_ONELINE, commit,
- &buf, &ctx);
- printf("%c %s %s\n", sign,
- find_unique_abbrev(commit->object.sha1, abbrev),
- buf.buf);
- strbuf_release(&buf);
- }
- else {
- printf("%c %s\n", sign,
- find_unique_abbrev(commit->object.sha1, abbrev));
- }
-
+ print_commit(sign, commit, verbose, abbrev);
list = list->next;
}
diff --git a/builtin/merge.c b/builtin/merge.c
index ca16657d25..d534520c3e 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -194,8 +194,8 @@ static struct option builtin_merge_options[] = {
"merge strategy to use", option_parse_strategy),
OPT_CALLBACK('X', "strategy-option", &xopts, "option=value",
"option for selected merge strategy", option_parse_x),
- OPT_CALLBACK('m', "message", &merge_msg, "message",
- "message to be used for the merge commit (if any)",
+ OPT_CALLBACK('m', "message", &merge_msg, "MESSAGE",
+ "merge commit message (for a non-fast-forward merge)",
option_parse_message),
OPT__VERBOSITY(&verbosity),
OPT_BOOLEAN(0, "abort", &abort_current_merge,
diff --git a/builtin/tag.c b/builtin/tag.c
index aa1f87d47a..246a2bc72b 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -376,9 +376,9 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
OPT_GROUP("Tag creation options"),
OPT_BOOLEAN('a', NULL, &annotate,
"annotated tag, needs a message"),
- OPT_CALLBACK('m', NULL, &msg, "msg",
- "message for the tag", parse_msg_arg),
- OPT_FILENAME('F', NULL, &msgfile, "message in a file"),
+ OPT_CALLBACK('m', NULL, &msg, "MESSAGE",
+ "tag message", parse_msg_arg),
+ OPT_FILENAME('F', NULL, &msgfile, "read message from file"),
OPT_BOOLEAN('s', NULL, &sign, "annotated and GPG-signed tag"),
OPT_STRING('u', NULL, &keyid, "key-id",
"use another key to sign the tag"),