aboutsummaryrefslogtreecommitdiff
path: root/builtin-blame.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-12-20 13:58:10 -0800
committerJunio C Hamano <junkio@cox.net>2006-12-20 13:58:10 -0800
commite035ce939d7e26afee4936ed32f1db9428ac026e (patch)
tree26b8a2e4707bcc064dac9f6a2c4e17c617b9af2e /builtin-blame.c
parent55e268e7ed9638239e80e0fcd5ebe1c875a985fb (diff)
parent4c10a5caa7d5e481a2acefbae71b694ab7e57108 (diff)
downloadgit-e035ce939d7e26afee4936ed32f1db9428ac026e.tar.gz
git-e035ce939d7e26afee4936ed32f1db9428ac026e.tar.xz
Merge branch 'jc/blame'
* jc/blame: blame: -b (blame.blankboundary) and --root (blame.showroot)
Diffstat (limited to 'builtin-blame.c')
-rw-r--r--builtin-blame.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/builtin-blame.c b/builtin-blame.c
index 9bf6ec951..4a1accf13 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -18,7 +18,9 @@
static char blame_usage[] =
"git-blame [-c] [-l] [-t] [-f] [-n] [-p] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [commit] [--] file\n"
" -c, --compatibility Use the same output mode as git-annotate (Default: off)\n"
+" -b Show blank SHA-1 for boundary commits (Default: off)\n"
" -l, --long Show long commit SHA1 (Default: off)\n"
+" --root Do not treat root commits as boundaries (Default: off)\n"
" -t, --time Show raw timestamp (Default: off)\n"
" -f, --show-name Show original filename (Default: auto)\n"
" -n, --show-number Show original linenumber (Default: off)\n"
@@ -32,6 +34,8 @@ static int longest_author;
static int max_orig_digits;
static int max_digits;
static int max_score_digits;
+static int show_root;
+static int blank_boundary;
#ifndef DEBUG
#define DEBUG 0
@@ -1091,6 +1095,9 @@ static void assign_blame(struct scoreboard *sb, struct rev_info *revs, int opt)
if (commit->object.parsed)
mark_parents_uninteresting(commit);
}
+ /* treat root commit as boundary */
+ if (!commit->parents && !show_root)
+ commit->object.flags |= UNINTERESTING;
/* Take responsibility for the remaining entries */
for (ent = sb->ent; ent; ent = ent->next)
@@ -1314,8 +1321,12 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
int length = (opt & OUTPUT_LONG_OBJECT_NAME) ? 40 : 8;
if (suspect->commit->object.flags & UNINTERESTING) {
- length--;
- putchar('^');
+ if (!blank_boundary) {
+ length--;
+ putchar('^');
+ }
+ else
+ memset(hex, ' ', length);
}
printf("%.*s", length, hex);
@@ -1635,6 +1646,19 @@ static void prepare_blame_range(struct scoreboard *sb,
usage(blame_usage);
}
+static int git_blame_config(const char *var, const char *value)
+{
+ if (!strcmp(var, "blame.showroot")) {
+ show_root = git_config_bool(var, value);
+ return 0;
+ }
+ if (!strcmp(var, "blame.blankboundary")) {
+ blank_boundary = git_config_bool(var, value);
+ return 0;
+ }
+ return git_default_config(var, value);
+}
+
int cmd_blame(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
@@ -1650,6 +1674,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
char type[10];
const char *bottomtop = NULL;
+ git_config(git_blame_config);
save_commit_buffer = 0;
opt = 0;
@@ -1658,6 +1683,10 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
const char *arg = argv[i];
if (*arg != '-')
break;
+ else if (!strcmp("-b", arg))
+ blank_boundary = 1;
+ else if (!strcmp("--root", arg))
+ show_root = 1;
else if (!strcmp("-c", arg))
output_option |= OUTPUT_ANNOTATE_COMPAT;
else if (!strcmp("-t", arg))