* [PATCH] blame: Add --time to produce raw timestamps
@ 2006-06-12 21:42 Fredrik Kuivinen
2006-06-12 22:41 ` Johannes Schindelin
0 siblings, 1 reply; 3+ messages in thread
From: Fredrik Kuivinen @ 2006-06-12 21:42 UTC (permalink / raw)
To: git; +Cc: junkio
Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
---
Documentation/git-blame.txt | 5 ++++-
blame.c | 24 ++++++++++++++++++++----
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt
index 0a1fa00..bfed945 100644
--- a/Documentation/git-blame.txt
+++ b/Documentation/git-blame.txt
@@ -20,7 +20,10 @@ OPTIONS
Use the same output mode as git-annotate (Default: off).
-l, --long::
- Show long rev (Defaults off).
+ Show long rev (Default: off).
+
+-t, --time::
+ Show raw timestamp (Default: off).
-S, --rev-file <revs-file>::
Use revs from revs-file instead of calling git-rev-list.
diff --git a/blame.c b/blame.c
index 88bfec2..afa22b5 100644
--- a/blame.c
+++ b/blame.c
@@ -20,9 +20,11 @@ #include "xdiff-interface.h"
#define DEBUG 0
-static const char blame_usage[] = "[-c] [-l] [--] file [commit]\n"
+static const char blame_usage[] = "[-c] [-l] [-t] [-S <revs-file>] [--] file [commit]\n"
" -c, --compability Use the same output mode as git-annotate (Default: off)\n"
" -l, --long Show long commit SHA1 (Default: off)\n"
+ " -t, --time Show raw timestamp (Default: off)\n"
+ " -S, --revs-file Use revisions from revs-file instead of calling git-rev-list\n"
" -h, --help This message";
static struct commit **blame_lines;
@@ -680,13 +682,19 @@ static void get_commit_info(struct commi
*tmp = 0;
}
-static const char* format_time(unsigned long time, const char* tz_str)
+static const char* format_time(unsigned long time, const char* tz_str,
+ int raw_time)
{
static char time_buf[128];
time_t t = time;
int minutes, tz;
struct tm *tm;
+ if (raw_time) {
+ sprintf(time_buf, "%lu %s", time, tz_str);
+ return time_buf;
+ }
+
tz = atoi(tz_str);
minutes = tz < 0 ? -tz : tz;
minutes = (minutes / 100)*60 + (minutes % 100);
@@ -740,6 +748,7 @@ int main(int argc, const char **argv)
char filename_buf[256];
int sha1_len = 8;
int compability = 0;
+ int raw_time = 0;
int options = 1;
struct commit* start_commit;
@@ -768,6 +777,10 @@ int main(int argc, const char **argv)
!strcmp(argv[i], "--compability")) {
compability = 1;
continue;
+ } else if(!strcmp(argv[i], "-t") ||
+ !strcmp(argv[i], "--time")) {
+ raw_time = 1;
+ continue;
} else if(!strcmp(argv[i], "-S")) {
if (i + 1 < argc &&
!read_ancestry(argv[i + 1], &sha1_p)) {
@@ -873,14 +886,17 @@ int main(int argc, const char **argv)
fwrite(sha1_to_hex(c->object.sha1), sha1_len, 1, stdout);
if(compability) {
printf("\t(%10s\t%10s\t%d)", ci.author,
- format_time(ci.author_time, ci.author_tz), i+1);
+ format_time(ci.author_time, ci.author_tz,
+ raw_time),
+ i+1);
} else {
if (found_rename)
printf(" %-*.*s", longest_file, longest_file,
u->pathname);
printf(" (%-*.*s %10s %*d) ",
longest_author, longest_author, ci.author,
- format_time(ci.author_time, ci.author_tz),
+ format_time(ci.author_time, ci.author_tz,
+ raw_time),
max_digits, i+1);
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] blame: Add --time to produce raw timestamps
2006-06-12 21:42 [PATCH] blame: Add --time to produce raw timestamps Fredrik Kuivinen
@ 2006-06-12 22:41 ` Johannes Schindelin
2006-06-13 6:08 ` Fredrik Kuivinen
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin @ 2006-06-12 22:41 UTC (permalink / raw)
To: Fredrik Kuivinen; +Cc: git, junkio
Hi,
On Mon, 12 Jun 2006, Fredrik Kuivinen wrote:
> diff --git a/blame.c b/blame.c
> index 88bfec2..afa22b5 100644
> --- a/blame.c
> +++ b/blame.c
> @@ -20,9 +20,11 @@ #include "xdiff-interface.h"
>
> #define DEBUG 0
>
> -static const char blame_usage[] = "[-c] [-l] [--] file [commit]\n"
> +static const char blame_usage[] = "[-c] [-l] [-t] [-S <revs-file>] [--] file [commit]\n"
That is a bit more than the commit message says.
> + " -t, --time Show raw timestamp (Default: off)\n"
> + " -S, --revs-file Use revisions from revs-file instead of calling git-rev-list\n"
I smell white space corruption here.
> + int raw_time)
Just a tiny nit: could you name it "show_raw_time" instead of "raw_time"?
I got confused by that naming into believeing raw_time was actually a
timestamp, not a boolean...
Ciao,
Dscho
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] blame: Add --time to produce raw timestamps
2006-06-12 22:41 ` Johannes Schindelin
@ 2006-06-13 6:08 ` Fredrik Kuivinen
0 siblings, 0 replies; 3+ messages in thread
From: Fredrik Kuivinen @ 2006-06-13 6:08 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Fredrik Kuivinen, git, junkio
On Tue, Jun 13, 2006 at 12:41:19AM +0200, Johannes Schindelin wrote:
<comments on "blame: Add --time to produce raw timestamps">
Thanks for the comments. Updated patch below.
- Fredrik
-------
blame: Add --time to produce raw timestamps
fix the usage string and clean up the docs while we are at it
Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
---
Documentation/git-blame.txt | 5 ++++-
blame.c | 24 ++++++++++++++++++++----
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt
index 0a1fa00..bfed945 100644
--- a/Documentation/git-blame.txt
+++ b/Documentation/git-blame.txt
@@ -20,7 +20,10 @@ OPTIONS
Use the same output mode as git-annotate (Default: off).
-l, --long::
- Show long rev (Defaults off).
+ Show long rev (Default: off).
+
+-t, --time::
+ Show raw timestamp (Default: off).
-S, --rev-file <revs-file>::
Use revs from revs-file instead of calling git-rev-list.
diff --git a/blame.c b/blame.c
index 88bfec2..25d3bcf 100644
--- a/blame.c
+++ b/blame.c
@@ -20,9 +20,11 @@ #include "xdiff-interface.h"
#define DEBUG 0
-static const char blame_usage[] = "[-c] [-l] [--] file [commit]\n"
+static const char blame_usage[] = "[-c] [-l] [-t] [-S <revs-file>] [--] file [commit]\n"
" -c, --compability Use the same output mode as git-annotate (Default: off)\n"
" -l, --long Show long commit SHA1 (Default: off)\n"
+ " -t, --time Show raw timestamp (Default: off)\n"
+ " -S, --revs-file Use revisions from revs-file instead of calling git-rev-list\n"
" -h, --help This message";
static struct commit **blame_lines;
@@ -680,13 +682,19 @@ static void get_commit_info(struct commi
*tmp = 0;
}
-static const char* format_time(unsigned long time, const char* tz_str)
+static const char* format_time(unsigned long time, const char* tz_str,
+ int show_raw_time)
{
static char time_buf[128];
time_t t = time;
int minutes, tz;
struct tm *tm;
+ if (show_raw_time) {
+ sprintf(time_buf, "%lu %s", time, tz_str);
+ return time_buf;
+ }
+
tz = atoi(tz_str);
minutes = tz < 0 ? -tz : tz;
minutes = (minutes / 100)*60 + (minutes % 100);
@@ -740,6 +748,7 @@ int main(int argc, const char **argv)
char filename_buf[256];
int sha1_len = 8;
int compability = 0;
+ int show_raw_time = 0;
int options = 1;
struct commit* start_commit;
@@ -768,6 +777,10 @@ int main(int argc, const char **argv)
!strcmp(argv[i], "--compability")) {
compability = 1;
continue;
+ } else if(!strcmp(argv[i], "-t") ||
+ !strcmp(argv[i], "--time")) {
+ show_raw_time = 1;
+ continue;
} else if(!strcmp(argv[i], "-S")) {
if (i + 1 < argc &&
!read_ancestry(argv[i + 1], &sha1_p)) {
@@ -873,14 +886,17 @@ int main(int argc, const char **argv)
fwrite(sha1_to_hex(c->object.sha1), sha1_len, 1, stdout);
if(compability) {
printf("\t(%10s\t%10s\t%d)", ci.author,
- format_time(ci.author_time, ci.author_tz), i+1);
+ format_time(ci.author_time, ci.author_tz,
+ show_raw_time),
+ i+1);
} else {
if (found_rename)
printf(" %-*.*s", longest_file, longest_file,
u->pathname);
printf(" (%-*.*s %10s %*d) ",
longest_author, longest_author, ci.author,
- format_time(ci.author_time, ci.author_tz),
+ format_time(ci.author_time, ci.author_tz,
+ show_raw_time),
max_digits, i+1);
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-06-13 6:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-12 21:42 [PATCH] blame: Add --time to produce raw timestamps Fredrik Kuivinen
2006-06-12 22:41 ` Johannes Schindelin
2006-06-13 6:08 ` Fredrik Kuivinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).