test-lib.sh: set prerequisite SANITY by testing what we really need
[gitweb.git] / shallow.c
index c7602ce3a2076f1ec0dfdfaee65a1810f45e5601..de07709e3358947062984970e85005ded224baf9 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -263,9 +263,9 @@ void setup_alternate_shallow(struct lock_file *shallow_lock,
        struct strbuf sb = STRBUF_INIT;
        int fd;
 
-       check_shallow_file_for_update();
        fd = hold_lock_file_for_update(shallow_lock, git_path("shallow"),
                                       LOCK_DIE_ON_ERROR);
+       check_shallow_file_for_update();
        if (write_shallow_commits(&sb, 0, extra)) {
                if (write_in_full(fd, sb.buf, sb.len) != sb.len)
                        die_errno("failed to write to %s",
@@ -310,9 +310,9 @@ void prune_shallow(int show_only)
                strbuf_release(&sb);
                return;
        }
-       check_shallow_file_for_update();
        fd = hold_lock_file_for_update(&shallow_lock, git_path("shallow"),
                                       LOCK_DIE_ON_ERROR);
+       check_shallow_file_for_update();
        if (write_shallow_commits_1(&sb, 0, NULL, SEEN_ONLY)) {
                if (write_in_full(fd, sb.buf, sb.len) != sb.len)
                        die_errno("failed to write to %s",
@@ -325,7 +325,7 @@ void prune_shallow(int show_only)
        strbuf_release(&sb);
 }
 
-#define TRACE_KEY "GIT_TRACE_SHALLOW"
+struct trace_key trace_shallow = TRACE_KEY_INIT(SHALLOW);
 
 /*
  * Step 1, split sender shallow commits into "ours" and "theirs"
@@ -334,7 +334,7 @@ void prune_shallow(int show_only)
 void prepare_shallow_info(struct shallow_info *info, struct sha1_array *sa)
 {
        int i;
-       trace_printf_key(TRACE_KEY, "shallow: prepare_shallow_info\n");
+       trace_printf_key(&trace_shallow, "shallow: prepare_shallow_info\n");
        memset(info, 0, sizeof(*info));
        info->shallow = sa;
        if (!sa)
@@ -365,7 +365,7 @@ void remove_nonexistent_theirs_shallow(struct shallow_info *info)
 {
        unsigned char (*sha1)[20] = info->shallow->sha1;
        int i, dst;
-       trace_printf_key(TRACE_KEY, "shallow: remove_nonexistent_theirs_shallow\n");
+       trace_printf_key(&trace_shallow, "shallow: remove_nonexistent_theirs_shallow\n");
        for (i = dst = 0; i < info->nr_theirs; i++) {
                if (i != dst)
                        info->theirs[dst] = info->theirs[i];
@@ -516,7 +516,7 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
        int *shallow, nr_shallow = 0;
        struct paint_info pi;
 
-       trace_printf_key(TRACE_KEY, "shallow: assign_shallow_commits_to_refs\n");
+       trace_printf_key(&trace_shallow, "shallow: assign_shallow_commits_to_refs\n");
        shallow = xmalloc(sizeof(*shallow) * (info->nr_ours + info->nr_theirs));
        for (i = 0; i < info->nr_ours; i++)
                shallow[nr_shallow++] = info->ours[i];
@@ -622,7 +622,7 @@ static void post_assign_shallow(struct shallow_info *info,
        int bitmap_nr = (info->ref->nr + 31) / 32;
        struct commit_array ca;
 
-       trace_printf_key(TRACE_KEY, "shallow: post_assign_shallow\n");
+       trace_printf_key(&trace_shallow, "shallow: post_assign_shallow\n");
        if (ref_status)
                memset(ref_status, 0, sizeof(*ref_status) * info->ref->nr);