Code

Use git_pathdup instead of xstrdup(git_path(...))
authorAlex Riesen <raa.lkml@gmail.com>
Mon, 27 Oct 2008 10:22:09 +0000 (11:22 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 31 Oct 2008 00:52:24 +0000 (17:52 -0700)
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-config.c
builtin-reflog.c
builtin-revert.c
builtin-tag.c
config.c
environment.c
refs.c
rerere.c
server-info.c

index 91fdc4985d8e64fae12209174dd4aa2d887793e5..f71016204b540d0d935323c909a0ffccb1abdbe2 100644 (file)
@@ -84,7 +84,7 @@ static int get_value(const char* key_, const char* regex_)
        local = config_exclusive_filename;
        if (!local) {
                const char *home = getenv("HOME");
-               local = repo_config = xstrdup(git_path("config"));
+               local = repo_config = git_pathdup("config");
                if (git_config_global() && home)
                        global = xstrdup(mkpath("%s/.gitconfig", home));
                if (git_config_system())
index 196fa03b7fac795475a0e12f0fa3b443cb34bd1d..da96da317be01c24ae9711206976f48f33e39f97 100644 (file)
@@ -277,11 +277,11 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
        lock = lock_any_ref_for_update(ref, sha1, 0);
        if (!lock)
                return error("cannot lock ref '%s'", ref);
-       log_file = xstrdup(git_path("logs/%s", ref));
+       log_file = git_pathdup("logs/%s", ref);
        if (!file_exists(log_file))
                goto finish;
        if (!cmd->dry_run) {
-               newlog_path = xstrdup(git_path("logs/%s.lock", ref));
+               newlog_path = git_pathdup("logs/%s.lock", ref);
                cb.newlog = fopen(newlog_path, "w");
        }
 
index 27881e94937dd79b9a0524eb2d9770427ec4f4fb..5c4ab58f4643b8a1b77507c1cc0f0b8a70691ebf 100644 (file)
@@ -269,7 +269,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
        int i;
        char *oneline, *reencoded_message = NULL;
        const char *message, *encoding;
-       const char *defmsg = xstrdup(git_path("MERGE_MSG"));
+       const char *defmsg = git_pathdup("MERGE_MSG");
 
        git_config(git_default_config, NULL);
        me = action == REVERT ? "revert" : "cherry-pick";
index f2853d08c77368b37b40c7ea51f5a124208d385f..6c6c35176e57a77fea85872fcea2c5b36f670e3e 100644 (file)
@@ -283,7 +283,7 @@ static void create_tag(const unsigned char *object, const char *tag,
                int fd;
 
                /* write the template message before editing: */
-               path = xstrdup(git_path("TAG_EDITMSG"));
+               path = git_pathdup("TAG_EDITMSG");
                fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
                if (fd < 0)
                        die("could not create file '%s': %s",
index 53f04a076a7275965090edd4ca2a34652c4f5679..82807c83b20ef8fbabfda7d476feff92f2dbb823 100644 (file)
--- a/config.c
+++ b/config.c
@@ -630,7 +630,7 @@ int git_config(config_fn_t fn, void *data)
                free(user_config);
        }
 
-       repo_config = xstrdup(git_path("config"));
+       repo_config = git_pathdup("config");
        ret += git_config_from_file(fn, repo_config, data);
        free(repo_config);
        return ret;
@@ -872,7 +872,7 @@ int git_config_set_multivar(const char* key, const char* value,
        if (config_exclusive_filename)
                config_filename = xstrdup(config_exclusive_filename);
        else
-               config_filename = xstrdup(git_path("config"));
+               config_filename = git_pathdup("config");
 
        /*
         * Since "key" actually contains the section name and the real
@@ -1132,7 +1132,7 @@ int git_config_rename_section(const char *old_name, const char *new_name)
        if (config_exclusive_filename)
                config_filename = xstrdup(config_exclusive_filename);
        else
-               config_filename = xstrdup(git_path("config"));
+               config_filename = git_pathdup("config");
        out_fd = hold_lock_file_for_update(lock, config_filename, 0);
        if (out_fd < 0) {
                ret = error("could not lock config file %s", config_filename);
index 0c6d11f6a0c6fa5dbab2f36c4b4ad4de5aba4ac9..df4f03a95f0b2098e97d0410bbb0589ff887e9cb 100644 (file)
@@ -71,7 +71,7 @@ static void setup_git_env(void)
        }
        git_graft_file = getenv(GRAFT_ENVIRONMENT);
        if (!git_graft_file)
-               git_graft_file = xstrdup(git_path("info/grafts"));
+               git_graft_file = git_pathdup("info/grafts");
 }
 
 int is_bare_repository(void)
diff --git a/refs.c b/refs.c
index 71443cdf85279933132266c8fdfc5d3dbcf043ca..d589b25562405b5361b6a6e49e2501361552c6ec 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1258,7 +1258,7 @@ int create_symref(const char *ref_target, const char *refs_heads_master,
        const char *lockpath;
        char ref[1000];
        int fd, len, written;
-       char *git_HEAD = xstrdup(git_path("%s", ref_target));
+       char *git_HEAD = git_pathdup("%s", ref_target);
        unsigned char old_sha1[20], new_sha1[20];
 
        if (logmsg && read_ref(ref_target, old_sha1))
index 323e493dafee46c0d3f95e3c4cd9c4c9b463bbef..3d6ee8fa2a647d6ee8459f700cbc450c94e7f179 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -345,7 +345,7 @@ int setup_rerere(struct string_list *merge_rr)
        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);
        read_rr(merge_rr);
        return fd;
index c1c073b2f05a48772a45602cdc711eef6e211695..66b0d9d878a011393582b837301eb1fd5caf2e40 100644 (file)
@@ -25,7 +25,7 @@ static int add_info_ref(const char *path, const unsigned char *sha1, int flag, v
 
 static int update_info_refs(int force)
 {
-       char *path0 = xstrdup(git_path("info/refs"));
+       char *path0 = git_pathdup("info/refs");
        int len = strlen(path0);
        char *path1 = xmalloc(len + 2);