Staging
v0.5.2
https://github.com/git/git
Revision 9231f500c394ede405fcfdca151dd7758ce99ced authored by Thomas Guyot-Sionnest on 22 April 2008, 10:07:47 UTC, committed by Junio C Hamano on 23 April 2008, 04:39:10 UTC
When trying to import from svn using an author file, git-svn bails out
if it encounters a blank author. The attached patch changes this
behavior and allow using the author file with blanks authors.

I came across this bug while importing from a cvs2svn repo where the
initial revision (1) has a blank author. This doesn't break the behavior
of bailing out when an unknown author is encountered.

Acked-by: Eric Wong <normalperson@yhbt.net>

Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 75b7dfb
Raw File
Tip revision: 9231f500c394ede405fcfdca151dd7758ce99ced authored by Thomas Guyot-Sionnest on 22 April 2008, 10:07:47 UTC
git-svn bug with blank commits and author file
Tip revision: 9231f50
test-chmtime.c
#include "git-compat-util.h"
#include <utime.h>

static const char usage_str[] = "(+|=|=+|=-|-)<seconds> <file>...";

int main(int argc, const char *argv[])
{
	int i;
	int set_eq;
	long int set_time;
	char *test;
	const char *timespec;

	if (argc < 3)
		goto usage;

	timespec = argv[1];
	set_eq = (*timespec == '=') ? 1 : 0;
	if (set_eq) {
		timespec++;
		if (*timespec == '+') {
			set_eq = 2; /* relative "in the future" */
			timespec++;
		}
	}
	set_time = strtol(timespec, &test, 10);
	if (*test) {
		fprintf(stderr, "Not a base-10 integer: %s\n", argv[1] + 1);
		goto usage;
	}
	if ((set_eq && set_time < 0) || set_eq == 2) {
		time_t now = time(NULL);
		set_time += now;
	}

	for (i = 2; i < argc; i++) {
		struct stat sb;
		struct utimbuf utb;

		if (stat(argv[i], &sb) < 0) {
			fprintf(stderr, "Failed to stat %s: %s\n",
			        argv[i], strerror(errno));
			return -1;
		}

		utb.actime = sb.st_atime;
		utb.modtime = set_eq ? set_time : sb.st_mtime + set_time;

		if (utime(argv[i], &utb) < 0) {
			fprintf(stderr, "Failed to modify time on %s: %s\n",
			        argv[i], strerror(errno));
			return -1;
		}
	}

	return 0;

usage:
	fprintf(stderr, "Usage: %s %s\n", argv[0], usage_str);
	return -1;
}
back to top