From: Junio C Hamano Date: Wed, 26 Apr 2017 06:39:08 +0000 (+0900) Subject: Merge branch 'jk/war-on-git-path' X-Git-Tag: v2.13.0-rc1~7 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b80f629f5bcf798a3c9b37651d2369ad555e7382?hp=--cc Merge branch 'jk/war-on-git-path' 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 --- b80f629f5bcf798a3c9b37651d2369ad555e7382 diff --cc builtin/pull.c index d8aa26d8ab,d8032e838c..dd1a4a94e4 --- a/builtin/pull.c +++ b/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.")); diff --cc sequencer.c index 77afecaebf,f52c30fbe2..130cc868e5 --- a/sequencer.c +++ b/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; } }