From: Junio C Hamano Date: Fri, 27 Oct 2006 01:48:30 +0000 (-0700) Subject: Merge branch 'jc/reflog' into lj/refs X-Git-Tag: v1.4.4-rc1~44^2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/2e6d8f181dd77d40a1148549d4f33cdf2877fb19?ds=inline;hp=-c Merge branch 'jc/reflog' into lj/refs * jc/reflog: sha1_name.c: avoid compilation warnings. ref-log: allow ref@{count} syntax. --- 2e6d8f181dd77d40a1148549d4f33cdf2877fb19 diff --combined refs.c index ed2e3b16a7,d7f4aa5d87..f003a0b108 --- a/refs.c +++ b/refs.c @@@ -721,8 -721,7 +721,8 @@@ static int log_ref_write(struct ref_loc char *logrec; const char *committer; - if (log_all_ref_updates) { + if (log_all_ref_updates && + !strncmp(lock->ref_name, "refs/heads/", 11)) { if (safe_create_leading_directories(lock->log_file) < 0) return error("unable to create directory for %s", lock->log_file); @@@ -731,20 -730,10 +731,20 @@@ logfd = open(lock->log_file, oflags, 0666); if (logfd < 0) { - if (!log_all_ref_updates && errno == ENOENT) + if (!(oflags & O_CREAT) && errno == ENOENT) return 0; - return error("Unable to append to %s: %s", - lock->log_file, strerror(errno)); + + if ((oflags & O_CREAT) && errno == EISDIR) { + if (remove_empty_directories(lock->log_file)) { + return error("There are still logs under '%s'", + lock->log_file); + } + logfd = open(lock->log_file, oflags, 0666); + } + + if (logfd < 0) + return error("Unable to append to %s: %s", + lock->log_file, strerror(errno)); } committer = git_committer_info(1); @@@ -806,7 -795,7 +806,7 @@@ int write_ref_sha1(struct ref_lock *loc return 0; } - int read_ref_at(const char *ref, unsigned long at_time, unsigned char *sha1) + int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1) { const char *logfile, *logdata, *logend, *rec, *lastgt, *lastrec; char *tz_c; @@@ -839,7 -828,7 +839,7 @@@ if (!lastgt) die("Log %s is corrupt.", logfile); date = strtoul(lastgt + 1, &tz_c, 10); - if (date <= at_time) { + if (date <= at_time || cnt == 0) { if (lastrec) { if (get_sha1_hex(lastrec, logged_sha1)) die("Log %s is corrupt.", logfile); @@@ -870,6 -859,8 +870,8 @@@ return 0; } lastrec = rec; + if (cnt > 0) + cnt--; } rec = logdata;