Submitted By: Kevin Day Date: 2021-05-13 Initial Package Version: n/a Upstream Status: Submitted Origin: Kevin Day Description: Provide the ability to use UTC when creating patches regardless of localtime. diff -Nurwp --set-utc diffutils-3.7.orig/man/diff.1 diffutils-3.7/man/diff.1 --- diffutils-3.7.orig/man/diff.1 2019-01-01 01:57:48.000000000 +0000 +++ diffutils-3.7/man/diff.1 2021-05-14 00:15:41.413005344 +0000 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.40.4. -.TH GNU "1" "December 2018" "diffutils 3.7" "User Commands" +.TH GNU "1" "May 2021" "diffutils 3.7" "User Commands" .SH NAME GNU diff \- compare files line by line .SH SYNOPSIS @@ -43,6 +43,9 @@ output only the left column of common li \fB\-\-suppress\-common\-lines\fR do not output common lines .TP +\fB\-\-set\-utc\fR +use UTC instead of local time +.TP \fB\-p\fR, \fB\-\-show\-c\-function\fR show which C function each change is in .TP diff -Nurwp --set-utc diffutils-3.7.orig/src/context.c diffutils-3.7/src/context.c --- diffutils-3.7.orig/src/context.c 2018-12-31 06:22:10.000000000 +0000 +++ diffutils-3.7/src/context.c 2021-05-14 00:11:30.612995027 +0000 @@ -37,6 +37,9 @@ static lin find_function_last_match; /* Print a label for a context diff, with a file name and date or a label. */ +/* Convert time_t to tm using either gmtime() or localtime(). */ +struct tm *(*tm_time)(const time_t *timep); + static void print_context_label (char const *mark, struct file_data *inf, @@ -50,7 +53,7 @@ print_context_label (char const *mark, { char buf[MAX (INT_STRLEN_BOUND (int) + 32, INT_STRLEN_BOUND (time_t) + 11)]; - struct tm const *tm = localtime (&inf->stat.st_mtime); + struct tm const *tm = tm_time (&inf->stat.st_mtime); int nsec = get_stat_mtime_ns (&inf->stat); if (! (tm && nstrftime (buf, sizeof buf, time_format, tm, 0, nsec))) { diff -Nurwp --set-utc diffutils-3.7.orig/src/diff.c diffutils-3.7/src/diff.c --- diffutils-3.7.orig/src/diff.c 2018-12-30 23:38:16.000000000 +0000 +++ diffutils-3.7/src/diff.c 2021-05-14 00:15:26.625004736 +0000 @@ -123,6 +123,7 @@ enum NO_IGNORE_FILE_NAME_CASE_OPTION, NORMAL_OPTION, SDIFF_MERGE_ASSIST_OPTION, + SET_UTC_OPTION, STRIP_TRAILING_CR_OPTION, SUPPRESS_BLANK_EMPTY_OPTION, SUPPRESS_COMMON_LINES_OPTION, @@ -205,6 +206,7 @@ static struct option const longopts[] = {"recursive", 0, 0, 'r'}, {"report-identical-files", 0, 0, 's'}, {"sdiff-merge-assist", 0, 0, SDIFF_MERGE_ASSIST_OPTION}, + {"set-utc", 0, 0, SET_UTC_OPTION}, {"show-c-function", 0, 0, 'p'}, {"show-function-line", 1, 0, 'F'}, {"side-by-side", 0, 0, 'y'}, @@ -297,6 +299,7 @@ main (int argc, char **argv) re_set_syntax (RE_SYNTAX_GREP | RE_NO_POSIX_BACKTRACKING); excluded = new_exclude (); presume_output_tty = false; + tm_time = &localtime; /* Decode the options. */ @@ -594,6 +597,10 @@ main (int argc, char **argv) sdiff_merge_assist = true; break; + case SET_UTC_OPTION: + tm_time = &gmtime; + break; + case STRIP_TRAILING_CR_OPTION: strip_trailing_cr = true; break; @@ -899,6 +906,7 @@ static char const * const option_help_ms N_("-W, --width=NUM output at most NUM (default 130) print columns"), N_(" --left-column output only the left column of common lines"), N_(" --suppress-common-lines do not output common lines"), + N_(" --set-utc use UTC instead of local time"), "", N_("-p, --show-c-function show which C function each change is in"), N_("-F, --show-function-line=RE show the most recent line matching RE"), diff -Nurwp --set-utc diffutils-3.7.orig/src/diff.h diffutils-3.7/src/diff.h --- diffutils-3.7.orig/src/diff.h 2018-01-07 00:50:55.000000000 +0000 +++ diffutils-3.7/src/diff.h 2021-05-14 00:09:46.800990756 +0000 @@ -350,6 +350,7 @@ extern int diff_2_files (struct comparis /* context.c */ extern void print_context_header (struct file_data[], char const * const *, bool); extern void print_context_script (struct change *, bool); +extern struct tm *(*tm_time)(const time_t *timep); /* dir.c */ extern int diff_dirs (struct comparison const *,