Merge branch 'ar/maint-mksnpath' into ar/mksnpath
authorJunio C Hamano <gitster@pobox.com>
Fri, 31 Oct 2008 01:08:58 +0000 (18:08 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 31 Oct 2008 01:08:58 +0000 (18:08 -0700)
* 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

1  2 
builtin-reflog.c
builtin-revert.c
builtin-tag.c
cache.h
config.c
environment.c
refs.c
rerere.c

Simple merge
index 472554019afdb5e8e21f2d362f62f40eb569d8aa,5c4ab58f4643b8a1b77507c1cc0f0b8a70691ebf..7e50c2aa542772b2bac7c599df8865c3dbae5bcd
@@@ -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 builtin-tag.c
Simple merge
diff --cc cache.h
Simple merge
diff --cc config.c
Simple merge
diff --cc environment.c
Simple merge
diff --cc refs.c
index 0a126fa371ae24f5cb251ff52cf7d38322d78ba7,d589b25562405b5361b6a6e49e2501361552c6ec..01e4df4ccfa203f140998f5da42b2a9fcfcca4c7
--- 1/refs.c
--- 2/refs.c
+++ b/refs.c
@@@ -421,7 -409,14 +421,8 @@@ const char *resolve_ref(const char *ref
                if (--depth < 0)
                        return NULL;
  
 -              /* 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.
 -               */
+               git_snpath(path, sizeof(path), "%s", ref);
 +              /* Special case: non-existing file. */
                if (lstat(path, &st) < 0) {
                        struct ref_list *list = get_packed_refs();
                        while (list) {
diff --cc rerere.c
index 8e5532b1ff96a88133d837b9a29fa78117c36abd,3d6ee8fa2a647d6ee8459f700cbc450c94e7f179..02931a151f1abe183763c9a1edb65ffd36d83bc3
+++ 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;
  }