summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 63d285c)
raw | patch | inline | side by side (parent: 63d285c)
author | André Goddard Rosa <andre.goddard@gmail.com> | |
Thu, 22 Nov 2007 22:22:23 +0000 (20:22 -0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 30 Nov 2007 21:10:11 +0000 (13:10 -0800) |
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
builtin-fetch--tool.c | patch | blob | history | |
builtin-fetch.c | patch | blob | history |
diff --git a/builtin-fetch--tool.c b/builtin-fetch--tool.c
index ed60847d9fcd0ad8803c432af8d0bc2dd3567768..7460ab7fce2a4e6a7e014f448819140e2204ccb7 100644 (file)
--- a/builtin-fetch--tool.c
+++ b/builtin-fetch--tool.c
if (!strcmp("append-fetch-head", argv[1])) {
int result;
FILE *fp;
+ char *filename;
if (argc != 8)
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],
argv[4], argv[5],
argv[6], !!argv[7][0],
if (!strcmp("native-store", argv[1])) {
int result;
FILE *fp;
+ char *filename;
if (argc != 5)
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],
verbose, force);
fclose(fp);
diff --git a/builtin-fetch.c b/builtin-fetch.c
index 31e138eab82a4a710916ff88386bd82bcf2f11d6..de9947e7ac2cc1236909fab813198b3df93bd39e 100644 (file)
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
}
}
-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;
struct commit *commit;
char note[1024];
const char *what, *kind;
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) {
struct ref *ref = NULL;
}
}
fclose(fp);
+ return 0;
}
/*
if (ret)
ret = transport_fetch_refs(transport, ref_map);
if (!ret)
- store_updated_refs(transport->url, ref_map);
+ ret |= store_updated_refs(transport->url, ref_map);
transport_unlock_pack(transport);
return ret;
}
die("Don't know how to fetch from %s", transport->url);
/* if not appending, truncate FETCH_HEAD */
- if (!append)
- fclose(fopen(git_path("FETCH_HEAD"), "w"));
+ if (!append) {
+ 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);