summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--object-file.c2
-rw-r--r--read-cache.c3
-rwxr-xr-xt/t3700-add.sh1
3 files changed, 2 insertions, 4 deletions
diff --git a/object-file.c b/object-file.c
index 6ff6cf7549..bb0c77b45d 100644
--- a/object-file.c
+++ b/object-file.c
@@ -1297,7 +1297,7 @@ int index_path(struct index_state *istate, struct object_id *oid,
break;
case S_IFDIR:
if (repo_resolve_gitlink_ref(istate->repo, path, "HEAD", oid))
- return -1;
+ return error(_("'%s' does not have a commit checked out"), path);
if (&hash_algos[oid->algo] != istate->repo->hash_algo)
return error(_("cannot add a submodule of a different hash algorithm"));
break;
diff --git a/read-cache.c b/read-cache.c
index 06ad74db22..e34c5c56c6 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -707,7 +707,6 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
int add_option = (ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE|
(intent_only ? ADD_CACHE_NEW_ONLY : 0));
unsigned hash_flags = pretend ? 0 : INDEX_WRITE_OBJECT;
- struct object_id oid;
if (flags & ADD_CACHE_RENORMALIZE)
hash_flags |= INDEX_RENORMALIZE;
@@ -717,8 +716,6 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
namelen = strlen(path);
if (S_ISDIR(st_mode)) {
- if (repo_resolve_gitlink_ref(the_repository, path, "HEAD", &oid) < 0)
- return error(_("'%s' does not have a commit checked out"), path);
while (namelen && path[namelen-1] == '/')
namelen--;
}
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 9a2c8dbcc2..af93e53c12 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -388,6 +388,7 @@ test_expect_success 'error on a repository with no commits' '
test_must_fail git add empty >actual 2>&1 &&
cat >expect <<-EOF &&
error: '"'empty/'"' does not have a commit checked out
+ error: unable to index file '"'empty/'"'
fatal: adding files failed
EOF
test_cmp expect actual