aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-08-08 14:21:32 -0700
committerJunio C Hamano <gitster@pobox.com>2016-08-08 14:21:32 -0700
commit327b3f8459a316aa5c27a8784f0f504122fce60e (patch)
treef197b28a0e74964acad5cdaefdd225cf39c8b428 /builtin
parent08df31eeccfe1576971ea4ba42570a424c3cfc41 (diff)
parentc66b470082144471fc95e669eb398c8f320d67c4 (diff)
downloadgit-327b3f8459a316aa5c27a8784f0f504122fce60e.tar.gz
git-327b3f8459a316aa5c27a8784f0f504122fce60e.tar.xz
Merge branch 'mh/blame-worktree' into maint
"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 9a035000b..d123e2e6a 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)