Allow the user to control the verbosity of merge-recursive.
[gitweb.git] / builtin-reflog.c
index a967117661c4cf888f992a198955d542f9182f21..7206b7a0139099c78b36f53c84705312f8daf8e5 100644 (file)
@@ -173,7 +173,6 @@ static int keep_entry(struct commit **it, unsigned char *sha1)
 {
        struct commit *commit;
 
-       *it = NULL;
        if (is_null_sha1(sha1))
                return 1;
        commit = lookup_commit_reference_gently(sha1, 1);
@@ -195,41 +194,46 @@ static int keep_entry(struct commit **it, unsigned char *sha1)
 }
 
 static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
-                            char *data, void *cb_data)
+               const char *email, unsigned long timestamp, int tz,
+               const char *message, void *cb_data)
 {
        struct expire_reflog_cb *cb = cb_data;
-       unsigned long timestamp;
-       char *cp, *ep;
        struct commit *old, *new;
 
-       cp = strchr(data, '>');
-       if (!cp || *++cp != ' ')
-               goto prune;
-       timestamp = strtoul(cp, &ep, 10);
-       if (*ep != ' ')
-               goto prune;
        if (timestamp < cb->cmd->expire_total)
                goto prune;
 
+       old = new = NULL;
        if (cb->cmd->stalefix &&
            (!keep_entry(&old, osha1) || !keep_entry(&new, nsha1)))
                goto prune;
 
-       if ((timestamp < cb->cmd->expire_unreachable) &&
-           (!cb->ref_commit ||
-            (old && !in_merge_bases(old, cb->ref_commit)) ||
-            (new && !in_merge_bases(new, cb->ref_commit))))
-               goto prune;
+       if (timestamp < cb->cmd->expire_unreachable) {
+               if (!cb->ref_commit)
+                       goto prune;
+               if (!old && !is_null_sha1(osha1))
+                       old = lookup_commit_reference_gently(osha1, 1);
+               if (!new && !is_null_sha1(nsha1))
+                       new = lookup_commit_reference_gently(nsha1, 1);
+               if ((old && !in_merge_bases(old, cb->ref_commit)) ||
+                   (new && !in_merge_bases(new, cb->ref_commit)))
+                       goto prune;
+       }
 
-       if (cb->newlog)
-               fprintf(cb->newlog, "%s %s %s",
-                       sha1_to_hex(osha1), sha1_to_hex(nsha1), data);
+       if (cb->newlog) {
+               char sign = (tz < 0) ? '-' : '+';
+               int zone = (tz < 0) ? (-tz) : tz;
+               fprintf(cb->newlog, "%s %s %s %lu %c%04d\t%s",
+                       sha1_to_hex(osha1), sha1_to_hex(nsha1),
+                       email, timestamp, sign, zone,
+                       message);
+       }
        if (cb->cmd->verbose)
-               printf("keep %s", data);
+               printf("keep %s", message);
        return 0;
  prune:
        if (!cb->newlog || cb->cmd->verbose)
-               printf("%sprune %s", cb->newlog ? "" : "would ", data);
+               printf("%sprune %s", cb->newlog ? "" : "would ", message);
        return 0;
 }