{"thread":{"id":"37234","subject":"[PATCH] init: avoid superfluous real_path() calls","startedAt":"2014-07-28T18:42:05Z","lastAt":"2014-07-28T18:42:05Z","messageCount":1,"participants":["René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"246824","messageId":"53D6997D.10603@web.de","threadId":"37234","inReplyTo":null,"subject":"[PATCH] init: avoid superfluous real_path() calls","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2014-07-28T18:42:05Z","receivedAt":"2014-07-28T18:42:05Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Feeding the result of a real_path() call to real_path() again doesn't\nchange that result -- the returned path won't get any more real.  Avoid\nsuch a double call in set_git_dir_init() and for the same reason stop\ncalling real_path() before feeding paths to set_git_work_tree(), as the\nlatter already takes care of that.\n\nSigned-off-by: Rene Scharfe <l.s.r@web.de>\n---\n builtin/init-db.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/init-db.c b/builtin/init-db.c\nindex 56f85e2..6d8ac2c 100644\n--- a/builtin/init-db.c\n+++ b/builtin/init-db.c\n@@ -330,12 +330,12 @@ int set_git_dir_init(const char *git_dir, const char *real_git_dir,\n \t\t * moving the target repo later on in separate_git_dir()\n \t\t */\n \t\tgit_link = xstrdup(real_path(git_dir));\n+\t\tset_git_dir(real_path(real_git_dir));\n \t}\n \telse {\n-\t\treal_git_dir = real_path(git_dir);\n+\t\tset_git_dir(real_path(git_dir));\n \t\tgit_link = NULL;\n \t}\n-\tset_git_dir(real_path(real_git_dir));\n \treturn 0;\n }\n \n@@ -578,7 +578,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)\n \t\t\t\tdie_errno (_(\"Cannot access current working directory\"));\n \t\t}\n \t\tif (work_tree)\n-\t\t\tset_git_work_tree(real_path(work_tree));\n+\t\t\tset_git_work_tree(work_tree);\n \t\telse\n \t\t\tset_git_work_tree(git_work_tree_cfg);\n \t\tif (access(get_git_work_tree(), X_OK))\n@@ -587,7 +587,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)\n \t}\n \telse {\n \t\tif (work_tree)\n-\t\t\tset_git_work_tree(real_path(work_tree));\n+\t\t\tset_git_work_tree(work_tree);\n \t}\n \n \tset_git_dir_init(git_dir, real_git_dir, 1);\n-- \n2.0.2\n"}]}