summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d28790d)
raw | patch | inline | side by side (parent: d28790d)
author | Junio C Hamano <gitster@pobox.com> | |
Thu, 14 Jul 2011 04:36:29 +0000 (21:36 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 14 Jul 2011 04:39:18 +0000 (21:39 -0700) |
Because "diff --cached HEAD" showed an incorrect blob object name on the
LHS of the diff, we ended up updating the index entry with bogus value,
not what we read from the tree.
Noticed by John Nowak.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
LHS of the diff, we ended up updating the index entry with bogus value,
not what we read from the tree.
Noticed by John Nowak.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/reset.c | patch | blob | history | |
diff-lib.c | patch | blob | history | |
t/t7102-reset.sh | patch | blob | history |
diff --git a/builtin/reset.c b/builtin/reset.c
index 98bca044c1267fa63cb084a45aaf621e85f7d9b6..777e7c612900f867c5a52723ebdd56c9db793489 100644 (file)
--- a/builtin/reset.c
+++ b/builtin/reset.c
for (i = 0; i < q->nr; i++) {
struct diff_filespec *one = q->queue[i]->one;
- if (one->mode) {
+ if (one->mode && !is_null_sha1(one->sha1)) {
struct cache_entry *ce;
ce = make_cache_entry(one->mode, one->sha1, one->path,
0, 0);
diff --git a/diff-lib.c b/diff-lib.c
index 9c29293bbc05d175ba13338813e8532c7ad677cf..fd61acbdce8c65f5146b15af0ab322501f271794 100644 (file)
--- a/diff-lib.c
+++ b/diff-lib.c
if (cached && idx && ce_stage(idx)) {
struct diff_filepair *pair;
pair = diff_unmerge(&revs->diffopt, idx->name);
- fill_filespec(pair->one, idx->sha1, idx->ce_mode);
+ if (tree)
+ fill_filespec(pair->one, tree->sha1, tree->ce_mode);
return;
}
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index f1cfc9ac959ee281d50f7b8a51fdcefd2d0670e7..b096dc88c2f4caf28887cf8fea5d700f0132f5a3 100755 (executable)
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
test_i18ncmp expect output
'
+test_expect_success 'resetting specific path that is unmerged' '
+ git rm --cached file2 &&
+ F1=$(git rev-parse HEAD:file1) &&
+ F2=$(git rev-parse HEAD:file2) &&
+ F3=$(git rev-parse HEAD:secondfile) &&
+ {
+ echo "100644 $F1 1 file2" &&
+ echo "100644 $F2 2 file2" &&
+ echo "100644 $F3 3 file2"
+ } | git update-index --index-info &&
+ git ls-files -u &&
+ test_must_fail git reset HEAD file2 &&
+ git diff-index --exit-code --cached HEAD
+'
+
test_expect_success 'disambiguation (1)' '
git reset --hard &&