Tests on Windows: $(pwd) must return Windows-style paths
[gitweb.git] / builtin-clone.c
index f9ce4fbf19dd3d589eba9a1dd8afcc0e18ee320f..efbc804a3d1c1f9edb1c8c21bc382f8c1c3836ff 100644 (file)
@@ -21,6 +21,7 @@
 #include "pack-refs.h"
 #include "sigchain.h"
 #include "remote.h"
+#include "run-command.h"
 
 /*
  * Overall FIXMEs:
@@ -329,8 +330,6 @@ static void install_branch_config(const char *local,
 
 int cmd_clone(int argc, const char **argv, const char *prefix)
 {
-       int use_local_hardlinks = 1;
-       int use_separate_remote = 1;
        int is_bundle = 0;
        struct stat buf;
        const char *repo_name, *repo, *work_tree, *git_dir;
@@ -341,6 +340,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        struct strbuf branch_top = STRBUF_INIT, reflog_msg = STRBUF_INIT;
        struct transport *transport = NULL;
        char *src_ref_prefix = "refs/heads/";
+       int err = 0;
 
        struct refspec refspec;
 
@@ -352,9 +352,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        if (argc == 0)
                die("You must specify a repository to clone.");
 
-       if (option_no_hardlinks)
-               use_local_hardlinks = 0;
-
        if (option_mirror)
                option_bare = 1;
 
@@ -363,7 +360,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                        die("--bare and --origin %s options are incompatible.",
                            option_origin);
                option_no_checkout = 1;
-               use_separate_remote = 0;
        }
 
        if (!option_origin)
@@ -510,7 +506,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                mapped_refs = write_remote_refs(refs, &refspec, reflog_msg.buf);
 
                remote_head = find_ref_by_name(refs, "HEAD");
-               head_points_at = guess_remote_head(remote_head, mapped_refs);
+               head_points_at = guess_remote_head(remote_head, mapped_refs, 0);
        }
        else {
                warning("You appear to have cloned an empty repository.");
@@ -596,6 +592,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                if (write_cache(fd, active_cache, active_nr) ||
                    commit_locked_index(lock_file))
                        die("unable to write new index file");
+
+               err |= run_hook(NULL, "post-checkout", sha1_to_hex(null_sha1),
+                               sha1_to_hex(remote_head->old_sha1), "1", NULL);
        }
 
        strbuf_release(&reflog_msg);
@@ -603,5 +602,5 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        strbuf_release(&key);
        strbuf_release(&value);
        junk_pid = 0;
-       return 0;
+       return err;
 }