Code

Merge branch 'jc/request-pull-show-head-4'
authorJunio C Hamano <gitster@pobox.com>
Fri, 9 Dec 2011 21:37:05 +0000 (13:37 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 Dec 2011 21:37:05 +0000 (13:37 -0800)
* jc/request-pull-show-head-4:
  request-pull: use the annotated tag contents
  fmt-merge-msg.c: Fix an "dubious one-bit signed bitfield" sparse error
  environment.c: Fix an sparse "symbol not declared" warning
  builtin/log.c: Fix an "Using plain integer as NULL pointer" warning
  fmt-merge-msg: use branch.$name.description
  request-pull: use the branch description
  request-pull: state what commit to expect
  request-pull: modernize style
  branch: teach --edit-description option
  format-patch: use branch description in cover letter
  branch: add read_branch_desc() helper function

Conflicts:
builtin/branch.c

1  2 
Documentation/git-branch.txt
Makefile
branch.c
builtin/branch.c
builtin/fmt-merge-msg.c
builtin/merge.c
environment.c

Simple merge
diff --cc Makefile
Simple merge
diff --cc branch.c
Simple merge
index 55cad766c7e3d284b1361b1beca8c5d51de96083,fffa319e0e2e0ca86815e14641213a581634caf6..ad02f0fd7e8819f436baf27d7836cc181d613bab
@@@ -623,11 -606,49 +623,49 @@@ static int opt_parse_merge_filter(cons
        return 0;
  }
  
+ static const char edit_description[] = "BRANCH_DESCRIPTION";
+ static int edit_branch_description(const char *branch_name)
+ {
+       FILE *fp;
+       int status;
+       struct strbuf buf = STRBUF_INIT;
+       struct strbuf name = STRBUF_INIT;
+       read_branch_desc(&buf, branch_name);
+       if (!buf.len || buf.buf[buf.len-1] != '\n')
+               strbuf_addch(&buf, '\n');
+       strbuf_addf(&buf,
+                   "# Please edit the description for the branch\n"
+                   "#   %s\n"
+                   "# Lines starting with '#' will be stripped.\n",
+                   branch_name);
+       fp = fopen(git_path(edit_description), "w");
+       if ((fwrite(buf.buf, 1, buf.len, fp) < buf.len) || fclose(fp)) {
+               strbuf_release(&buf);
+               return error(_("could not write branch description template: %s\n"),
+                            strerror(errno));
+       }
+       strbuf_reset(&buf);
+       if (launch_editor(git_path(edit_description), &buf, NULL)) {
+               strbuf_release(&buf);
+               return -1;
+       }
+       stripspace(&buf, 1);
+       strbuf_addf(&name, "branch.%s.description", branch_name);
+       status = git_config_set(name.buf, buf.buf);
+       strbuf_release(&name);
+       strbuf_release(&buf);
+       return status;
+ }
  int cmd_branch(int argc, const char **argv, const char *prefix)
  {
 -      int delete = 0, rename = 0, force_create = 0;
 +      int delete = 0, rename = 0, force_create = 0, list = 0;
        int verbose = 0, abbrev = -1, detached = 0;
-       int reflog = 0;
+       int reflog = 0, edit_description = 0;
        enum branch_track track;
        int kinds = REF_LOCAL_BRANCH;
        struct commit_list *with_commit = NULL;
                OPT__ABBREV(&abbrev),
  
                OPT_GROUP("Specific git-branch actions:"),
 -              OPT_SET_INT('a', NULL, &kinds, "list both remote-tracking and local branches",
 +              OPT_SET_INT('a', "all", &kinds, "list both remote-tracking and local branches",
                        REF_REMOTE_BRANCH | REF_LOCAL_BRANCH),
 -              OPT_BIT('d', NULL, &delete, "delete fully merged branch", 1),
 +              OPT_BIT('d', "delete", &delete, "delete fully merged branch", 1),
                OPT_BIT('D', NULL, &delete, "delete branch (even if not merged)", 2),
 -              OPT_BIT('m', NULL, &rename, "move/rename a branch and its reflog", 1),
 +              OPT_BIT('m', "move", &rename, "move/rename a branch and its reflog", 1),
                OPT_BIT('M', NULL, &rename, "move/rename a branch, even if target exists", 2),
 -              OPT_BOOLEAN('l', NULL, &reflog, "create the branch's reflog"),
 +              OPT_BOOLEAN(0, "list", &list, "list branch names"),
 +              OPT_BOOLEAN('l', "create-reflog", &reflog, "create the branch's reflog"),
+               OPT_BOOLEAN(0, "edit-description", &edit_description,
+                           "edit the description for the branch"),
                OPT__FORCE(&force_create, "force creation (when already exists)"),
                {
                        OPTION_CALLBACK, 0, "no-merged", &merge_filter_ref,
  
        argc = parse_options(argc, argv, prefix, options, builtin_branch_usage,
                             0);
 -      if (!!delete + !!rename + !!force_create > 1)
 +
-       if (!delete && !rename && argc == 0)
++      if (!delete && !rename && !edit_description && argc == 0)
 +              list = 1;
 +
 +      if (!!delete + !!rename + !!force_create + !!list > 1)
                usage_with_options(builtin_branch_usage, options);
  
        if (abbrev == -1)
  
        if (delete)
                return delete_branches(argc, argv, delete > 1, kinds);
-       else if (rename) {
 +      else if (list)
 +              return print_ref_list(kinds, detached, verbose, abbrev,
 +                                    with_commit, argv);
 -      } else if (argc == 0)
 -              return print_ref_list(kinds, detached, verbose, abbrev, with_commit);
 -      else if (rename && (argc == 1))
 -              rename_branch(head, argv[0], rename > 1);
 -      else if (rename && (argc == 2))
 -              rename_branch(argv[0], argv[1], rename > 1);
 -      else if (argc <= 2) {
+       else if (edit_description) {
+               const char *branch_name;
+               if (detached)
+                       die("Cannot give description to detached HEAD");
+               if (!argc)
+                       branch_name = head;
+               else if (argc == 1)
+                       branch_name = argv[0];
+               else
+                       usage_with_options(builtin_branch_usage, options);
+               if (edit_branch_description(branch_name))
+                       return 1;
++      } else if (rename) {
 +              if (argc == 1)
 +                      rename_branch(head, argv[0], rename > 1);
 +              else if (argc == 2)
 +                      rename_branch(argv[0], argv[1], rename > 1);
 +              else
 +                      usage_with_options(builtin_branch_usage, options);
 +      } else if (argc > 0 && argc <= 2) {
                if (kinds != REF_LOCAL_BRANCH)
                        die(_("-a and -r options to 'git branch' do not make sense with a branch name"));
                create_branch(head, argv[0], (argc == 2) ? argv[1] : head,
Simple merge
diff --cc builtin/merge.c
index 8a7bebd96acfb8f627352216ca2f8e344e8d4a53,b8f25dd44e2d85fc607dd18c540db443036f08f9..3fc54923b500712097a4918f14a1e58b261e34c4
@@@ -44,9 -45,9 +45,9 @@@ static const char * const builtin_merge
        NULL
  };
  
- static int show_diffstat = 1, shortlog_len, squash;
+ static int show_diffstat = 1, shortlog_len = -1, squash;
  static int option_commit = 1, allow_fast_forward = 1;
 -static int fast_forward_only;
 +static int fast_forward_only, option_edit;
  static int allow_trivial = 1, have_message;
  static struct strbuf merge_msg;
  static struct commit_list *remoteheads;
diff --cc environment.c
Simple merge