Beispiel #1
0
static void cgit_print_diffstat(const struct object_id *old_oid,
				const struct object_id *new_oid,
				const char *prefix)
{
	int i;

	html("<div class='diffstat-header'>");
	cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1,
		       ctx.qry.sha2, NULL);
	if (prefix) {
		html(" (limited to '");
		html_txt(prefix);
		html("')");
	}
	html("</div>");
	html("<table summary='diffstat' class='diffstat'>");
	max_changes = 0;
	cgit_diff_tree(old_oid, new_oid, inspect_filepair, prefix,
		       ctx.qry.ignorews);
	for (i = 0; i<files; i++)
		print_fileinfo(&items[i]);
	html("</table>");
	html("<div class='diffstat-summary'>");
	htmlf("%d files changed, %d insertions, %d deletions",
	      files, total_adds, total_rems);
	html("</div>");
}
Beispiel #2
0
static void exec_meta(Pcs pcs, struct params *params)
{
	char str[32] = {0};
	PcsFileInfo *fi;
	printf("\nGet meta %s\n", params->args[0]);
	fi = pcs_meta(pcs, params->args[0]);
	if (!fi) {
		printf("Failed: %s\n", pcs_strerror(pcs));
		return;
	}
	print_fileinfo(fi, " ");
	pcs_fileinfo_destroy(fi);
}
Beispiel #3
0
void cgit_print_diffstat(const unsigned char *old_sha1,
			 const unsigned char *new_sha1, const char *prefix)
{
	int i, save_context = ctx.qry.context;

	html("<div class='diffstat-header'>");
	cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1,
		       ctx.qry.sha2, NULL, 0);
	if (prefix) {
		html(" (limited to '");
		html_txt(prefix);
		html("')");
	}
	html(" (");
	ctx.qry.context = (save_context > 0 ? save_context : 3) << 1;
	cgit_self_link("more", NULL, NULL, &ctx);
	html("/");
	ctx.qry.context = (save_context > 3 ? save_context : 3) >> 1;
	cgit_self_link("less", NULL, NULL, &ctx);
	ctx.qry.context = save_context;
	html(" context)");
	html(" (");
	ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2;
	cgit_self_link(ctx.qry.ignorews ? "ignore" : "show", NULL, NULL, &ctx);
	ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2;
	html(" whitespace changes)");
	html("</div>");
	html("<table summary='diffstat' class='diffstat'>");
	max_changes = 0;
	cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix,
		       ctx.qry.ignorews);
	for(i = 0; i<files; i++)
		print_fileinfo(&items[i]);
	html("</table>");
	html("<div class='diffstat-summary'>");
	htmlf("%d files changed, %d insertions, %d deletions",
	      files, total_adds, total_rems);
	html("</div>");
}
Beispiel #4
0
int main(int argc, char *argv[]) {

	int n;
	extern char *optarg;		/* for getopt */
	extern int optind, opterr;	/* for getopt */

	option_l = 0;
	option_a = 0;
	
	while((n = getopt(argc, argv, "la")) != -1) {
		switch(n) {
		case 'l':
			option_l = 1;
			break;
		case 'a':
			option_a = 1;
			break;
		default:
			usage();
		}
	}
	argc -= optind;
	argv += optind;

	struct list list;
	list.head = NULL;
	list.size = 0;
	int num;
	for(num = 0; num < argc; num++) {
		appendbypath(&list, argv[num], 1023);
	}

	int iterator = 0;
	struct node *node;
	DIR *dir;
	struct dirent *dirent;
	// check file type and print.
	while( (node = getnode_ite(&list, &iterator)) != NULL) {
		if(lstat(node->path, node->buf) != 0) {
			perror("lstat");
		}
		if(S_ISDIR(node->buf->st_mode)) {	// dir
			//if(strncmp(dirent->d_name, "/", 1)) {
			fprintf(stdout, "%s:\n", node->path);
			dir = opendir(node->path);
			struct stat *buf;
			buf = malloc(sizeof(struct stat));
			while( (dirent = readdir(dir)) != NULL) {
				memset(buf, 0, sizeof(buf));
				if(option_l == 1) {
					char path[1024];
					memcpy(path, node->path, strlen(node->path));
			fprintf(stdout, "%s:%d:%d\n", path, strlen(path), strlen(node->path));
			fprintf(stdout, "%s\n", path[1]);
					if(strncmp(&path[strlen(node->path) - 1], "/", 1)) {
						strcat(path, "/");
					}
					strcat(path, dirent->d_name);
					if(lstat(path, buf) != 0) 
						perror("lstat");
					print_fileinfo(dirent->d_name, *buf, option_a);
				} else {
					fprintf(stdout, "%s\n", dirent->d_name);	
				}
			}
			closedir(dir);
		} else if(S_ISLNK(node->buf->st_mode)) {	//symbolic link
			if(option_a != 1 && !strncmp(dirent->d_name, ".", 1)) {
			} else {
				char *rpath;
				rpath = realpath(node->path, NULL);
				char time[25];
				struct passwd *pw;
				// get username by passwd
				pw = getpwuid(node->buf->st_uid);
				fprintf(stdout, "%o\t%d\t%s\t%d\t%d", 
						node->buf->st_mode, node->buf->st_nlink, pw->pw_name, 
						node->buf->st_gid, node->buf->st_size
					);
				memcpy(time, (char *)ctime(&node->buf->st_mtime), 24);
				fprintf(stdout, "\t%s\t%s -> %s\n", time, node->path, rpath);

				free(rpath);
			}
		} else {	//regular file
			if(option_l == 1) {
				char time[25];
				struct passwd *pw;
				// get username by passwd
				pw = getpwuid(node->buf->st_uid);
				fprintf(stdout, "%o\t%d\t%s\t%d\t%d", 
						node->buf->st_mode, node->buf->st_nlink, pw->pw_name, 
						node->buf->st_gid, node->buf->st_size
					);
				memcpy(time, (char *)ctime(&node->buf->st_mtime), 24);
				fprintf(stdout, "\t%s\t%s\n", time, node->path);
			} else {
				fprintf(stdout, "%s\n", node->path);	
			}
		}
		fprintf(stdout, "\n");
	}

	return 0;
}