Merge branch 'jk/war-on-git-path'
authorJunio C Hamano <gitster@pobox.com>
Wed, 26 Apr 2017 06:39:08 +0000 (15:39 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 26 Apr 2017 06:39:08 +0000 (15:39 +0900)
While handy, "git_path()" is a dangerous function to use as a
callsite that uses it safely one day can be broken by changes
to other code that calls it.  Reduction of its use continues.

* jk/war-on-git-path:
  am: drop "dir" parameter from am_state_init
  replace strbuf_addstr(git_path()) with git_path_buf()
  replace xstrdup(git_path(...)) with git_pathdup(...)
  use git_path_* helper functions
  branch: add edit_description() helper
  bisect: add git_path_bisect_terms helper

1  2 
bisect.c
builtin/am.c
builtin/branch.c
builtin/commit.c
builtin/config.c
builtin/pull.c
builtin/worktree.c
fast-import.c
sequencer.c

diff --cc bisect.c
Simple merge
diff --cc builtin/am.c
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc builtin/pull.c
@@@ -330,12 -330,12 +330,12 @@@ static int git_pull_config(const char *
   * Appends merge candidates from FETCH_HEAD that are not marked not-for-merge
   * into merge_heads.
   */
 -static void get_merge_heads(struct sha1_array *merge_heads)
 +static void get_merge_heads(struct oid_array *merge_heads)
  {
-       const char *filename = git_path("FETCH_HEAD");
+       const char *filename = git_path_fetch_head();
        FILE *fp;
        struct strbuf sb = STRBUF_INIT;
 -      unsigned char sha1[GIT_SHA1_RAWSZ];
 +      struct object_id oid;
  
        if (!(fp = fopen(filename, "r")))
                die_errno(_("could not open '%s' for reading"), filename);
@@@ -791,11 -791,11 +791,11 @@@ int cmd_pull(int argc, const char **arg
        if (read_cache_unmerged())
                die_resolve_conflict("pull");
  
-       if (file_exists(git_path("MERGE_HEAD")))
+       if (file_exists(git_path_merge_head()))
                die_conclude_merge();
  
 -      if (get_sha1("HEAD", orig_head))
 -              hashclr(orig_head);
 +      if (get_oid("HEAD", &orig_head))
 +              oidclr(&orig_head);
  
        if (!opt_rebase && opt_autostash != -1)
                die(_("--[no-]autostash option is only valid with --rebase."));
Simple merge
diff --cc fast-import.c
Simple merge
diff --cc sequencer.c
@@@ -1062,17 -1054,17 +1062,17 @@@ static int do_pick_commit(enum todo_com
                if (!final_fixup)
                        msg_file = rebase_path_squash_msg();
                else if (file_exists(rebase_path_fixup_msg())) {
 -                      cleanup_commit_message = 1;
 +                      flags |= CLEANUP_MSG;
                        msg_file = rebase_path_fixup_msg();
                } else {
-                       const char *dest = git_path("SQUASH_MSG");
+                       const char *dest = git_path_squash_msg();
                        unlink(dest);
                        if (copy_file(dest, rebase_path_squash_msg(), 0666))
                                return error(_("could not rename '%s' to '%s'"),
                                             rebase_path_squash_msg(), dest);
-                       unlink(git_path("MERGE_MSG"));
+                       unlink(git_path_merge_msg());
                        msg_file = dest;
 -                      edit = 1;
 +                      flags |= EDIT_MSG;
                }
        }