From 90f867b9a5088a2ea6f5844ae28b617821e77b28 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 31 Oct 2013 03:25:32 -0600 Subject: [PATCH 01/13] merge: simplify ff-only option No functional changes. Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- builtin/merge.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/builtin/merge.c b/builtin/merge.c index 02a69c14e6..41fb66dec2 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -186,13 +186,6 @@ static int option_parse_n(const struct option *opt, return 0; } -static int option_parse_ff_only(const struct option *opt, - const char *arg, int unset) -{ - fast_forward = FF_ONLY; - return 0; -} - static struct option builtin_merge_options[] = { { OPTION_CALLBACK, 'n', NULL, NULL, NULL, N_("do not show a diffstat at the end of the merge"), @@ -210,9 +203,9 @@ static struct option builtin_merge_options[] = { OPT_BOOL('e', "edit", &option_edit, N_("edit message before committing")), OPT_SET_INT(0, "ff", &fast_forward, N_("allow fast-forward (default)"), FF_ALLOW), - { OPTION_CALLBACK, 0, "ff-only", NULL, NULL, + { OPTION_SET_INT, 0, "ff-only", &fast_forward, NULL, N_("abort if fast-forward is not possible"), - PARSE_OPT_NOARG | PARSE_OPT_NONEG, option_parse_ff_only }, + PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, FF_ONLY }, OPT_RERERE_AUTOUPDATE(&allow_rerere_auto), OPT_BOOL(0, "verify-signatures", &verify_signatures, N_("Verify that the named commit has a valid GPG signature")), From 501a75a7b308ed9631cd4802d891e6b56c06821a Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 31 Oct 2013 03:25:33 -0600 Subject: [PATCH 02/13] t: replace pulls with merges This is what the code intended. No functional changes. Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- t/annotate-tests.sh | 2 +- t/t4200-rerere.sh | 2 +- t/t9114-git-svn-dcommit-merge.sh | 2 +- t/t9500-gitweb-standalone-no-errors.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh index 99caa42f5c..c9d105d707 100644 --- a/t/annotate-tests.sh +++ b/t/annotate-tests.sh @@ -92,7 +92,7 @@ test_expect_success 'blame 2 authors + 1 branch2 author' ' ' test_expect_success 'merge branch1 & branch2' ' - git pull . branch1 + git merge branch1 ' test_expect_success 'blame 2 authors + 2 merged-in authors' ' diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh index 7f6666fcd3..cf19eb78af 100755 --- a/t/t4200-rerere.sh +++ b/t/t4200-rerere.sh @@ -172,7 +172,7 @@ test_expect_success 'first postimage wins' ' git show second^:a1 | sed "s/To die: t/To die! T/" >a1 && git commit -q -a -m third && - test_must_fail git pull . first && + test_must_fail git merge first && # rerere kicked in ! grep "^=======\$" a1 && test_cmp expect a1 diff --git a/t/t9114-git-svn-dcommit-merge.sh b/t/t9114-git-svn-dcommit-merge.sh index f524d2f383..d33d714006 100755 --- a/t/t9114-git-svn-dcommit-merge.sh +++ b/t/t9114-git-svn-dcommit-merge.sh @@ -62,7 +62,7 @@ test_expect_success 'setup git mirror and merge' ' echo friend > README && cat tmp >> README && git commit -a -m "friend" && - git pull . merge + git merge merge ' test_debug 'gitk --all & sleep 1' diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh index 718014d5de..e74b9ab1e1 100755 --- a/t/t9500-gitweb-standalone-no-errors.sh +++ b/t/t9500-gitweb-standalone-no-errors.sh @@ -328,7 +328,7 @@ test_expect_success \ git add b && git commit -a -m "On branch" && git checkout master && - git pull . b && + git merge b && git tag merge_commit' test_expect_success \ From 5a3fd6afd4a26accc20a58bf4980f296772be98a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 31 Oct 2013 13:43:35 -0700 Subject: [PATCH 03/13] doc/pull: clarify the illustrations The second illustration that shows the history after "git pull" spelled the remote-tracking branch with "remotes/" prefix, which is not necessary. Drop it. To match the assumption that a remote-tracking branch is used to keep track of the advancement of the master at the origin, update the first illustration that shows the history before "git pull" to show the distinction between the master currently at origin and the stale origin/master remote-tracking branch. Noticed-by: Felipe Contreras Helped-by: Max Horn Signed-off-by: Junio C Hamano --- Documentation/git-pull.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt index beea10b148..6083aab87b 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -42,6 +42,8 @@ Assume the following history exists and the current branch is A---B---C master on origin / D---E---F---G master + ^ + origin/master in your repository ------------ Then "`git pull`" will fetch and replay the changes from the remote @@ -51,7 +53,7 @@ result in a new commit along with the names of the two parent commits and a log message from the user describing the changes. ------------ - A---B---C remotes/origin/master + A---B---C origin/master / \ D---E---F---G---H master ------------ From 19ecb564ad15d6eb0544d11d808ca8dc9a198bdf Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 31 Oct 2013 03:25:36 -0600 Subject: [PATCH 04/13] revision: add missing include Otherwise we might not have 'struct diff_options'. [jc: needs a matching follow-up patch to remove inclusion of diff.h from *.c files that do not themselves use anything from diff.h] Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- revision.h | 1 + 1 file changed, 1 insertion(+) diff --git a/revision.h b/revision.h index e7f1d211bf..89132df2fa 100644 --- a/revision.h +++ b/revision.h @@ -5,6 +5,7 @@ #include "grep.h" #include "notes.h" #include "commit.h" +#include "diff.h" #define SEEN (1u<<0) #define UNINTERESTING (1u<<1) From 54d07f2e25eb90f00def6d6406714d787ab0beb9 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 31 Oct 2013 03:25:38 -0600 Subject: [PATCH 05/13] branch: trivial style fix Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- builtin/branch.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/builtin/branch.c b/builtin/branch.c index ad0f86de54..5696cf0ef7 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -975,9 +975,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix) die(_("no such branch '%s'"), argv[0]); } - if (!branch_has_merge_config(branch)) { + if (!branch_has_merge_config(branch)) die(_("Branch '%s' has no upstream information"), branch->name); - } strbuf_addf(&buf, "branch.%s.remote", branch->name); git_config_set_multivar(buf.buf, NULL, NULL, 1); From 57b15ead774ed2139d9ece494ef67f3f9fd5bbf2 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 31 Oct 2013 03:25:39 -0600 Subject: [PATCH 06/13] sha1-name: trivial style cleanup Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- sha1_name.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sha1_name.c b/sha1_name.c index 0e5fe7f937..e9c299943b 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -343,7 +343,6 @@ static int get_short_sha1(const char *name, int len, unsigned char *sha1, return status; } - int for_each_abbrev(const char *prefix, each_abbrev_fn fn, void *cb_data) { char hex_pfx[40]; From 23cd01ec53abd9a814d6a565a1e40333ae785611 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 31 Oct 2013 03:25:40 -0600 Subject: [PATCH 07/13] transport-helper: trivial style fix Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- transport-helper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/transport-helper.c b/transport-helper.c index b32e2d64dd..673b7c214f 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -269,6 +269,7 @@ static const char *unsupported_options[] = { TRANS_OPT_THIN, TRANS_OPT_KEEP }; + static const char *boolean_options[] = { TRANS_OPT_THIN, TRANS_OPT_KEEP, From c44726438fbdb193c86ee68d53933597a2e10dcb Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 31 Oct 2013 03:25:41 -0600 Subject: [PATCH 08/13] describe: trivial style fixes Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- builtin/describe.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/builtin/describe.c b/builtin/describe.c index b9d3603704..6f62109887 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -9,7 +9,7 @@ #include "hash.h" #include "argv-array.h" -#define SEEN (1u<<0) +#define SEEN (1u << 0) #define MAX_TAGS (FLAG_BITS - 1) static const char * const describe_usage[] = { @@ -36,7 +36,6 @@ static const char *diff_index_args[] = { "diff-index", "--quiet", "HEAD", "--", NULL }; - struct commit_name { struct commit_name *next; unsigned char peeled[20]; @@ -46,6 +45,7 @@ struct commit_name { unsigned char sha1[20]; char *path; }; + static const char *prio_names[] = { "head", "lightweight", "annotated", }; @@ -488,9 +488,8 @@ int cmd_describe(int argc, const char **argv, const char *prefix) } else if (dirty) { die(_("--dirty is incompatible with commit-ishes")); } else { - while (argc-- > 0) { + while (argc-- > 0) describe(*argv++, argc == 0); - } } return 0; } From 35b2fa5ba3090d56d318acd206204e61b6a3281c Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 31 Oct 2013 03:25:42 -0600 Subject: [PATCH 09/13] pretty: trivial style fix Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- pretty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pretty.c b/pretty.c index b4e32b74d3..962e82be86 100644 --- a/pretty.c +++ b/pretty.c @@ -497,7 +497,7 @@ void pp_user_info(struct pretty_print_context *pp, static int is_empty_line(const char *line, int *len_p) { int len = *len_p; - while (len && isspace(line[len-1])) + while (len && isspace(line[len - 1])) len--; *len_p = len; return !len; From 9e57ac55cecec8bd2cf94d675e4458bc68a7336f Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 31 Oct 2013 03:25:43 -0600 Subject: [PATCH 10/13] revision: trivial style fixes Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- revision.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/revision.c b/revision.c index 3fdea51ffe..956040c8c8 100644 --- a/revision.c +++ b/revision.c @@ -1519,7 +1519,7 @@ struct cmdline_pathspec { static void append_prune_data(struct cmdline_pathspec *prune, const char **av) { while (*av) { - ALLOC_GROW(prune->path, prune->nr+1, prune->alloc); + ALLOC_GROW(prune->path, prune->nr + 1, prune->alloc); prune->path[prune->nr++] = *(av++); } } @@ -1531,7 +1531,7 @@ static void read_pathspec_from_stdin(struct rev_info *revs, struct strbuf *sb, int len = sb->len; if (len && sb->buf[len - 1] == '\n') sb->buf[--len] = '\0'; - ALLOC_GROW(prune->path, prune->nr+1, prune->alloc); + ALLOC_GROW(prune->path, prune->nr + 1, prune->alloc); prune->path[prune->nr++] = xstrdup(sb->buf); } } @@ -2134,7 +2134,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s * call init_pathspec() to set revs->prune_data here. * } */ - ALLOC_GROW(prune_data.path, prune_data.nr+1, prune_data.alloc); + ALLOC_GROW(prune_data.path, prune_data.nr + 1, prune_data.alloc); prune_data.path[prune_data.nr++] = NULL; parse_pathspec(&revs->prune_data, 0, 0, revs->prefix, prune_data.path); @@ -2987,7 +2987,7 @@ static struct commit *get_revision_internal(struct rev_info *revs) if (revs->max_count) { c = get_revision_1(revs); if (c) { - while (0 < revs->skip_count) { + while (revs->skip_count > 0) { revs->skip_count--; c = get_revision_1(revs); if (!c) @@ -3002,9 +3002,8 @@ static struct commit *get_revision_internal(struct rev_info *revs) if (c) c->object.flags |= SHOWN; - if (!revs->boundary) { + if (!revs->boundary) return c; - } if (!c) { /* @@ -3050,9 +3049,8 @@ struct commit *get_revision(struct rev_info *revs) if (revs->reverse) { reversed = NULL; - while ((c = get_revision_internal(revs))) { + while ((c = get_revision_internal(revs))) commit_list_insert(c, &reversed); - } revs->commits = reversed; revs->reverse = 0; revs->reverse_output_stage = 1; From 4e7e4b6b1bd3412a30ac577d06907ab47ede9483 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 31 Oct 2013 03:25:44 -0600 Subject: [PATCH 11/13] diff: trivial style fix Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- builtin/diff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/diff.c b/builtin/diff.c index 2fb8c5dc0b..adb93a9efa 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -169,7 +169,7 @@ static int builtin_diff_tree(struct rev_info *revs, if (ent1->item->flags & UNINTERESTING) swap = 1; sha1[swap] = ent0->item->sha1; - sha1[1-swap] = ent1->item->sha1; + sha1[1 - swap] = ent1->item->sha1; diff_tree_sha1(sha1[0], sha1[1], "", &revs->diffopt); log_tree_diff_flush(revs); return 0; From 5a50085c6b4dd7838167c6ce04042b4b563d8916 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 31 Oct 2013 03:25:45 -0600 Subject: [PATCH 12/13] run-command: trivial style fixes Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- run-command.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/run-command.c b/run-command.c index 1b7f88eeb1..3914d9c511 100644 --- a/run-command.c +++ b/run-command.c @@ -406,13 +406,12 @@ int start_command(struct child_process *cmd) unsetenv(*cmd->env); } } - if (cmd->git_cmd) { + if (cmd->git_cmd) execv_git_cmd(cmd->argv); - } else if (cmd->use_shell) { + else if (cmd->use_shell) execv_shell_cmd(cmd->argv); - } else { + else sane_execvp(cmd->argv[0], (char *const*) cmd->argv); - } if (errno == ENOENT) { if (!cmd->silent_exec_failure) error("cannot run %s: %s", cmd->argv[0], @@ -446,7 +445,6 @@ int start_command(struct child_process *cmd) cmd->pid = -1; } close(notify_pipe[0]); - } #else { @@ -480,11 +478,10 @@ int start_command(struct child_process *cmd) if (cmd->env) env = make_augmented_environ(cmd->env); - if (cmd->git_cmd) { + if (cmd->git_cmd) cmd->argv = prepare_git_cmd(cmd->argv); - } else if (cmd->use_shell) { + else if (cmd->use_shell) cmd->argv = prepare_shell_cmd(cmd->argv); - } cmd->pid = mingw_spawnvpe(cmd->argv[0], cmd->argv, env, cmd->dir, fhin, fhout, fherr); From abf03eeb8e99538cd31806d5f252214b9fe695a6 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 31 Oct 2013 03:25:46 -0600 Subject: [PATCH 13/13] setup: trivial style fixes Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.c b/setup.c index dbf4138720..5432a31b62 100644 --- a/setup.c +++ b/setup.c @@ -563,7 +563,7 @@ static const char *setup_git_directory_gently_1(int *nongit_ok) { const char *env_ceiling_dirs = getenv(CEILING_DIRECTORIES_ENVIRONMENT); struct string_list ceiling_dirs = STRING_LIST_INIT_DUP; - static char cwd[PATH_MAX+1]; + static char cwd[PATH_MAX + 1]; const char *gitdirenv, *ret; char *gitfile; int len, offset, offset_parent, ceil_offset = -1; @@ -578,7 +578,7 @@ static const char *setup_git_directory_gently_1(int *nongit_ok) if (nongit_ok) *nongit_ok = 0; - if (!getcwd(cwd, sizeof(cwd)-1)) + if (!getcwd(cwd, sizeof(cwd) - 1)) die_errno("Unable to read current working directory"); offset = len = strlen(cwd);