Skip to content

Commit 725149b

Browse files
chriscoolgitster
authored andcommitted
usage: add get_error_routine() and get_warn_routine()
Let's make it possible to get the current error_routine and warn_routine, so that we can store them before using set_error_routine() or set_warn_routine() to use new ones. This way we will be able put back the original routines, when we are done with using new ones. Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b83f108 commit 725149b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

git-compat-util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,9 @@ static inline int const_error(void)
440440

441441
extern void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list params));
442442
extern void set_error_routine(void (*routine)(const char *err, va_list params));
443+
extern void (*get_error_routine(void))(const char *err, va_list params);
443444
extern void set_warn_routine(void (*routine)(const char *warn, va_list params));
445+
extern void (*get_warn_routine(void))(const char *warn, va_list params);
444446
extern void set_die_is_recursing_routine(int (*routine)(void));
445447
extern void set_error_handle(FILE *);
446448

usage.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,21 @@ void set_error_routine(void (*routine)(const char *err, va_list params))
7070
error_routine = routine;
7171
}
7272

73+
void (*get_error_routine(void))(const char *err, va_list params)
74+
{
75+
return error_routine;
76+
}
77+
7378
void set_warn_routine(void (*routine)(const char *warn, va_list params))
7479
{
7580
warn_routine = routine;
7681
}
7782

83+
void (*get_warn_routine(void))(const char *warn, va_list params)
84+
{
85+
return warn_routine;
86+
}
87+
7888
void set_die_is_recursing_routine(int (*routine)(void))
7989
{
8090
die_is_recursing = routine;

0 commit comments

Comments
 (0)