git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
blob ce914d3c9f81791ebba480c5c82cfafd9f372689 1900 bytes (raw)
name: builtin/prime-clone.c 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
 
#include "cache.h"
#include "parse-options.h"
#include "pkt-line.h"

static char const * const prime_clone_usage[] = {
	N_("git prime-clone [--strict] <dir>"),
	NULL
};

static unsigned int enabled = 1;
static const char *url = NULL, *filetype = NULL;
static int strict;

static struct option prime_clone_options[] = {
	OPT_BOOL(0, "strict", &strict, N_("Do not attempt <dir>/.git if <dir> "
					  "is not a git directory")),
	OPT_END(),
};

static void prime_clone(void)
{
	if (!enabled) {
		fprintf(stderr, _("prime-clone not enabled\n"));
	}
	else if (url && filetype){
		packet_write(1, "%s %s\n", filetype, url);
	}
	else if (url || filetype) {
		if (filetype)
			fprintf(stderr, _("prime-clone not properly "
					  "configured: missing url\n"));
		else if (url)
			fprintf(stderr, _("prime-clone not properly "
					  "configured: missing filetype\n"));
	}
	packet_flush(1);
}

static int prime_clone_config(const char *var, const char *value, void *unused)
{
	if (!strcmp("primeclone.url",var)) {
		return git_config_pathname(&url, var, value);
	}
	if (!strcmp("primeclone.enabled",var)) {
		enabled = git_config_bool(var, value);
		return 0;
	}
	if (!strcmp("primeclone.filetype",var)) {
		return git_config_string(&filetype, var, value);
	}
	return git_default_config(var, value, unused);
}

int cmd_prime_clone(int argc, const char **argv, const char *prefix)
{
	const char *dir;
	argc = parse_options(argc, argv, prefix, prime_clone_options,
			     prime_clone_usage, 0);
	if (argc == 0) {
		usage_msg_opt(_("No repository specified."), prime_clone_usage,
			      prime_clone_options);
	}
	else if (argc > 1) {
		usage_msg_opt(_("Too many arguments."), prime_clone_usage,
			      prime_clone_options);
	}

	dir = argv[0];

	if (!enter_repo(dir, 0)){
		die(_("'%s' does not appear to be a git repository"), dir);
	}

	git_config(prime_clone_config, NULL);
	prime_clone();
	return 0;
}

debug log:

solving ce914d3 ...
found ce914d3 in https://public-inbox.org/git/1473984742-12516-2-git-send-email-kevin.m.wern@gmail.com/

applying [1/1] https://public-inbox.org/git/1473984742-12516-2-git-send-email-kevin.m.wern@gmail.com/
diff --git a/builtin/prime-clone.c b/builtin/prime-clone.c
new file mode 100644
index 0000000..ce914d3

Checking patch builtin/prime-clone.c...
Applied patch builtin/prime-clone.c cleanly.

index at:
100644 ce914d3c9f81791ebba480c5c82cfafd9f372689	builtin/prime-clone.c

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).