#include "strbuf.h"
#include "dir.h"
#include "pack-refs.h"
+#include "sigchain.h"
/*
* Overall FIXMEs:
static void remove_junk_on_signal(int signo)
{
remove_junk();
- signal(SIGINT, SIG_DFL);
+ sigchain_pop(signo);
raise(signo);
}
return local_refs;
}
+static void install_branch_config(const char *local,
+ const char *origin,
+ const char *remote)
+{
+ struct strbuf key = STRBUF_INIT;
+ strbuf_addf(&key, "branch.%s.remote", local);
+ git_config_set(key.buf, origin);
+ strbuf_reset(&key);
+ strbuf_addf(&key, "branch.%s.merge", local);
+ git_config_set(key.buf, remote);
+ strbuf_release(&key);
+}
+
int cmd_clone(int argc, const char **argv, const char *prefix)
{
int use_local_hardlinks = 1;
}
junk_git_dir = git_dir;
atexit(remove_junk);
- signal(SIGINT, remove_junk_on_signal);
+ sigchain_push_common(remove_junk_on_signal);
setenv(CONFIG_ENVIRONMENT, xstrdup(mkpath("%s/config", git_dir)), 1);
head_points_at = NULL;
remote_head = NULL;
option_no_checkout = 1;
+ if (!option_bare)
+ install_branch_config("master", option_origin,
+ "refs/heads/master");
}
if (head_points_at) {
head_points_at->peer_ref->name,
reflog_msg.buf);
- strbuf_addf(&key, "branch.%s.remote", head);
- git_config_set(key.buf, option_origin);
- strbuf_reset(&key);
- strbuf_addf(&key, "branch.%s.merge", head);
- git_config_set(key.buf, head_points_at->name);
+ install_branch_config(head, option_origin,
+ head_points_at->name);
}
} else if (remote_head) {
/* Source had detached HEAD pointing somewhere. */