Error out when user doesn't have access permission to the repository

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
This commit is contained in:
André Goddard Rosa 2007-11-22 20:22:23 -02:00 коммит произвёл Junio C Hamano
Родитель 63d285c849
Коммит d6617c7cde
2 изменённых файлов: 24 добавлений и 7 удалений

Просмотреть файл

@ -511,10 +511,14 @@ int cmd_fetch__tool(int argc, const char **argv, const char *prefix)
if (!strcmp("append-fetch-head", argv[1])) { if (!strcmp("append-fetch-head", argv[1])) {
int result; int result;
FILE *fp; FILE *fp;
char *filename;
if (argc != 8) if (argc != 8)
return error("append-fetch-head takes 6 args"); return error("append-fetch-head takes 6 args");
fp = fopen(git_path("FETCH_HEAD"), "a"); filename = git_path("FETCH_HEAD");
fp = fopen(filename, "a");
if (!fp)
return error("cannot open %s: %s\n", filename, strerror(errno));
result = append_fetch_head(fp, argv[2], argv[3], result = append_fetch_head(fp, argv[2], argv[3],
argv[4], argv[5], argv[4], argv[5],
argv[6], !!argv[7][0], argv[6], !!argv[7][0],
@ -525,10 +529,14 @@ int cmd_fetch__tool(int argc, const char **argv, const char *prefix)
if (!strcmp("native-store", argv[1])) { if (!strcmp("native-store", argv[1])) {
int result; int result;
FILE *fp; FILE *fp;
char *filename;
if (argc != 5) if (argc != 5)
return error("fetch-native-store takes 3 args"); return error("fetch-native-store takes 3 args");
fp = fopen(git_path("FETCH_HEAD"), "a"); filename = git_path("FETCH_HEAD");
fp = fopen(filename, "a");
if (!fp)
return error("cannot open %s: %s\n", filename, strerror(errno));
result = fetch_native_store(fp, argv[2], argv[3], argv[4], result = fetch_native_store(fp, argv[2], argv[3], argv[4],
verbose, force); verbose, force);
fclose(fp); fclose(fp);

Просмотреть файл

@ -255,7 +255,7 @@ static int update_local_ref(struct ref *ref,
} }
} }
static void store_updated_refs(const char *url, struct ref *ref_map) static int store_updated_refs(const char *url, struct ref *ref_map)
{ {
FILE *fp; FILE *fp;
struct commit *commit; struct commit *commit;
@ -263,8 +263,11 @@ static void store_updated_refs(const char *url, struct ref *ref_map)
char note[1024]; char note[1024];
const char *what, *kind; const char *what, *kind;
struct ref *rm; struct ref *rm;
char *filename = git_path("FETCH_HEAD");
fp = fopen(git_path("FETCH_HEAD"), "a"); fp = fopen(filename, "a");
if (!fp)
return error("cannot open %s: %s\n", filename, strerror(errno));
for (rm = ref_map; rm; rm = rm->next) { for (rm = ref_map; rm; rm = rm->next) {
struct ref *ref = NULL; struct ref *ref = NULL;
@ -335,6 +338,7 @@ static void store_updated_refs(const char *url, struct ref *ref_map)
} }
} }
fclose(fp); fclose(fp);
return 0;
} }
/* /*
@ -404,7 +408,7 @@ static int fetch_refs(struct transport *transport, struct ref *ref_map)
if (ret) if (ret)
ret = transport_fetch_refs(transport, ref_map); ret = transport_fetch_refs(transport, ref_map);
if (!ret) if (!ret)
store_updated_refs(transport->url, ref_map); ret |= store_updated_refs(transport->url, ref_map);
transport_unlock_pack(transport); transport_unlock_pack(transport);
return ret; return ret;
} }
@ -487,8 +491,13 @@ static int do_fetch(struct transport *transport,
die("Don't know how to fetch from %s", transport->url); die("Don't know how to fetch from %s", transport->url);
/* if not appending, truncate FETCH_HEAD */ /* if not appending, truncate FETCH_HEAD */
if (!append) if (!append) {
fclose(fopen(git_path("FETCH_HEAD"), "w")); char *filename = git_path("FETCH_HEAD");
FILE *fp = fopen(filename, "w");
if (!fp)
return error("cannot open %s: %s\n", filename, strerror(errno));
fclose(fp);
}
ref_map = get_ref_map(transport, refs, ref_count, tags, &autotags); ref_map = get_ref_map(transport, refs, ref_count, tags, &autotags);