Staging
v0.5.2
https://github.com/git/git
Revision c63777c0d7687a1edff2c0da307ad8ac1d75c8f6 authored by Junio C Hamano on 06 May 2007, 04:18:57 UTC, committed by Junio C Hamano on 06 May 2007, 05:40:27 UTC
When you do this, existing "blame -C -C" would not find that the
latter half of the file2 came from the existing file1:

	... both file1 and file2 are tracked ...
	$ cat file1 >>file2
	$ git add file1 file2
	$ git commit

This is because we avoid the expensive find-copies-harder code
that makes unchanged file (in this case, file1) as a candidate
for copy & paste source when annotating an existing file
(file2).  The third -C now allows it.  However, this obviously
makes the process very expensive.  We've actually seen this
patch before, but I dismissed it because it covers such a narrow
(and arguably stupid) corner case.

Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent dd166aa
Raw File
Tip revision: c63777c0d7687a1edff2c0da307ad8ac1d75c8f6 authored by Junio C Hamano on 06 May 2007, 04:18:57 UTC
blame: -C -C -C
Tip revision: c63777c
peek-remote.c
#include "cache.h"
#include "refs.h"
#include "pkt-line.h"

static const char peek_remote_usage[] =
"git-peek-remote [--upload-pack=<git-upload-pack>] [<host>:]<directory>";
static const char *uploadpack = "git-upload-pack";

static int peek_remote(int fd[2], unsigned flags)
{
	struct ref *ref;

	get_remote_heads(fd[0], &ref, 0, NULL, flags);
	packet_flush(fd[1]);

	while (ref) {
		printf("%s	%s\n", sha1_to_hex(ref->old_sha1), ref->name);
		ref = ref->next;
	}
	return 0;
}

int main(int argc, char **argv)
{
	int i, ret;
	char *dest = NULL;
	int fd[2];
	pid_t pid;
	int nongit = 0;
	unsigned flags = 0;

	setup_git_directory_gently(&nongit);

	for (i = 1; i < argc; i++) {
		char *arg = argv[i];

		if (*arg == '-') {
			if (!prefixcmp(arg, "--upload-pack=")) {
				uploadpack = arg + 14;
				continue;
			}
			if (!prefixcmp(arg, "--exec=")) {
				uploadpack = arg + 7;
				continue;
			}
			if (!strcmp("--tags", arg)) {
				flags |= REF_TAGS;
				continue;
			}
			if (!strcmp("--heads", arg)) {
				flags |= REF_HEADS;
				continue;
			}
			if (!strcmp("--refs", arg)) {
				flags |= REF_NORMAL;
				continue;
			}
			usage(peek_remote_usage);
		}
		dest = arg;
		break;
	}

	if (!dest || i != argc - 1)
		usage(peek_remote_usage);

	pid = git_connect(fd, dest, uploadpack);
	if (pid < 0)
		return 1;
	ret = peek_remote(fd, flags);
	close(fd[0]);
	close(fd[1]);
	ret |= finish_connect(pid);
	return !!ret;
}
back to top