From: Junio C Hamano Date: Fri, 31 Oct 2008 01:08:58 +0000 (-0700) Subject: Merge branch 'ar/maint-mksnpath' into ar/mksnpath X-Git-Tag: v1.6.1-rc1~84^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=98b35e2c749614446b916230148d66857e8a09f3;p=git.git Merge branch 'ar/maint-mksnpath' into ar/mksnpath * ar/maint-mksnpath: Use git_pathdup instead of xstrdup(git_path(...)) git_pathdup: returns xstrdup-ed copy of the formatted path Fix potentially dangerous use of git_path in ref.c Add git_snpath: a .git path formatting routine with output buffer Conflicts: builtin-revert.c refs.c rerere.c --- 98b35e2c749614446b916230148d66857e8a09f3 diff --cc builtin-revert.c index 472554019,5c4ab58f4..7e50c2aa5 --- a/builtin-revert.c +++ b/builtin-revert.c @@@ -248,13 -266,10 +248,13 @@@ static int revert_or_cherry_pick(int ar { unsigned char head[20]; struct commit *base, *next, *parent; - int i; + int i, index_fd, clean; char *oneline, *reencoded_message = NULL; const char *message, *encoding; - const char *defmsg = xstrdup(git_path("MERGE_MSG")); + const char *defmsg = git_pathdup("MERGE_MSG"); + struct merge_options o; + struct tree *result, *next_tree, *base_tree, *head_tree; + static struct lock_file index_lock; git_config(git_default_config, NULL); me = action == REVERT ? "revert" : "cherry-pick"; diff --cc refs.c index 0a126fa37,d589b2556..01e4df4cc --- a/refs.c +++ b/refs.c @@@ -421,7 -409,14 +421,8 @@@ const char *resolve_ref(const char *ref if (--depth < 0) return NULL; + git_snpath(path, sizeof(path), "%s", ref); - /* Special case: non-existing file. - * Not having the refs/heads/new-branch is OK - * if we are writing into it, so is .git/HEAD - * that points at refs/heads/master still to be - * born. It is NOT OK if we are resolving for - * reading. - */ + /* Special case: non-existing file. */ if (lstat(path, &st) < 0) { struct ref_list *list = get_packed_refs(); while (list) { diff --cc rerere.c index 8e5532b1f,3d6ee8fa2..02931a151 --- a/rerere.c +++ b/rerere.c @@@ -351,9 -345,8 +351,9 @@@ int setup_rerere(struct string_list *me if (!is_rerere_enabled()) return -1; - merge_rr_path = xstrdup(git_path("MERGE_RR")); + merge_rr_path = git_pathdup("MERGE_RR"); - fd = hold_lock_file_for_update(&write_lock, merge_rr_path, 1); + fd = hold_lock_file_for_update(&write_lock, merge_rr_path, + LOCK_DIE_ON_ERROR); read_rr(merge_rr); return fd; }