]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'nv/commit-gpgsign-config'
authorJunio C Hamano <gitster@pobox.com>
Thu, 27 Feb 2014 22:01:03 +0000 (14:01 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 27 Feb 2014 22:01:03 +0000 (14:01 -0800)
Introduce commit.gpgsign configuration variable to force every
commit to be GPG signed.  The variable cannot be overriden from the
command line of some of the commands that create commits except for
"git commit" and "git commit-tree", but I am not convinced that it
is a good idea to sprinkle support for --no-gpg-sign everywhere,
which in turn means that this configuration variable may not be
such a good idea.

* nv/commit-gpgsign-config:
  test the commit.gpgsign config option
  commit-tree: add and document --no-gpg-sign
  commit-tree: add the commit.gpgsign option to sign all commits

1  2 
Documentation/config.txt
builtin/commit.c
builtin/merge.c

diff --combined Documentation/config.txt
index 5f4d7939ed1ec267e7f282624e5bb480e72d7a33,1672284746ef2a3c25f30885622dd3afa5d807ee..a23392ca6ab5c637bcb32400cc83b017b63bbfb4
@@@ -567,10 -567,6 +567,10 @@@ be passed to the shell by Git, which wi
  command to `LESS=FRSX less -+S`. The environment tells the command
  to set the `S` option to chop long lines but the command line
  resets it to the default to fold long lines.
 ++
 +Likewise, when the `LV` environment variable is unset, Git sets it
 +to `-c`.  You can override this setting by exporting `LV` with
 +another value or setting `core.pager` to `lv +c`.
  
  core.whitespace::
        A comma separated list of common whitespace problems to
@@@ -992,6 -988,14 +992,14 @@@ commit.cleanup:
        have to remove the help lines that begin with `#` in the commit log
        template yourself, if you do this).
  
+ commit.gpgsign::
+       A boolean to specify whether all commits should be GPG signed.
+       Use of this option when doing operations such as rebase can
+       result in a large number of commits being signed. It may be
+       convenient to use an agent to avoid typing your GPG passphrase
+       several times.
  commit.status::
        A boolean to enable/disable inclusion of status information in the
        commit message template when using an editor to prepare the commit
@@@ -2030,10 -2034,6 +2038,10 @@@ receive.updateserverinfo:
        If set to true, git-receive-pack will run git-update-server-info
        after receiving data from git-push and updating refs.
  
 +receive.shallowupdate::
 +      If set to true, .git/shallow can be updated when new refs
 +      require new shallow roots. Otherwise those refs are rejected.
 +
  remote.pushdefault::
        The remote to push to by default.  Overrides
        `branch.<name>.remote` for all branches, and is overridden by
@@@ -2095,8 -2095,8 +2103,8 @@@ remote.<name>.vcs:
  
  remote.<name>.prune::
        When set to true, fetching from this remote by default will also
 -      remove any remote-tracking branches which no longer exist on the
 -      remote (as if the `--prune` option was give on the command line).
 +      remove any remote-tracking references that no longer exist on the
 +      remote (as if the `--prune` option was given on the command line).
        Overrides `fetch.prune` settings, if any.
  
  remotes.<group>::
diff --combined builtin/commit.c
index 3767478c6ddb02cf8a4a418f8911102aeaacfbe8,cffddf210807b756385dee6c3f4618d77e949a42..9c51b129e856b9c00a93097dcebd5e8b9c5fe128
@@@ -733,7 -733,7 +733,7 @@@ static int prepare_to_commit(const cha
                                eol = nl - sb.buf;
                        else
                                eol = sb.len;
 -                      if (!prefixcmp(sb.buf + previous, "\nConflicts:\n")) {
 +                      if (starts_with(sb.buf + previous, "\nConflicts:\n")) {
                                ignore_footer = sb.len - previous;
                                break;
                        }
@@@ -904,7 -904,7 +904,7 @@@ static int rest_is_empty(struct strbuf 
                        eol = sb->len;
  
                if (strlen(sign_off_header) <= eol - i &&
 -                  !prefixcmp(sb->buf + i, sign_off_header)) {
 +                  starts_with(sb->buf + i, sign_off_header)) {
                        i = eol;
                        continue;
                }
@@@ -1183,7 -1183,7 +1183,7 @@@ static int git_status_config(const cha
  {
        struct wt_status *s = cb;
  
 -      if (!prefixcmp(k, "column."))
 +      if (starts_with(k, "column."))
                return git_column_config(k, v, "status", &s->colopts);
        if (!strcmp(k, "status.submodulesummary")) {
                int is_bool;
                s->display_comment_prefix = git_config_bool(k, v);
                return 0;
        }
 -      if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
 +      if (starts_with(k, "status.color.") || starts_with(k, "color.status.")) {
                int slot = parse_status_slot(k, 13);
                if (slot < 0)
                        return 0;
@@@ -1338,7 -1338,7 +1338,7 @@@ static void print_summary(const char *p
        commit = lookup_commit(sha1);
        if (!commit)
                die(_("couldn't look up newly created commit"));
 -      if (!commit || parse_commit(commit))
 +      if (parse_commit(commit))
                die(_("could not parse newly created commit"));
  
        strbuf_addstr(&format, "format:%h] %s");
  
        head = resolve_ref_unsafe("HEAD", junk_sha1, 0, NULL);
        printf("[%s%s ",
 -              !prefixcmp(head, "refs/heads/") ?
 +              starts_with(head, "refs/heads/") ?
                        head + 11 :
                        !strcmp(head, "HEAD") ?
                                _("detached HEAD") :
@@@ -1406,6 -1406,10 +1406,10 @@@ static int git_commit_config(const cha
        }
        if (!strcmp(k, "commit.cleanup"))
                return git_config_string(&cleanup_arg, k, v);
+       if (!strcmp(k, "commit.gpgsign")) {
+               sign_commit = git_config_bool(k, v) ? "" : NULL;
+               return 0;
+       }
  
        status = git_gpg_config(k, v, NULL);
        if (status)
@@@ -1505,7 -1509,7 +1509,7 @@@ int cmd_commit(int argc, const char **a
        struct strbuf sb = STRBUF_INIT;
        struct strbuf author_ident = STRBUF_INIT;
        const char *index_file, *reflog_msg;
 -      char *nl, *p;
 +      char *nl;
        unsigned char sha1[20];
        struct ref_lock *ref_lock;
        struct commit_list *parents = NULL, **pptr = &parents;
                current_head = NULL;
        else {
                current_head = lookup_commit_or_die(sha1, "HEAD");
 -              if (!current_head || parse_commit(current_head))
 +              if (parse_commit(current_head))
                        die(_("could not parse HEAD commit"));
        }
        argc = parse_and_validate_options(argc, argv, builtin_commit_options,
        }
  
        /* Truncate the message just before the diff, if any. */
 -      if (verbose) {
 -              p = strstr(sb.buf, "\ndiff --git ");
 -              if (p != NULL)
 -                      strbuf_setlen(&sb, p - sb.buf + 1);
 -      }
 +      if (verbose)
 +              wt_status_truncate_message_at_cut_line(&sb);
  
        if (cleanup_mode != CLEANUP_NONE)
                stripspace(&sb, cleanup_mode == CLEANUP_ALL);
diff --combined builtin/merge.c
index e576a7fdc619303a65e859920a1ab6936db2626c,fea27244557d5f0f7ab556a251cf0108a81f397a..f0cf1205faa66c5ae8b4603f04239f1efbd999d6
@@@ -186,6 -186,13 +186,6 @@@ static int option_parse_n(const struct 
        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"),
        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")),
@@@ -367,7 -374,7 +367,7 @@@ static void squash_message(struct commi
                        sha1_to_hex(commit->object.sha1));
                pretty_print_commit(&ctx, commit, &out);
        }
 -      if (write(fd, out.buf, out.len) < 0)
 +      if (write_in_full(fd, out.buf, out.len) != out.len)
                die_errno(_("Writing SQUASH_MSG"));
        if (close(fd))
                die_errno(_("Finishing SQUASH_MSG"));
@@@ -446,17 -453,17 +446,17 @@@ static void merge_name(const char *remo
                die(_("'%s' does not point to a commit"), remote);
  
        if (dwim_ref(remote, strlen(remote), branch_head, &found_ref) > 0) {
 -              if (!prefixcmp(found_ref, "refs/heads/")) {
 +              if (starts_with(found_ref, "refs/heads/")) {
                        strbuf_addf(msg, "%s\t\tbranch '%s' of .\n",
                                    sha1_to_hex(branch_head), remote);
                        goto cleanup;
                }
 -              if (!prefixcmp(found_ref, "refs/tags/")) {
 +              if (starts_with(found_ref, "refs/tags/")) {
                        strbuf_addf(msg, "%s\t\ttag '%s' of .\n",
                                    sha1_to_hex(branch_head), remote);
                        goto cleanup;
                }
 -              if (!prefixcmp(found_ref, "refs/remotes/")) {
 +              if (starts_with(found_ref, "refs/remotes/")) {
                        strbuf_addf(msg, "%s\t\tremote-tracking branch '%s' of .\n",
                                    sha1_to_hex(branch_head), remote);
                        goto cleanup;
@@@ -570,8 -577,8 +570,8 @@@ static int git_merge_config(const char 
  {
        int status;
  
 -      if (branch && !prefixcmp(k, "branch.") &&
 -              !prefixcmp(k + 7, branch) &&
 +      if (branch && starts_with(k, "branch.") &&
 +              starts_with(k + 7, branch) &&
                !strcmp(k + 7 + strlen(branch), ".mergeoptions")) {
                free(branch_mergeoptions);
                branch_mergeoptions = xstrdup(v);
        } else if (!strcmp(k, "merge.defaulttoupstream")) {
                default_to_upstream = git_config_bool(k, v);
                return 0;
+       } else if (!strcmp(k, "commit.gpgsign")) {
+               sign_commit = git_config_bool(k, v) ? "" : NULL;
+               return 0;
        }
  
        status = fmt_merge_msg_config(k, v, cb);
@@@ -1106,7 -1116,7 +1109,7 @@@ int cmd_merge(int argc, const char **ar
         * current branch.
         */
        branch = branch_to_free = resolve_refdup("HEAD", head_sha1, 0, &flag);
 -      if (branch && !prefixcmp(branch, "refs/heads/"))
 +      if (branch && starts_with(branch, "refs/heads/"))
                branch += 11;
        if (!branch || is_null_sha1(head_sha1))
                head_commit = NULL;