Merge branch 'nd/const-struct-cache-entry'
authorJunio C Hamano <gitster@pobox.com>
Mon, 22 Jul 2013 18:24:00 +0000 (11:24 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Jul 2013 18:24:01 +0000 (11:24 -0700)
* nd/const-struct-cache-entry:
Convert "struct cache_entry *" to "const ..." wherever possible

1  2 
builtin/apply.c
builtin/checkout.c
builtin/commit.c
builtin/merge.c
cache.h
diff.c
dir.c
entry.c
sha1_name.c
submodule.c
wt-status.c
diff --combined builtin/apply.c
index 240a05c2d209478dc0d825ec07e636b50738bbf2,023bb3aada5269d8c7cfa4cd095bfeb6cc610e66..64310cd678d67c88de459e99ba577a1228378fa4
@@@ -722,7 -722,7 +722,7 @@@ static char *find_name(const char *line
  
  static char *find_name_traditional(const char *line, char *def, int p_value)
  {
 -      size_t len = strlen(line);
 +      size_t len;
        size_t date_len;
  
        if (*line == '"') {
@@@ -2999,7 -2999,7 +2999,7 @@@ static int read_blob_object(struct strb
        return 0;
  }
  
- static int read_file_or_gitlink(struct cache_entry *ce, struct strbuf *buf)
+ static int read_file_or_gitlink(const struct cache_entry *ce, struct strbuf *buf)
  {
        if (!ce)
                return 0;
@@@ -3117,7 -3117,7 +3117,7 @@@ static struct patch *previous_patch(str
        return previous;
  }
  
- static int verify_index_match(struct cache_entry *ce, struct stat *st)
+ static int verify_index_match(const struct cache_entry *ce, struct stat *st)
  {
        if (S_ISGITLINK(ce->ce_mode)) {
                if (!S_ISDIR(st->st_mode))
  #define SUBMODULE_PATCH_WITHOUT_INDEX 1
  
  static int load_patch_target(struct strbuf *buf,
-                            struct cache_entry *ce,
+                            const struct cache_entry *ce,
                             struct stat *st,
                             const char *name,
                             unsigned expected_mode)
   * we read from the result of a previous diff.
   */
  static int load_preimage(struct image *image,
-                        struct patch *patch, struct stat *st, struct cache_entry *ce)
+                        struct patch *patch, struct stat *st,
+                        const struct cache_entry *ce)
  {
        struct strbuf buf = STRBUF_INIT;
        size_t len;
@@@ -3273,7 -3274,7 +3274,7 @@@ static int load_current(struct image *i
  }
  
  static int try_threeway(struct image *image, struct patch *patch,
-                       struct stat *st, struct cache_entry *ce)
+                       struct stat *st, const struct cache_entry *ce)
  {
        unsigned char pre_sha1[20], post_sha1[20], our_sha1[20];
        struct strbuf buf = STRBUF_INIT;
        return 0;
  }
  
- static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *ce)
+ static int apply_data(struct patch *patch, struct stat *st, const struct cache_entry *ce)
  {
        struct image image;
  
@@@ -3847,7 -3848,7 +3848,7 @@@ static void add_index_file(const char *
                const char *s = buf;
  
                if (get_sha1_hex(s + strlen("Subproject commit "), ce->sha1))
 -                      die(_("corrupt patch for subproject %s"), path);
 +                      die(_("corrupt patch for submodule %s"), path);
        } else {
                if (!cached) {
                        if (lstat(path, &st) < 0)
diff --combined builtin/checkout.c
index 7fe0bffaf8b875b40b5e4e0e5c207f978c932691,69f9efa757f2496a8dc5674e2c35d3213457c274..7025938ae30f2ce3104b27f66bf6e1f294edb810
@@@ -97,7 -97,7 +97,7 @@@ static int read_tree_some(struct tree *
        return 0;
  }
  
- static int skip_same_name(struct cache_entry *ce, int pos)
+ static int skip_same_name(const struct cache_entry *ce, int pos)
  {
        while (++pos < active_nr &&
               !strcmp(active_cache[pos]->name, ce->name))
        return pos;
  }
  
- static int check_stage(int stage, struct cache_entry *ce, int pos)
+ static int check_stage(int stage, const struct cache_entry *ce, int pos)
  {
        while (pos < active_nr &&
               !strcmp(active_cache[pos]->name, ce->name)) {
                return error(_("path '%s' does not have their version"), ce->name);
  }
  
- static int check_stages(unsigned stages, struct cache_entry *ce, int pos)
+ static int check_stages(unsigned stages, const struct cache_entry *ce, int pos)
  {
        unsigned seen = 0;
        const char *name = ce->name;
@@@ -321,7 -321,7 +321,7 @@@ static int checkout_paths(const struct 
  
        /* Any unmerged paths? */
        for (pos = 0; pos < active_nr; pos++) {
-               struct cache_entry *ce = active_cache[pos];
+               const struct cache_entry *ce = active_cache[pos];
                if (ce->ce_flags & CE_MATCHED) {
                        if (!ce_stage(ce))
                                continue;
@@@ -587,7 -587,7 +587,7 @@@ static void update_refs_for_switch(cons
                                   struct branch_info *new)
  {
        struct strbuf msg = STRBUF_INIT;
 -      const char *old_desc;
 +      const char *old_desc, *reflog_msg;
        if (opts->new_branch) {
                if (opts->new_orphan_branch) {
                        if (opts->new_branch_log && !log_all_ref_updates) {
        old_desc = old->name;
        if (!old_desc && old->commit)
                old_desc = sha1_to_hex(old->commit->object.sha1);
 -      strbuf_addf(&msg, "checkout: moving from %s to %s",
 -                  old_desc ? old_desc : "(invalid)", new->name);
 +
 +      reflog_msg = getenv("GIT_REFLOG_ACTION");
 +      if (!reflog_msg)
 +              strbuf_addf(&msg, "checkout: moving from %s to %s",
 +                      old_desc ? old_desc : "(invalid)", new->name);
 +      else
 +              strbuf_insert(&msg, 0, reflog_msg, strlen(reflog_msg));
  
        if (!strcmp(new->name, "HEAD") && !new->path && !opts->force_detach) {
                /* Nothing to do. */
diff --combined builtin/commit.c
index 790e5ab5cfee7b0f5760aafed7bf6f3f5927871e,c9cbb811b031096a8e448567510f539c56693612..65cf2a79b71021cc456634a52bc8ba6f73260bc1
@@@ -112,14 -112,12 +112,14 @@@ static int show_ignored_in_status, have
  static const char *only_include_assumed;
  static struct strbuf message = STRBUF_INIT;
  
 -static enum {
 +static enum status_format {
        STATUS_FORMAT_NONE = 0,
        STATUS_FORMAT_LONG,
        STATUS_FORMAT_SHORT,
 -      STATUS_FORMAT_PORCELAIN
 -} status_format;
 +      STATUS_FORMAT_PORCELAIN,
 +
 +      STATUS_FORMAT_UNSPECIFIED
 +} status_format = STATUS_FORMAT_UNSPECIFIED;
  
  static int opt_parse_m(const struct option *opt, const char *arg, int unset)
  {
@@@ -207,7 -205,7 +207,7 @@@ static int list_paths(struct string_lis
        }
  
        for (i = 0; i < active_nr; i++) {
-               struct cache_entry *ce = active_cache[i];
+               const struct cache_entry *ce = active_cache[i];
                struct string_list_item *item;
  
                if (ce->ce_flags & CE_UPDATE)
@@@ -462,9 -460,6 +462,9 @@@ static int run_status(FILE *fp, const c
        case STATUS_FORMAT_PORCELAIN:
                wt_porcelain_print(s);
                break;
 +      case STATUS_FORMAT_UNSPECIFIED:
 +              die("BUG: finalize_deferred_config() should have been called");
 +              break;
        case STATUS_FORMAT_NONE:
        case STATUS_FORMAT_LONG:
                wt_status_print(s);
@@@ -966,42 -961,6 +966,42 @@@ static const char *read_commit_message(
        return logmsg_reencode(commit, NULL, out_enc);
  }
  
 +/*
 + * Enumerate what needs to be propagated when --porcelain
 + * is not in effect here.
 + */
 +static struct status_deferred_config {
 +      enum status_format status_format;
 +      int show_branch;
 +} status_deferred_config = {
 +      STATUS_FORMAT_UNSPECIFIED,
 +      -1 /* unspecified */
 +};
 +
 +static void finalize_deferred_config(struct wt_status *s)
 +{
 +      int use_deferred_config = (status_format != STATUS_FORMAT_PORCELAIN &&
 +                                 !s->null_termination);
 +
 +      if (s->null_termination) {
 +              if (status_format == STATUS_FORMAT_NONE ||
 +                  status_format == STATUS_FORMAT_UNSPECIFIED)
 +                      status_format = STATUS_FORMAT_PORCELAIN;
 +              else if (status_format == STATUS_FORMAT_LONG)
 +                      die(_("--long and -z are incompatible"));
 +      }
 +
 +      if (use_deferred_config && status_format == STATUS_FORMAT_UNSPECIFIED)
 +              status_format = status_deferred_config.status_format;
 +      if (status_format == STATUS_FORMAT_UNSPECIFIED)
 +              status_format = STATUS_FORMAT_NONE;
 +
 +      if (use_deferred_config && s->show_branch < 0)
 +              s->show_branch = status_deferred_config.show_branch;
 +      if (s->show_branch < 0)
 +              s->show_branch = 0;
 +}
 +
  static int parse_and_validate_options(int argc, const char *argv[],
                                      const struct option *options,
                                      const char * const usage[],
        int f = 0;
  
        argc = parse_options(argc, argv, prefix, options, usage, 0);
 +      finalize_deferred_config(s);
  
        if (force_author && !strchr(force_author, '>'))
                force_author = find_author_by_nickname(force_author);
        if (all && argc > 0)
                die(_("Paths with -a does not make sense."));
  
 -      if (s->null_termination) {
 -              if (status_format == STATUS_FORMAT_NONE)
 -                      status_format = STATUS_FORMAT_PORCELAIN;
 -              else if (status_format == STATUS_FORMAT_LONG)
 -                      die(_("--long and -z are incompatible"));
 -      }
        if (status_format != STATUS_FORMAT_NONE)
                dry_run = 1;
  
@@@ -1149,17 -1113,6 +1149,17 @@@ static int git_status_config(const cha
                        s->submodule_summary = -1;
                return 0;
        }
 +      if (!strcmp(k, "status.short")) {
 +              if (git_config_bool(k, v))
 +                      status_deferred_config.status_format = STATUS_FORMAT_SHORT;
 +              else
 +                      status_deferred_config.status_format = STATUS_FORMAT_NONE;
 +              return 0;
 +      }
 +      if (!strcmp(k, "status.branch")) {
 +              status_deferred_config.show_branch = git_config_bool(k, v);
 +              return 0;
 +      }
        if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
                s->use_color = git_config_colorbool(k, v);
                return 0;
@@@ -1202,8 -1155,8 +1202,8 @@@ int cmd_status(int argc, const char **a
                OPT__VERBOSE(&verbose, N_("be verbose")),
                OPT_SET_INT('s', "short", &status_format,
                            N_("show status concisely"), STATUS_FORMAT_SHORT),
 -              OPT_BOOLEAN('b', "branch", &s.show_branch,
 -                          N_("show branch information")),
 +              OPT_BOOL('b', "branch", &s.show_branch,
 +                       N_("show branch information")),
                OPT_SET_INT(0, "porcelain", &status_format,
                            N_("machine-readable output"),
                            STATUS_FORMAT_PORCELAIN),
                             builtin_status_options,
                             builtin_status_usage, 0);
        finalize_colopts(&s.colopts, -1);
 -
 -      if (s.null_termination) {
 -              if (status_format == STATUS_FORMAT_NONE)
 -                      status_format = STATUS_FORMAT_PORCELAIN;
 -              else if (status_format == STATUS_FORMAT_LONG)
 -                      die(_("--long and -z are incompatible"));
 -      }
 +      finalize_deferred_config(&s);
  
        handle_untracked_files_arg(&s);
        if (show_ignored_in_status)
        case STATUS_FORMAT_PORCELAIN:
                wt_porcelain_print(&s);
                break;
 +      case STATUS_FORMAT_UNSPECIFIED:
 +              die("BUG: finalize_deferred_config() should have been called");
 +              break;
        case STATUS_FORMAT_NONE:
        case STATUS_FORMAT_LONG:
                s.verbose = verbose;
@@@ -1436,7 -1392,7 +1436,7 @@@ int cmd_commit(int argc, const char **a
                OPT_BOOLEAN(0, "dry-run", &dry_run, N_("show what would be committed")),
                OPT_SET_INT(0, "short", &status_format, N_("show status concisely"),
                            STATUS_FORMAT_SHORT),
 -              OPT_BOOLEAN(0, "branch", &s.show_branch, N_("show branch information")),
 +              OPT_BOOL(0, "branch", &s.show_branch, N_("show branch information")),
                OPT_SET_INT(0, "porcelain", &status_format,
                            N_("machine-readable output"), STATUS_FORMAT_PORCELAIN),
                OPT_SET_INT(0, "long", &status_format,
        wt_status_prepare(&s);
        gitmodules_config();
        git_config(git_commit_config, &s);
 +      status_format = STATUS_FORMAT_NONE; /* Ignore status.short */
        determine_whence(&s);
        s.colopts = 0;
  
diff --combined builtin/merge.c
index 9505e7e426d302522f5e065d741fccd37290ea21,74c0746a93a249ff3c48401f040d8f1396d656f0..34a6166b520c8ede9973fbf497b21ac6ecb761ad
@@@ -47,8 -47,8 +47,8 @@@ static const char * const builtin_merge
  };
  
  static int show_diffstat = 1, shortlog_len = -1, squash;
 -static int option_commit = 1, allow_fast_forward = 1;
 -static int fast_forward_only, option_edit = -1;
 +static int option_commit = 1;
 +static int option_edit = -1;
  static int allow_trivial = 1, have_message, verify_signatures;
  static int overwrite_ignore = 1;
  static struct strbuf merge_msg = STRBUF_INIT;
@@@ -76,14 -76,6 +76,14 @@@ static struct strategy all_strategy[] 
  
  static const char *pull_twohead, *pull_octopus;
  
 +enum ff_type {
 +      FF_NO,
 +      FF_ALLOW,
 +      FF_ONLY
 +};
 +
 +static enum ff_type fast_forward = FF_ALLOW;
 +
  static int option_parse_message(const struct option *opt,
                                const char *arg, int unset)
  {
@@@ -186,13 -178,6 +186,13 @@@ 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"),
                N_("perform a commit if the merge succeeds (default)")),
        OPT_BOOL('e', "edit", &option_edit,
                N_("edit message before committing")),
 -      OPT_BOOLEAN(0, "ff", &allow_fast_forward,
 -              N_("allow fast-forward (default)")),
 -      OPT_BOOLEAN(0, "ff-only", &fast_forward_only,
 -              N_("abort if fast-forward is not possible")),
 +      OPT_SET_INT(0, "ff", &fast_forward, N_("allow fast-forward (default)"), FF_ALLOW),
 +      { OPTION_CALLBACK, 0, "ff-only", NULL, NULL,
 +              N_("abort if fast-forward is not possible"),
 +              PARSE_OPT_NOARG | PARSE_OPT_NONEG, option_parse_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")),
@@@ -596,9 -581,10 +596,9 @@@ static int git_merge_config(const char 
        else if (!strcmp(k, "merge.ff")) {
                int boolval = git_config_maybe_bool(k, v);
                if (0 <= boolval) {
 -                      allow_fast_forward = boolval;
 +                      fast_forward = boolval ? FF_ALLOW : FF_NO;
                } else if (v && !strcmp(v, "only")) {
 -                      allow_fast_forward = 1;
 -                      fast_forward_only = 1;
 +                      fast_forward = FF_ONLY;
                } /* do not barf on values from future versions of git */
                return 0;
        } else if (!strcmp(k, "merge.defaulttoupstream")) {
@@@ -877,7 -863,7 +877,7 @@@ static int finish_automerge(struct comm
  
        free_commit_list(common);
        parents = remoteheads;
 -      if (!head_subsumed || !allow_fast_forward)
 +      if (!head_subsumed || fast_forward == FF_NO)
                commit_list_insert(head, &parents);
        strbuf_addch(&merge_msg, '\n');
        prepare_to_commit(remoteheads);
@@@ -903,7 -889,7 +903,7 @@@ static int suggest_conflicts(int renorm
                die_errno(_("Could not open '%s' for writing"), filename);
        fprintf(fp, "\nConflicts:\n");
        for (pos = 0; pos < active_nr; pos++) {
-               struct cache_entry *ce = active_cache[pos];
+               const struct cache_entry *ce = active_cache[pos];
  
                if (ce_stage(ce)) {
                        fprintf(fp, "\t%s\n", ce->name);
@@@ -962,7 -948,7 +962,7 @@@ static int evaluate_result(void
  }
  
  /*
 - * Pretend as if the user told us to merge with the tracking
 + * Pretend as if the user told us to merge with the remote-tracking
   * branch we have for the upstream of the current branch
   */
  static int setup_with_upstream(const char ***argv)
        args = xcalloc(branch->merge_nr + 1, sizeof(char *));
        for (i = 0; i < branch->merge_nr; i++) {
                if (!branch->merge[i]->dst)
 -                      die(_("No remote tracking branch for %s from %s"),
 +                      die(_("No remote-tracking branch for %s from %s"),
                            branch->merge[i]->src, branch->remote_name);
                args[i] = branch->merge[i]->dst;
        }
@@@ -1022,7 -1008,7 +1022,7 @@@ static void write_merge_state(struct co
        if (fd < 0)
                die_errno(_("Could not open '%s' for writing"), filename);
        strbuf_reset(&buf);
 -      if (!allow_fast_forward)
 +      if (fast_forward == FF_NO)
                strbuf_addf(&buf, "no-ff");
        if (write_in_full(fd, buf.buf, buf.len) != buf.len)
                die_errno(_("Could not write to '%s'"), filename);
@@@ -1171,11 -1157,14 +1171,11 @@@ int cmd_merge(int argc, const char **ar
                show_diffstat = 0;
  
        if (squash) {
 -              if (!allow_fast_forward)
 +              if (fast_forward == FF_NO)
                        die(_("You cannot combine --squash with --no-ff."));
                option_commit = 0;
        }
  
 -      if (!allow_fast_forward && fast_forward_only)
 -              die(_("You cannot combine --no-ff with --ff-only."));
 -
        if (!abort_current_merge) {
                if (!argc) {
                        if (default_to_upstream)
                                "empty head"));
                if (squash)
                        die(_("Squash commit into empty head not supported yet"));
 -              if (!allow_fast_forward)
 +              if (fast_forward == FF_NO)
                        die(_("Non-fast-forward commit does not make sense into "
                            "an empty head"));
                remoteheads = collect_parents(head_commit, &head_subsumed, argc, argv);
                            sha1_to_hex(commit->object.sha1));
                setenv(buf.buf, merge_remote_util(commit)->name, 1);
                strbuf_reset(&buf);
 -              if (!fast_forward_only &&
 +              if (fast_forward != FF_ONLY &&
                    merge_remote_util(commit) &&
                    merge_remote_util(commit)->obj &&
                    merge_remote_util(commit)->obj->type == OBJ_TAG)
 -                      allow_fast_forward = 0;
 +                      fast_forward = FF_NO;
        }
  
        if (option_edit < 0)
  
        for (i = 0; i < use_strategies_nr; i++) {
                if (use_strategies[i]->attr & NO_FAST_FORWARD)
 -                      allow_fast_forward = 0;
 +                      fast_forward = FF_NO;
                if (use_strategies[i]->attr & NO_TRIVIAL)
                        allow_trivial = 0;
        }
                 */
                finish_up_to_date("Already up-to-date.");
                goto done;
 -      } else if (allow_fast_forward && !remoteheads->next &&
 +      } else if (fast_forward != FF_NO && !remoteheads->next &&
                        !common->next &&
                        !hashcmp(common->item->object.sha1, head_commit->object.sha1)) {
                /* Again the most common case of merging one remote. */
                 * only one common.
                 */
                refresh_cache(REFRESH_QUIET);
 -              if (allow_trivial && !fast_forward_only) {
 +              if (allow_trivial && fast_forward != FF_ONLY) {
                        /* See if it is really trivial. */
                        git_committer_info(IDENT_STRICT);
                        printf(_("Trying really trivial in-index merge...\n"));
                }
        }
  
 -      if (fast_forward_only)
 +      if (fast_forward == FF_ONLY)
                die(_("Not possible to fast-forward, aborting."));
  
        /* We are going to make a new commit. */
diff --combined cache.h
index b89409bbf20a4fd64ae6aa278ee49b657f85ce39,430d021a2a60d1156a4e460862c01eb90b5725b2..48e147f8ba8591bb7577c76e3ab6947580c515da
+++ b/cache.h
@@@ -425,8 -425,6 +425,8 @@@ extern int path_inside_repo(const char 
  extern int set_git_dir_init(const char *git_dir, const char *real_git_dir, int);
  extern int init_db(const char *template_dir, unsigned int flags);
  
 +extern void sanitize_stdfds(void);
 +
  #define alloc_nr(x) (((x)+16)*3/2)
  
  /*
@@@ -478,7 -476,7 +478,7 @@@ extern int remove_file_from_index(struc
  extern int add_to_index(struct index_state *, const char *path, struct stat *, int flags);
  extern int add_file_to_index(struct index_state *, const char *path, int flags);
  extern struct cache_entry *make_cache_entry(unsigned int mode, const unsigned char *sha1, const char *path, int stage, int refresh);
- extern int ce_same_name(struct cache_entry *a, struct cache_entry *b);
+ extern int ce_same_name(const struct cache_entry *a, const struct cache_entry *b);
  extern int index_name_is_other(const struct index_state *, const char *, int);
  extern void *read_blob_data_from_index(struct index_state *, const char *, unsigned long *);
  
@@@ -1132,7 -1130,6 +1132,7 @@@ extern int unpack_object_header(struct 
  struct object_info {
        /* Request */
        unsigned long *sizep;
 +      unsigned long *disk_sizep;
  
        /* Response */
        enum {
diff --combined diff.c
index 0b1b5e7af8931692a81500c35e7e06ca60da876a,126abbf6d3da633c37115c0a5b1a81d0962bf820..a4583f01107c4534c1939ffcd5effcb959ea732e
--- 1/diff.c
--- 2/diff.c
+++ b/diff.c
@@@ -2586,7 -2586,7 +2586,7 @@@ void fill_filespec(struct diff_filespe
   */
  static int reuse_worktree_file(const char *name, const unsigned char *sha1, int want_file)
  {
-       struct cache_entry *ce;
+       const struct cache_entry *ce;
        struct stat st;
        int pos, len;
  
@@@ -2677,14 -2677,6 +2677,14 @@@ static int diff_populate_gitlink(struc
  int diff_populate_filespec(struct diff_filespec *s, int size_only)
  {
        int err = 0;
 +      /*
 +       * demote FAIL to WARN to allow inspecting the situation
 +       * instead of refusing.
 +       */
 +      enum safe_crlf crlf_warn = (safe_crlf == SAFE_CRLF_FAIL
 +                                  ? SAFE_CRLF_WARN
 +                                  : safe_crlf);
 +
        if (!DIFF_FILE_VALID(s))
                die("internal error: asking to populate invalid file.");
        if (S_ISDIR(s->mode))
                /*
                 * Convert from working tree format to canonical git format
                 */
 -              if (convert_to_git(s->path, s->data, s->size, &buf, safe_crlf)) {
 +              if (convert_to_git(s->path, s->data, s->size, &buf, crlf_warn)) {
                        size_t size = 0;
                        munmap(s->data, s->size);
                        s->should_munmap = 0;
@@@ -3505,11 -3497,6 +3505,11 @@@ static int parse_submodule_opt(struct d
        return 1;
  }
  
 +static void enable_patch_output(int *fmt) {
 +      *fmt &= ~DIFF_FORMAT_NO_OUTPUT;
 +      *fmt |= DIFF_FORMAT_PATCH;
 +}
 +
  int diff_opt_parse(struct diff_options *options, const char **av, int ac)
  {
        const char *arg = av[0];
        int argcount;
  
        /* Output format options */
 -      if (!strcmp(arg, "-p") || !strcmp(arg, "-u") || !strcmp(arg, "--patch"))
 -              options->output_format |= DIFF_FORMAT_PATCH;
 -      else if (opt_arg(arg, 'U', "unified", &options->context))
 -              options->output_format |= DIFF_FORMAT_PATCH;
 +      if (!strcmp(arg, "-p") || !strcmp(arg, "-u") || !strcmp(arg, "--patch")
 +          || opt_arg(arg, 'U', "unified", &options->context))
 +              enable_patch_output(&options->output_format);
        else if (!strcmp(arg, "--raw"))
                options->output_format |= DIFF_FORMAT_RAW;
 -      else if (!strcmp(arg, "--patch-with-raw"))
 -              options->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW;
 -      else if (!strcmp(arg, "--numstat"))
 +      else if (!strcmp(arg, "--patch-with-raw")) {
 +              enable_patch_output(&options->output_format);
 +              options->output_format |= DIFF_FORMAT_RAW;
 +      } else if (!strcmp(arg, "--numstat"))
                options->output_format |= DIFF_FORMAT_NUMSTAT;
        else if (!strcmp(arg, "--shortstat"))
                options->output_format |= DIFF_FORMAT_SHORTSTAT;
                options->output_format |= DIFF_FORMAT_CHECKDIFF;
        else if (!strcmp(arg, "--summary"))
                options->output_format |= DIFF_FORMAT_SUMMARY;
 -      else if (!strcmp(arg, "--patch-with-stat"))
 -              options->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT;
 -      else if (!strcmp(arg, "--name-only"))
 +      else if (!strcmp(arg, "--patch-with-stat")) {
 +              enable_patch_output(&options->output_format);
 +              options->output_format |= DIFF_FORMAT_DIFFSTAT;
 +      } else if (!strcmp(arg, "--name-only"))
                options->output_format |= DIFF_FORMAT_NAME;
        else if (!strcmp(arg, "--name-status"))
                options->output_format |= DIFF_FORMAT_NAME_STATUS;
 -      else if (!strcmp(arg, "-s"))
 +      else if (!strcmp(arg, "-s") || !strcmp(arg, "--no-patch"))
                options->output_format |= DIFF_FORMAT_NO_OUTPUT;
        else if (!prefixcmp(arg, "--stat"))
                /* --stat, --stat-width, --stat-name-width, or --stat-count */
  
        /* flags options */
        else if (!strcmp(arg, "--binary")) {
 -              options->output_format |= DIFF_FORMAT_PATCH;
 +              enable_patch_output(&options->output_format);
                DIFF_OPT_SET(options, BINARY);
        }
        else if (!strcmp(arg, "--full-index"))
diff --combined dir.c
index 048041954418315d73924b3d73c6f2c794a5edb1,bb1f4e4295e2dfd07e8a975495b8348c1b299f09..910bfcde4e432fae3bf57ec951258bc5a02bebb6
--- 1/dir.c
--- 2/dir.c
+++ b/dir.c
@@@ -933,7 -933,7 +933,7 @@@ enum exist_status 
   */
  static enum exist_status directory_exists_in_index_icase(const char *dirname, int len)
  {
-       struct cache_entry *ce = index_name_exists(&the_index, dirname, len + 1, ignore_case);
+       const struct cache_entry *ce = index_name_exists(&the_index, dirname, len + 1, ignore_case);
        unsigned char endchar;
  
        if (!ce)
@@@ -977,7 -977,7 +977,7 @@@ static enum exist_status directory_exis
        if (pos < 0)
                pos = -pos-1;
        while (pos < active_nr) {
-               struct cache_entry *ce = active_cache[pos++];
+               const struct cache_entry *ce = active_cache[pos++];
                unsigned char endchar;
  
                if (strncmp(ce->name, dirname, len))
@@@ -1036,7 -1036,9 +1036,7 @@@ static enum path_treatment treat_direct
                return path_recurse;
  
        case index_gitdir:
 -              if (dir->flags & DIR_SHOW_OTHER_DIRECTORIES)
 -                      return path_none;
 -              return path_untracked;
 +              return path_none;
  
        case index_nonexistent:
                if (dir->flags & DIR_SHOW_OTHER_DIRECTORIES)
@@@ -1113,7 -1115,7 +1113,7 @@@ static int exclude_matches_pathspec(con
  static int get_index_dtype(const char *path, int len)
  {
        int pos;
-       struct cache_entry *ce;
+       const struct cache_entry *ce;
  
        ce = cache_name_exists(path, len, 0);
        if (ce) {
diff --combined entry.c
index 6af4b6a0c3b6d8db3f8ceaaf8aa79f360be1e704,c6f7fd7d825e1222f0ba70a66d9f462277257fae..acc892f9a62b5bc3d3442b044b29bf8d763bf3ba
+++ b/entry.c
@@@ -79,7 -79,7 +79,7 @@@ static int create_file(const char *path
        return open(path, O_WRONLY | O_CREAT | O_EXCL, mode);
  }
  
- static void *read_blob_entry(struct cache_entry *ce, unsigned long *size)
+ static void *read_blob_entry(const struct cache_entry *ce, unsigned long *size)
  {
        enum object_type type;
        void *new = read_sha1_file(ce->sha1, &type, size);
@@@ -92,7 -92,7 +92,7 @@@
        return NULL;
  }
  
- static int open_output_fd(char *path, struct cache_entry *ce, int to_tempfile)
+ static int open_output_fd(char *path, const struct cache_entry *ce, int to_tempfile)
  {
        int symlink = (ce->ce_mode & S_IFMT) != S_IFREG;
        if (to_tempfile) {
@@@ -115,7 -115,7 +115,7 @@@ static int fstat_output(int fd, const s
        return 0;
  }
  
- static int streaming_write_entry(struct cache_entry *ce, char *path,
+ static int streaming_write_entry(const struct cache_entry *ce, char *path,
                                 struct stream_filter *filter,
                                 const struct checkout *state, int to_tempfile,
                                 int *fstat_done, struct stat *statbuf)
        return result;
  }
  
- static int write_entry(struct cache_entry *ce, char *path, const struct checkout *state, int to_tempfile)
+ static int write_entry(struct cache_entry *ce,
+                      char *path, const struct checkout *state, int to_tempfile)
  {
        unsigned int ce_mode_s_ifmt = ce->ce_mode & S_IFMT;
        int fd, ret, fstat_done = 0;
                break;
        case S_IFGITLINK:
                if (to_tempfile)
 -                      return error("cannot create temporary subproject %s", path);
 +                      return error("cannot create temporary submodule %s", path);
                if (mkdir(path, 0777) < 0)
 -                      return error("cannot create subproject directory %s", path);
 +                      return error("cannot create submodule directory %s", path);
                break;
        default:
                return error("unknown file mode for %s in index", path);
@@@ -233,7 -234,8 +234,8 @@@ static int check_path(const char *path
        return lstat(path, st);
  }
  
- int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath)
+ int checkout_entry(struct cache_entry *ce,
+                  const struct checkout *state, char *topath)
  {
        static char path[PATH_MAX + 1];
        struct stat st;
diff --combined sha1_name.c
index 1a75fac05feaefa3cc0c57896aa6ee70813a324a,86e8a5cd98a9d249e359f0418fe4d8d829c72681..543bf9d9eceb81f97107437b30f4f150270b949a
@@@ -241,7 -241,7 +241,7 @@@ static int disambiguate_committish_only
                return 0;
  
        /* We need to do this the hard way... */
 -      obj = deref_tag(lookup_object(sha1), NULL, 0);
 +      obj = deref_tag(parse_object(sha1), NULL, 0);
        if (obj && obj->type == OBJ_COMMIT)
                return 1;
        return 0;
@@@ -1234,7 -1234,7 +1234,7 @@@ static void diagnose_invalid_index_path
                                        const char *filename)
  {
        struct stat st;
-       struct cache_entry *ce;
+       const struct cache_entry *ce;
        int pos;
        unsigned namelen = strlen(filename);
        unsigned fullnamelen;
@@@ -1328,7 -1328,7 +1328,7 @@@ static int get_sha1_with_context_1(cons
         */
        if (name[0] == ':') {
                int stage = 0;
-               struct cache_entry *ce;
+               const struct cache_entry *ce;
                char *new_path = NULL;
                int pos;
                if (!only_to_die && namelen > 2 && name[1] == '/') {
diff --combined submodule.c
index 85415d0057402d40c4c9e98e3c94c41eb8dd940f,4045d5316bc584c55c731c985caca0c2875f670b..3f0a3f9419a3dead24cd8e850051f595d0b5974f
@@@ -226,7 -226,6 +226,7 @@@ static void print_submodule_summary(str
        while ((commit = get_revision(rev))) {
                struct pretty_print_context ctx = {0};
                ctx.date_mode = rev->date_mode;
 +              ctx.output_encoding = get_log_output_encoding();
                strbuf_setlen(&sb, 0);
                strbuf_addstr(&sb, line_prefix);
                if (commit->object.flags & SYMMETRIC_LEFT) {
@@@ -624,7 -623,7 +624,7 @@@ int fetch_populated_submodules(const st
                struct strbuf submodule_path = STRBUF_INIT;
                struct strbuf submodule_git_dir = STRBUF_INIT;
                struct strbuf submodule_prefix = STRBUF_INIT;
-               struct cache_entry *ce = active_cache[i];
+               const struct cache_entry *ce = active_cache[i];
                const char *git_dir, *name, *default_argv;
  
                if (!S_ISGITLINK(ce->ce_mode))
diff --combined wt-status.c
index 9c4d086b51364ff42a044be95e6ea55dffe7b79e,08aba7c75bc7899d39c8fbbee48e83ce6617de9e..bf1554cc4cfff1b11ddf0845f8d81d8376c8b049
@@@ -127,7 -127,6 +127,7 @@@ void wt_status_prepare(struct wt_statu
        s->change.strdup_strings = 1;
        s->untracked.strdup_strings = 1;
        s->ignored.strdup_strings = 1;
 +      s->show_branch = -1;  /* unspecified */
  }
  
  static void wt_status_print_unmerged_header(struct wt_status *s)
@@@ -372,7 -371,7 +372,7 @@@ static void wt_status_collect_changed_c
  static int unmerged_mask(const char *path)
  {
        int pos, mask;
-       struct cache_entry *ce;
+       const struct cache_entry *ce;
  
        pos = cache_name_pos(path, strlen(path));
        if (0 <= pos)
@@@ -476,7 -475,7 +476,7 @@@ static void wt_status_collect_changes_i
        for (i = 0; i < active_nr; i++) {
                struct string_list_item *it;
                struct wt_status_change_data *d;
-               struct cache_entry *ce = active_cache[i];
+               const struct cache_entry *ce = active_cache[i];
  
                if (!ce_path_match(ce, &pathspec))
                        continue;
@@@ -1038,6 -1037,7 +1038,6 @@@ got_nothing
  }
  
  struct grab_1st_switch_cbdata {
 -      int found;
        struct strbuf buf;
        unsigned char nsha1[20];
  };
@@@ -1061,6 -1061,7 +1061,6 @@@ static int grab_1st_switch(unsigned cha
        for (end = target; *end && *end != '\n'; end++)
                ;
        strbuf_add(&cb->buf, target, end - target);
 -      cb->found = 1;
        return 1;
  }
  
@@@ -1177,10 -1178,7 +1177,10 @@@ void wt_status_print(struct wt_status *
                        branch_name += 11;
                else if (!strcmp(branch_name, "HEAD")) {
                        branch_status_color = color(WT_STATUS_NOBRANCH, s);
 -                      if (state.detached_from) {
 +                      if (state.rebase_in_progress || state.rebase_interactive_in_progress) {
 +                              on_what = _("rebase in progress; onto ");
 +                              branch_name = state.onto;
 +                      } else if (state.detached_from) {
                                unsigned char sha1[20];
                                branch_name = state.detached_from;
                                if (!get_sha1("HEAD", sha1) &&