Merge branch 'jk/misc-unused-fixes'
authorJunio C Hamano <gitster@pobox.com>
Tue, 13 Nov 2018 13:37:26 +0000 (22:37 +0900)
committerJunio C Hamano <gitster@pobox.com>
Tue, 13 Nov 2018 13:37:26 +0000 (22:37 +0900)
Assorted fixes for bugs found while auditing -Wunused-parameter
warnings.

* jk/misc-unused-fixes:
approxidate: fix NULL dereference in date_time()
pathspec: handle non-terminated strings with :(attr)
approxidate: handle pending number for "specials"
rev-list: handle flags for --indexed-objects

1  2 
revision.c
diff --combined revision.c
index 59a3c22b8a6d9827721121727f5f903128d3812a,8e56c9641f8f8f9223249df05212415c5a37a6a5..bdd3e7c9f193415d073b78c220366ac69afa5c20
@@@ -1177,7 -1177,7 +1177,7 @@@ struct all_refs_cb 
        int warned_bad_reflog;
        struct rev_info *all_revs;
        const char *name_for_errormsg;
 -      struct ref_store *refs;
 +      struct worktree *wt;
  };
  
  int ref_excluded(struct string_list *ref_excludes, const char *path)
@@@ -1214,7 -1214,7 +1214,7 @@@ static void init_all_refs_cb(struct all
        cb->all_revs = revs;
        cb->all_flags = flags;
        revs->rev_input_given = 1;
 -      cb->refs = NULL;
 +      cb->wt = NULL;
  }
  
  void clear_ref_exclusion(struct string_list **ref_excludes_p)
@@@ -1277,20 -1277,14 +1277,20 @@@ static int handle_one_reflog_ent(struc
        return 0;
  }
  
 -static int handle_one_reflog(const char *path, const struct object_id *oid,
 +static int handle_one_reflog(const char *refname_in_wt,
 +                           const struct object_id *oid,
                             int flag, void *cb_data)
  {
        struct all_refs_cb *cb = cb_data;
 +      struct strbuf refname = STRBUF_INIT;
 +
        cb->warned_bad_reflog = 0;
 -      cb->name_for_errormsg = path;
 -      refs_for_each_reflog_ent(cb->refs, path,
 +      strbuf_worktree_ref(cb->wt, &refname, refname_in_wt);
 +      cb->name_for_errormsg = refname.buf;
 +      refs_for_each_reflog_ent(get_main_ref_store(the_repository),
 +                               refname.buf,
                                 handle_one_reflog_ent, cb_data);
 +      strbuf_release(&refname);
        return 0;
  }
  
@@@ -1305,8 -1299,8 +1305,8 @@@ static void add_other_reflogs_to_pendin
                if (wt->is_current)
                        continue;
  
 -              cb->refs = get_worktree_ref_store(wt);
 -              refs_for_each_reflog(cb->refs,
 +              cb->wt = wt;
 +              refs_for_each_reflog(get_worktree_ref_store(wt),
                                     handle_one_reflog,
                                     cb);
        }
@@@ -1319,7 -1313,7 +1319,7 @@@ void add_reflogs_to_pending(struct rev_
  
        cb.all_revs = revs;
        cb.all_flags = flags;
 -      cb.refs = get_main_ref_store(revs->repo);
 +      cb.wt = NULL;
        for_each_reflog(handle_one_reflog, &cb);
  
        if (!revs->single_worktree)
  }
  
  static void add_cache_tree(struct cache_tree *it, struct rev_info *revs,
-                          struct strbuf *path)
+                          struct strbuf *path, unsigned int flags)
  {
        size_t baselen = path->len;
        int i;
  
        if (it->entry_count >= 0) {
                struct tree *tree = lookup_tree(revs->repo, &it->oid);
+               tree->object.flags |= flags;
                add_pending_object_with_path(revs, &tree->object, "",
                                             040000, path->buf);
        }
        for (i = 0; i < it->subtree_nr; i++) {
                struct cache_tree_sub *sub = it->down[i];
                strbuf_addf(path, "%s%s", baselen ? "/" : "", sub->name);
-               add_cache_tree(sub->cache_tree, revs, path);
+               add_cache_tree(sub->cache_tree, revs, path, flags);
                strbuf_setlen(path, baselen);
        }
  
  }
  
  static void do_add_index_objects_to_pending(struct rev_info *revs,
-                                           struct index_state *istate)
+                                           struct index_state *istate,
+                                           unsigned int flags)
  {
        int i;
  
                blob = lookup_blob(revs->repo, &ce->oid);
                if (!blob)
                        die("unable to add index blob to traversal");
+               blob->object.flags |= flags;
                add_pending_object_with_path(revs, &blob->object, "",
                                             ce->ce_mode, ce->name);
        }
  
        if (istate->cache_tree) {
                struct strbuf path = STRBUF_INIT;
-               add_cache_tree(istate->cache_tree, revs, &path);
+               add_cache_tree(istate->cache_tree, revs, &path, flags);
                strbuf_release(&path);
        }
  }
@@@ -1378,7 -1375,7 +1381,7 @@@ void add_index_objects_to_pending(struc
        struct worktree **worktrees, **p;
  
        read_index(revs->repo->index);
-       do_add_index_objects_to_pending(revs, revs->repo->index);
+       do_add_index_objects_to_pending(revs, revs->repo->index, flags);
  
        if (revs->single_worktree)
                return;
                if (read_index_from(&istate,
                                    worktree_git_path(wt, "index"),
                                    get_worktree_git_dir(wt)) > 0)
-                       do_add_index_objects_to_pending(revs, &istate);
+                       do_add_index_objects_to_pending(revs, &istate, flags);
                discard_index(&istate);
        }
        free_worktrees(worktrees);
@@@ -2144,8 -2141,7 +2147,8 @@@ static int handle_revision_opt(struct r
                revs->limited = 1;
        } else if (!strcmp(arg, "--ignore-missing")) {
                revs->ignore_missing = 1;
 -      } else if (!strcmp(arg, "--exclude-promisor-objects")) {
 +      } else if (revs->allow_exclude_promisor_objects_opt &&
 +                 !strcmp(arg, "--exclude-promisor-objects")) {
                if (fetch_if_missing)
                        BUG("exclude_promisor_objects can only be used when fetch_if_missing is 0");
                revs->exclude_promisor_objects = 1;