Merge branch 'mh/cherry-default'
authorJunio C Hamano <gitster@pobox.com>
Wed, 14 Jan 2009 07:09:09 +0000 (23:09 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Jan 2009 07:09:09 +0000 (23:09 -0800)
* mh/cherry-default:
Documentation: clarify which parameters are optional to git-cherry
git-cherry: make <upstream> parameter optional

1  2 
builtin-log.c
diff --combined builtin-log.c
index 4a02ee987ac421f3a89a53873f00d50760cd0044,7e9616e5e73aaaeaa4ff06feaf7ddfbd077923cf..c1e2c6a4c53a7b1b40f3868a0288a6be4c7cb247
@@@ -16,6 -16,7 +16,7 @@@
  #include "patch-ids.h"
  #include "run-command.h"
  #include "shortlog.h"
+ #include "remote.h"
  
  /* Set a default date-time format for git log ("log.date" config variable) */
  static const char *default_date_mode = NULL;
@@@ -249,13 -250,22 +250,13 @@@ int cmd_whatchanged(int argc, const cha
  
  static void show_tagger(char *buf, int len, struct rev_info *rev)
  {
 -      char *email_end, *p;
 -      unsigned long date;
 -      int tz;
 +      struct strbuf out = STRBUF_INIT;
  
 -      email_end = memchr(buf, '>', len);
 -      if (!email_end)
 -              return;
 -      p = ++email_end;
 -      while (isspace(*p))
 -              p++;
 -      date = strtoul(p, &p, 10);
 -      while (isspace(*p))
 -              p++;
 -      tz = (int)strtol(p, NULL, 10);
 -      printf("Tagger: %.*s\nDate:   %s\n", (int)(email_end - buf), buf,
 -             show_date(date, tz, rev->date_mode));
 +      pp_user_info("Tagger", rev->commit_format, &out, buf, rev->date_mode,
 +              git_log_output_encoding ?
 +              git_log_output_encoding: git_commit_encoding);
 +      printf("%s\n", out.buf);
 +      strbuf_release(&out);
  }
  
  static int show_object(const unsigned char *sha1, int show_tag_object,
@@@ -815,7 -825,7 +816,7 @@@ int cmd_format_patch(int argc, const ch
                        committer = git_committer_info(IDENT_ERROR_ON_NO_NAME);
                        endpos = strchr(committer, '>');
                        if (!endpos)
 -                              die("bogus committer info %s\n", committer);
 +                              die("bogus committer info %s", committer);
                        add_signoff = xmemdupz(committer, endpos - committer + 1);
                }
                else if (!strcmp(argv[i], "--attach")) {
@@@ -1061,13 -1071,14 +1062,14 @@@ static int add_pending_commit(const cha
  }
  
  static const char cherry_usage[] =
- "git cherry [-v] <upstream> [<head>] [<limit>]";
+ "git cherry [-v] [<upstream> [<head> [<limit>]]]";
  int cmd_cherry(int argc, const char **argv, const char *prefix)
  {
        struct rev_info revs;
        struct patch_ids ids;
        struct commit *commit;
        struct commit_list *list = NULL;
+       struct branch *current_branch;
        const char *upstream;
        const char *head = "HEAD";
        const char *limit = NULL;
                upstream = argv[1];
                break;
        default:
-               usage(cherry_usage);
+               current_branch = branch_get(NULL);
+               if (!current_branch || !current_branch->merge
+                                       || !current_branch->merge[0]
+                                       || !current_branch->merge[0]->dst) {
+                       fprintf(stderr, "Could not find a tracked"
+                                       " remote branch, please"
+                                       " specify <upstream> manually.\n");
+                       usage(cherry_usage);
+               }
+               upstream = current_branch->merge[0]->dst;
        }
  
        init_revisions(&revs, prefix);