#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;
free(p);
}
-static int get_blob_sha1_internal(unsigned char *sha1, const char *base,
+static int get_blob_sha1_internal(const unsigned char *sha1, const char *base,
int baselen, const char *pathname,
unsigned mode, int stage);
return 0;
}
-static int get_blob_sha1_internal(unsigned char *sha1, const char *base,
+static int get_blob_sha1_internal(const unsigned char *sha1, const char *base,
int baselen, const char *pathname,
unsigned mode, int stage)
{
static int compare_tree_path(struct rev_info* revs,
struct commit* c1, struct commit* c2)
{
+ int ret;
const char* paths[2];
struct util_info* util = c2->object.util;
paths[0] = util->pathname;
paths[1] = NULL;
- diff_tree_setup_paths(get_pathspec(revs->prefix, paths));
- return rev_compare_tree(c1->tree, c2->tree);
+ diff_tree_setup_paths(get_pathspec(revs->prefix, paths),
+ &revs->pruning);
+ ret = rev_compare_tree(revs, c1->tree, c2->tree);
+ diff_tree_release_paths(&revs->pruning);
+ return ret;
}
static int same_tree_as_empty_path(struct rev_info *revs, struct tree* t1,
const char* path)
{
+ int ret;
const char* paths[2];
paths[0] = path;
paths[1] = NULL;
- diff_tree_setup_paths(get_pathspec(revs->prefix, paths));
- return rev_same_tree_as_empty(t1);
+ diff_tree_setup_paths(get_pathspec(revs->prefix, paths),
+ &revs->pruning);
+ ret = rev_same_tree_as_empty(revs, t1);
+ diff_tree_release_paths(&revs->pruning);
+ return ret;
}
static const char* find_rename(struct commit* commit, struct commit* parent)
diff_opts.recursive = 1;
diff_opts.detect_rename = DIFF_DETECT_RENAME;
paths[0] = NULL;
- diff_tree_setup_paths(paths);
+ diff_tree_setup_paths(paths, &diff_opts);
if (diff_setup_done(&diff_opts) < 0)
die("diff_setup_done failed");
*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);
char filename_buf[256];
int sha1_len = 8;
int compability = 0;
+ int show_raw_time = 0;
int options = 1;
struct commit* start_commit;
!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)) {
rev.prune_fn = simplify_commit;
rev.topo_setter = topo_setter;
rev.topo_getter = topo_getter;
+ rev.parents = 1;
rev.limited = 1;
commit_list_insert(start_commit, &rev.commits);
args[0] = filename;
args[1] = NULL;
- diff_tree_setup_paths(args);
+ diff_tree_setup_paths(args, &rev.pruning);
prepare_revision_walk(&rev);
process_commits(&rev, filename, &initial);
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);
}