aboutsummaryrefslogtreecommitdiff
path: root/blame.c
diff options
context:
space:
mode:
authorFredrik Kuivinen <freku045@student.liu.se>2006-06-13 08:08:31 +0200
committerJunio C Hamano <junkio@cox.net>2006-06-16 22:45:11 -0700
commitb19ee24b22b3c1d08f06e8f868f11d9e8639fd30 (patch)
tree035c5e4c4da0398c5138a6bd44b7dcf8e046c748 /blame.c
parentd8498500ba5cf348577202e0bb7810cbd68fa120 (diff)
downloadgit-b19ee24b22b3c1d08f06e8f868f11d9e8639fd30.tar.gz
git-b19ee24b22b3c1d08f06e8f868f11d9e8639fd30.tar.xz
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> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'blame.c')
-rw-r--r--blame.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/blame.c b/blame.c
index 88bfec262..25d3bcf64 100644
--- a/blame.c
+++ b/blame.c
@@ -20,9 +20,11 @@
#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 commit* commit, struct commit_info* ret)
*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);
}