@@ -714,7 +714,7 @@ static int git_blame_config(const char *var, const char *value, void *cb)
if (!strcmp(var, "blame.date")) {
if (!value)
return config_error_nonbool(var);
- parse_date_format(value, &blame_date_mode);
+ parse_date_format(value, &blame_date_mode, pager_in_use());
return 0;
}
if (!strcmp(var, "blame.ignorerevsfile")) {
@@ -185,7 +185,7 @@ static void cmd_log_init_defaults(struct rev_info *rev)
rev->diffopt.flags.allow_textconv = 1;
if (default_date_mode)
- parse_date_format(default_date_mode, &rev->date_mode);
+ parse_date_format(default_date_mode, &rev->date_mode, pager_in_use());
}
static void set_default_decoration_filter(struct decoration_filter *decoration_filter)
@@ -7,7 +7,6 @@
#include "git-compat-util.h"
#include "date.h"
#include "gettext.h"
-#include "pager.h"
#include "strbuf.h"
/*
@@ -1003,13 +1002,13 @@ static enum date_mode_type parse_date_type(const char *format, const char **end)
die("unknown date format %s", format);
}
-void parse_date_format(const char *format, struct date_mode *mode)
+void parse_date_format(const char *format, struct date_mode *mode, int pager_in_use)
{
const char *p;
/* "auto:foo" is "if tty/pager, then foo, otherwise normal" */
if (skip_prefix(format, "auto:", &p)) {
- if (isatty(1) || pager_in_use())
+ if (isatty(1) || pager_in_use)
format = p;
else
format = "default";
@@ -53,7 +53,7 @@ const char *show_date(timestamp_t time, int timezone, const struct date_mode *mo
* be used with strbuf_addftime(), in which case you'll need to call
* date_mode_release() later.
*/
-void parse_date_format(const char *format, struct date_mode *mode);
+void parse_date_format(const char *format, struct date_mode *mode, int pager_in_use);
/**
* Release a "struct date_mode", currently only required if
@@ -28,6 +28,7 @@
#include "worktree.h"
#include "hashmap.h"
#include "strvec.h"
+#include "pager.h"
static struct ref_msg {
const char *gone;
@@ -1323,7 +1324,7 @@ static void grab_date(const char *buf, struct atom_value *v, const char *atomnam
formatp = strchr(atomname, ':');
if (formatp) {
formatp++;
- parse_date_format(formatp, &date_mode);
+ parse_date_format(formatp, &date_mode, pager_in_use());
}
if (!eoemail)
@@ -46,6 +46,7 @@
#include "resolve-undo.h"
#include "parse-options.h"
#include "wildmatch.h"
+#include "pager.h"
volatile show_early_output_fn_t show_early_output;
@@ -2577,7 +2578,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
revs->date_mode.type = DATE_RELATIVE;
revs->date_mode_explicit = 1;
} else if ((argcount = parse_long_opt("date", argv, &optarg))) {
- parse_date_format(optarg, &revs->date_mode);
+ parse_date_format(optarg, &revs->date_mode, pager_in_use());
revs->date_mode_explicit = 1;
return argcount;
} else if (!strcmp(arg, "--log-size")) {
@@ -1,5 +1,6 @@
#include "test-tool.h"
#include "date.h"
+#include "pager.h"
#include "trace.h"
static const char *usage_msg = "\n"
@@ -37,7 +38,7 @@ static void show_dates(const char **argv, const char *format)
{
struct date_mode mode = DATE_MODE_INIT;
- parse_date_format(format, &mode);
+ parse_date_format(format, &mode, pager_in_use());
for (; *argv; argv++) {
char *arg;
timestamp_t t;
In order for date.c to be included in git-std-lib, the dependency to pager.h must be removed since it has dependencies on many other files not in git-std-lib. We achieve this by passing a boolean for "pager_in_use", rather than checking for it in parse_date_format() so callers of the function will have that dependency. Signed-off-by: Calvin Wan <calvinwan@google.com> --- builtin/blame.c | 2 +- builtin/log.c | 2 +- date.c | 5 ++--- date.h | 2 +- ref-filter.c | 3 ++- revision.c | 3 ++- t/helper/test-date.c | 3 ++- 7 files changed, 11 insertions(+), 9 deletions(-)