Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
blame: make sanity_check use a callback in scoreboard
author
Jeff Smith
<whydoubt@gmail.com>
Wed, 24 May 2017 05:15:25 +0000
(
00:15
-0500)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 24 May 2017 06:41:51 +0000
(15:41 +0900)
Allow the interface user to decide how to handle a failed sanity check,
whether that be to output with the current state or to do nothing.
Signed-off-by: Jeff Smith <whydoubt@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/blame.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
1f44129
)
diff --git
a/builtin/blame.c
b/builtin/blame.c
index 90c643c7da671235ad51b563d93db7e5fa56b431..1b53325ff3f3b351262662d147aeb463d963a36e 100644
(file)
--- a/
builtin/blame.c
+++ b/
builtin/blame.c
@@
-387,6
+387,10
@@
struct blame_scoreboard {
int show_root;
int xdl_opts;
int no_whole_file_rename;
int show_root;
int xdl_opts;
int no_whole_file_rename;
+ int debug;
+
+ /* callbacks */
+ void(*on_sanity_fail)(struct blame_scoreboard *, int);
};
static void sanity_check_refcnt(struct blame_scoreboard *);
};
static void sanity_check_refcnt(struct blame_scoreboard *);
@@
-412,7
+416,7
@@
static void blame_coalesce(struct blame_scoreboard *sb)
}
}
}
}
- if (
DEBUG
) /* sanity */
+ if (
sb->debug
) /* sanity */
sanity_check_refcnt(sb);
}
sanity_check_refcnt(sb);
}
@@
-1809,7
+1813,7
@@
static void assign_blame(struct blame_scoreboard *sb, int opt)
}
blame_origin_decref(suspect);
}
blame_origin_decref(suspect);
- if (
DEBUG
) /* sanity */
+ if (
sb->debug
) /* sanity */
sanity_check_refcnt(sb);
}
sanity_check_refcnt(sb);
}
@@
-2148,12
+2152,16
@@
static void sanity_check_refcnt(struct blame_scoreboard *sb)
baa = 1;
}
}
baa = 1;
}
}
- if (baa) {
- int opt = 0160;
- find_alignment(sb, &opt);
- output(sb, opt);
- die("Baa %d!", baa);
- }
+ if (baa)
+ sb->on_sanity_fail(sb, baa);
+}
+
+static void sanity_check_on_fail(struct blame_scoreboard *sb, int baa)
+{
+ int opt = OUTPUT_SHOW_SCORE | OUTPUT_SHOW_NUMBER | OUTPUT_SHOW_NAME;
+ find_alignment(sb, &opt);
+ output(sb, opt);
+ die("Baa %d!", baa);
}
static unsigned parse_score(const char *arg)
}
static unsigned parse_score(const char *arg)
@@
-2888,6
+2896,9
@@
int cmd_blame(int argc, const char **argv, const char *prefix)
if (blame_copy_score)
sb.copy_score = blame_copy_score;
if (blame_copy_score)
sb.copy_score = blame_copy_score;
+ sb.debug = DEBUG;
+ sb.on_sanity_fail = &sanity_check_on_fail;
+
sb.show_root = show_root;
sb.xdl_opts = xdl_opts;
sb.no_whole_file_rename = no_whole_file_rename;
sb.show_root = show_root;
sb.xdl_opts = xdl_opts;
sb.no_whole_file_rename = no_whole_file_rename;