]> git.ipfire.org Git - thirdparty/git.git/blobdiff - commit.c
config.mak.uname: resolve FreeBSD iconv-related compilation warning
[thirdparty/git.git] / commit.c
index 1d7622b2ccaea0e30edada1f271f7ca3a694db2d..0030e79940ff8564b5c8c5ebab462eb1bd745174 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -13,6 +13,7 @@
 #include "prio-queue.h"
 #include "sha1-lookup.h"
 #include "wt-status.h"
+#include "advice.h"
 
 static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);
 
@@ -177,6 +178,15 @@ static int read_graft_file(const char *graft_file)
        struct strbuf buf = STRBUF_INIT;
        if (!fp)
                return -1;
+       if (advice_graft_file_deprecated)
+               advise(_("Support for <GIT_DIR>/info/grafts is deprecated\n"
+                        "and will be removed in a future Git version.\n"
+                        "\n"
+                        "Please use \"git replace --convert-graft-file\"\n"
+                        "to convert the grafts into replace refs.\n"
+                        "\n"
+                        "Turn this message off by running\n"
+                        "\"git config advice.graftFileDeprecated false\""));
        while (!strbuf_getwholeline(&buf, fp, '\n')) {
                /* The format is just "Commit Parent1 Parent2 ...\n" */
                struct commit_graft *graft = read_graft_line(&buf);
@@ -197,6 +207,9 @@ static void prepare_commit_graft(void)
 
        if (commit_graft_prepared)
                return;
+       if (!startup_info->have_repository)
+               return;
+
        graft_file = get_graft_file();
        read_graft_file(graft_file);
        /* make sure shallows are read */
@@ -348,7 +361,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s
        if (tail <= bufptr + tree_entry_len + 1 || memcmp(bufptr, "tree ", 5) ||
                        bufptr[tree_entry_len] != '\n')
                return error("bogus commit object %s", oid_to_hex(&item->object.oid));
-       if (get_sha1_hex(bufptr + 5, parent.hash) < 0)
+       if (get_oid_hex(bufptr + 5, &parent) < 0)
                return error("bad tree pointer in commit %s",
                             oid_to_hex(&item->object.oid));
        item->maybe_tree = lookup_tree(&parent);
@@ -360,7 +373,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s
                struct commit *new_parent;
 
                if (tail <= bufptr + parent_entry_len + 1 ||
-                   get_sha1_hex(bufptr + 7, parent.hash) ||
+                   get_oid_hex(bufptr + 7, &parent) ||
                    bufptr[parent_entry_len] != '\n')
                        return error("bad parents in commit %s", oid_to_hex(&item->object.oid));
                bufptr += parent_entry_len + 1;
@@ -1307,17 +1320,19 @@ struct commit_extra_header *read_commit_extra_headers(struct commit *commit,
        return extra;
 }
 
-void for_each_mergetag(each_mergetag_fn fn, struct commit *commit, void *data)
+int for_each_mergetag(each_mergetag_fn fn, struct commit *commit, void *data)
 {
        struct commit_extra_header *extra, *to_free;
+       int res = 0;
 
        to_free = read_commit_extra_headers(commit, NULL);
-       for (extra = to_free; extra; extra = extra->next) {
+       for (extra = to_free; !res && extra; extra = extra->next) {
                if (strcmp(extra->key, "mergetag"))
                        continue; /* not a merge tag */
-               fn(commit, extra, data);
+               res = fn(commit, extra, data);
        }
        free_commit_extra_headers(to_free);
+       return res;
 }
 
 static inline int standard_header_field(const char *field, size_t len)