Skip to content

Commit ca03e06

Browse files
peffgitster
authored andcommitted
use git_path_* helper functions
Long ago we added functions like git_path_merge_msg() to replace the more dangerous git_path("MERGE_MSG"). Over time some new calls to the latter have crept it. Let's convert them to use the safer form. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c10388c commit ca03e06

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

builtin/commit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -821,9 +821,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
821821
"If this is not correct, please remove the file\n"
822822
" %s\n"
823823
"and try again.\n"),
824-
git_path(whence == FROM_MERGE
825-
? "MERGE_HEAD"
826-
: "CHERRY_PICK_HEAD"));
824+
whence == FROM_MERGE ?
825+
git_path_merge_head() :
826+
git_path_cherry_pick_head());
827827
}
828828

829829
fprintf(s->fp, "\n");

builtin/pull.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ static int git_pull_config(const char *var, const char *value, void *cb)
332332
*/
333333
static void get_merge_heads(struct sha1_array *merge_heads)
334334
{
335-
const char *filename = git_path("FETCH_HEAD");
335+
const char *filename = git_path_fetch_head();
336336
FILE *fp;
337337
struct strbuf sb = STRBUF_INIT;
338338
unsigned char sha1[GIT_SHA1_RAWSZ];
@@ -791,7 +791,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
791791
if (read_cache_unmerged())
792792
die_resolve_conflict("pull");
793793

794-
if (file_exists(git_path("MERGE_HEAD")))
794+
if (file_exists(git_path_merge_head()))
795795
die_conclude_merge();
796796

797797
if (get_sha1("HEAD", orig_head))

sequencer.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,12 +1057,12 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
10571057
cleanup_commit_message = 1;
10581058
msg_file = rebase_path_fixup_msg();
10591059
} else {
1060-
const char *dest = git_path("SQUASH_MSG");
1060+
const char *dest = git_path_squash_msg();
10611061
unlink(dest);
10621062
if (copy_file(dest, rebase_path_squash_msg(), 0666))
10631063
return error(_("could not rename '%s' to '%s'"),
10641064
rebase_path_squash_msg(), dest);
1065-
unlink(git_path("MERGE_MSG"));
1065+
unlink(git_path_merge_msg());
10661066
msg_file = dest;
10671067
edit = 1;
10681068
}
@@ -1812,10 +1812,10 @@ static int error_failed_squash(struct commit *commit,
18121812
return error(_("could not rename '%s' to '%s'"),
18131813
rebase_path_squash_msg(), rebase_path_message());
18141814
unlink(rebase_path_fixup_msg());
1815-
unlink(git_path("MERGE_MSG"));
1816-
if (copy_file(git_path("MERGE_MSG"), rebase_path_message(), 0666))
1815+
unlink(git_path_merge_msg());
1816+
if (copy_file(git_path_merge_msg(), rebase_path_message(), 0666))
18171817
return error(_("could not copy '%s' to '%s'"),
1818-
rebase_path_message(), git_path("MERGE_MSG"));
1818+
rebase_path_message(), git_path_merge_msg());
18191819
return error_with_patch(commit, subject, subject_len, opts, 1, 0);
18201820
}
18211821

@@ -2158,7 +2158,7 @@ static int commit_staged_changes(struct replay_opts *opts)
21582158
if (has_unstaged_changes(1))
21592159
return error(_("cannot rebase: You have unstaged changes."));
21602160
if (!has_uncommitted_changes(0)) {
2161-
const char *cherry_pick_head = git_path("CHERRY_PICK_HEAD");
2161+
const char *cherry_pick_head = git_path_cherry_pick_head();
21622162

21632163
if (file_exists(cherry_pick_head) && unlink(cherry_pick_head))
21642164
return error(_("could not remove CHERRY_PICK_HEAD"));

0 commit comments

Comments
 (0)