summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 732232a)
raw | patch | inline | side by side (parent: 732232a)
author | Shawn Pearce <spearce@spearce.org> | |
Fri, 19 May 2006 07:29:26 +0000 (03:29 -0400) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 19 May 2006 22:02:52 +0000 (15:02 -0700) |
If a ref is changed by http-fetch, local-fetch or ssh-fetch
record the change and the remote URL/name in the log for the ref.
This requires loading the config file to check logAllRefUpdates.
Also fixed a bug in the ref lock generation; the log file name was
not being produced right due to a bad prefix length.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
record the change and the remote URL/name in the log for the ref.
This requires loading the config file to check logAllRefUpdates.
Also fixed a bug in the ref lock generation; the log file name was
not being produced right due to a bad prefix length.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
fetch.c | patch | blob | history | |
fetch.h | patch | blob | history | |
http-fetch.c | patch | blob | history | |
local-fetch.c | patch | blob | history | |
refs.c | patch | blob | history | |
ssh-fetch.c | patch | blob | history |
index 8bdaacb8e87b9990e00023aa9baa6b7cda179437..fd57684d8fad43c92df8005aa8fe7b2cd9263bbb 100644 (file)
--- a/fetch.c
+++ b/fetch.c
#include "refs.h"
const char *write_ref = NULL;
+const char *write_ref_log_details = NULL;
const unsigned char *current_ref = NULL;
{
struct ref_lock *lock;
unsigned char sha1[20];
+ char *msg;
+ int ret;
save_commit_buffer = 0;
track_object_refs = 0;
if (write_ref) {
lock = lock_ref_sha1(write_ref, current_ref, 1);
- if (!lock)
+ if (!lock) {
+ error("Can't lock ref %s", write_ref);
return -1;
+ }
}
if (!get_recover) {
}
if (write_ref) {
- return write_ref_sha1(lock, sha1, "git fetch");
+ if (write_ref_log_details) {
+ msg = xmalloc(strlen(write_ref_log_details) + 12);
+ sprintf(msg, "fetch from %s", write_ref_log_details);
+ } else
+ msg = NULL;
+ ret = write_ref_sha1(lock, sha1, msg ? msg : "fetch (unknown)");
+ if (msg)
+ free(msg);
+ return ret;
}
return 0;
}
index 9837a3d03527ed648370f62b706978ad14fd20e5..0011548de8c3aa085944ac56a1568a433834145f 100644 (file)
--- a/fetch.h
+++ b/fetch.h
/* If set, the ref filename to write the target value to. */
extern const char *write_ref;
+/* If set additional text will appear in the ref log. */
+extern const char *write_ref_log_details;
+
/* If set, the hash that the current value of write_ref must be. */
extern const unsigned char *current_ref;
diff --git a/http-fetch.c b/http-fetch.c
index 861644b27ee0c01a780b68daa43c259dd978a538..cc7bd1f3676d58f62bb0c1e5d029d9273aecf2c0 100644 (file)
--- a/http-fetch.c
+++ b/http-fetch.c
int rc = 0;
setup_git_directory();
+ git_config(git_default_config);
while (arg < argc && argv[arg][0] == '-') {
if (argv[arg][1] == 't') {
}
commit_id = argv[arg];
url = argv[arg + 1];
+ write_ref_log_details = url;
http_init();
diff --git a/local-fetch.c b/local-fetch.c
index fa9e697fd3fa8fe305184f78fdf500532c14ab63..ffa4887570319a2cbcf4042bd6e00063a48a4b6d 100644 (file)
--- a/local-fetch.c
+++ b/local-fetch.c
int arg = 1;
setup_git_directory();
+ git_config(git_default_config);
while (arg < argc && argv[arg][0] == '-') {
if (argv[arg][1] == 't')
usage(local_pull_usage);
commit_id = argv[arg];
path = argv[arg + 1];
+ write_ref_log_details = path;
if (pull(commit_id))
return 1;
index 31cf27668df705ae0dda6d28a2e1e78d568a170d..d3ddc82d26ca72793e626204c246b8e5883153fa 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -142,6 +142,8 @@ static int do_for_each_ref(const char *base, int (*fn)(const char *path, const u
namelen = strlen(de->d_name);
if (namelen > 255)
continue;
+ if (namelen>5 && !strcmp(de->d_name+namelen-5,".lock"))
+ continue;
memcpy(path + baselen, de->d_name, namelen+1);
if (stat(git_path("%s", path), &st) < 0)
continue;
plen = strlen(path) - plen;
path = resolve_ref(path, lock->old_sha1, mustexist);
if (!path) {
- error("Can't read ref %s", path);
unlock_ref(lock);
return NULL;
}
if (check_ref_format(ref))
return NULL;
return lock_ref_sha1_basic(git_path("refs/%s", ref),
- strlen(ref), old_sha1, mustexist);
+ 5 + strlen(ref), old_sha1, mustexist);
}
struct ref_lock* lock_any_ref_for_update(const char *ref,
diff --git a/ssh-fetch.c b/ssh-fetch.c
index 4eb9e04829b5925ea07c764239f91e801e158c78..e3067b878e8721886c9fe61b136b46415165671d 100644 (file)
--- a/ssh-fetch.c
+++ b/ssh-fetch.c
if (!prog) prog = "git-ssh-upload";
setup_git_directory();
+ git_config(git_default_config);
while (arg < argc && argv[arg][0] == '-') {
if (argv[arg][1] == 't') {
}
commit_id = argv[arg];
url = argv[arg + 1];
+ write_ref_log_details = url;
if (setup_connection(&fd_in, &fd_out, prog, url, arg, argv + 1))
return 1;