summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2016-07-25 14:13:45 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2016-07-25 14:13:45 -0700
commit37e9c7f5e15aa423cef640cc4dc137da2f73c5af (patch)
tree93e6584656c5fd138dfffba4261ab16811fa39df /builtin
parentMerge branch 'js/fsck-name-object' (diff)
parentt/t8003-blame-corner-cases.sh: Use here documents (diff)
downloadtgif-37e9c7f5e15aa423cef640cc4dc137da2f73c5af.tar.xz
Merge branch 'mh/blame-worktree'
"git blame file" allowed the lineage of lines in the uncommitted, unadded contents of "file" to be inspected, but it refused when "file" did not appear in the current commit. When "file" was created by renaming an existing file (but the change has not been committed), this restriction was unnecessarily tight. * mh/blame-worktree: t/t8003-blame-corner-cases.sh: Use here documents blame: allow to blame paths freshly added to the index
Diffstat (limited to 'builtin')
-rw-r--r--builtin/blame.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/builtin/blame.c b/builtin/blame.c
index 8fec0e1fb3..ab66cde2c2 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2229,6 +2229,7 @@ static int git_blame_config(const char *var, const char *value, void *cb)
static void verify_working_tree_path(struct commit *work_tree, const char *path)
{
struct commit_list *parents;
+ int pos;
for (parents = work_tree->parents; parents; parents = parents->next) {
const unsigned char *commit_sha1 = parents->item->object.oid.hash;
@@ -2239,7 +2240,14 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)
sha1_object_info(blob_sha1, NULL) == OBJ_BLOB)
return;
}
- die("no such path '%s' in HEAD", path);
+
+ pos = cache_name_pos(path, strlen(path));
+ if (pos >= 0)
+ ; /* path is in the index */
+ else if (!strcmp(active_cache[-1 - pos]->name, path))
+ ; /* path is in the index, unmerged */
+ else
+ die("no such path '%s' in HEAD", path);
}
static struct commit_list **append_parent(struct commit_list **tail, const unsigned char *sha1)