path: implement common_dir handling in git_pathdup_submodule()
[gitweb.git] / submodule.c
index 97355eb7ad82ac16c2b6317409e57615f75c5740..5e5a46fe2ab765ff5ecec01a9bc46351fe596837 100644 (file)
@@ -122,15 +122,8 @@ static int add_submodule_odb(const char *path)
        struct strbuf objects_directory = STRBUF_INIT;
        struct alternate_object_database *alt_odb;
        int ret = 0;
-       const char *git_dir;
 
-       strbuf_addf(&objects_directory, "%s/.git", path);
-       git_dir = read_gitfile(objects_directory.buf);
-       if (git_dir) {
-               strbuf_reset(&objects_directory);
-               strbuf_addstr(&objects_directory, git_dir);
-       }
-       strbuf_addstr(&objects_directory, "/objects/");
+       strbuf_git_path_submodule(&objects_directory, path, "objects/");
        if (!is_directory(objects_directory.buf)) {
                ret = -1;
                goto done;
@@ -288,21 +281,6 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
        strbuf_release(&sb);
 }
 
-int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg)
-{
-       switch (git_config_maybe_bool(opt, arg)) {
-       case 1:
-               return RECURSE_SUBMODULES_ON;
-       case 0:
-               return RECURSE_SUBMODULES_OFF;
-       default:
-               if (!strcmp(arg, "on-demand"))
-                       return RECURSE_SUBMODULES_ON_DEMAND;
-               /* TODO: remove the die for history parsing here */
-               die("bad %s argument: %s", opt, arg);
-       }
-}
-
 void show_submodule_summary(FILE *f, const char *path,
                const char *line_prefix,
                unsigned char one[20], unsigned char two[20],
@@ -366,7 +344,8 @@ void set_config_fetch_recurse_submodules(int value)
        config_fetch_recurse_submodules = value;
 }
 
-static int has_remote(const char *refname, const unsigned char *sha1, int flags, void *cb_data)
+static int has_remote(const char *refname, const struct object_id *oid,
+                     int flags, void *cb_data)
 {
        return 1;
 }
@@ -560,10 +539,10 @@ static void submodule_collect_changed_cb(struct diff_queue_struct *q,
        }
 }
 
-static int add_sha1_to_array(const char *ref, const unsigned char *sha1,
+static int add_sha1_to_array(const char *ref, const struct object_id *oid,
                             int flags, void *data)
 {
-       sha1_array_append(data, sha1);
+       sha1_array_append(data, oid->hash);
        return 0;
 }
 
@@ -937,7 +916,7 @@ static void print_commit(struct commit *commit)
 {
        struct strbuf sb = STRBUF_INIT;
        struct pretty_print_context ctx = {0};
-       ctx.date_mode = DATE_NORMAL;
+       ctx.date_mode.type = DATE_NORMAL;
        format_commit_message(commit, " %h: %m %s", &sb, &ctx);
        fprintf(stderr, "%s\n", sb.buf);
        strbuf_release(&sb);
@@ -1047,7 +1026,7 @@ void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir)
 
        /* Update gitfile */
        strbuf_addf(&file_name, "%s/.git", work_tree);
-       write_file(file_name.buf, 1, "gitdir: %s\n",
+       write_file(file_name.buf, "gitdir: %s",
                   relative_path(git_dir, real_work_tree, &rel_path));
 
        /* Update core.worktree setting */