Merge branch 'jc/maint-add-u-remove-conflicted'
* jc/maint-add-u-remove-conflicted: add -u: do not fail to resolve a path as deletedmaint
commit
f39e4cfa2e
20
read-cache.c
20
read-cache.c
|
@ -1574,6 +1574,26 @@ static void update_callback(struct diff_queue_struct *q,
|
||||||
default:
|
default:
|
||||||
die("unexpected diff status %c", p->status);
|
die("unexpected diff status %c", p->status);
|
||||||
case DIFF_STATUS_UNMERGED:
|
case DIFF_STATUS_UNMERGED:
|
||||||
|
/*
|
||||||
|
* ADD_CACHE_IGNORE_REMOVAL is unset if "git
|
||||||
|
* add -u" is calling us, In such a case, a
|
||||||
|
* missing work tree file needs to be removed
|
||||||
|
* if there is an unmerged entry at stage #2,
|
||||||
|
* but such a diff record is followed by
|
||||||
|
* another with DIFF_STATUS_DELETED (and if
|
||||||
|
* there is no stage #2, we won't see DELETED
|
||||||
|
* nor MODIFIED). We can simply continue
|
||||||
|
* either way.
|
||||||
|
*/
|
||||||
|
if (!(data->flags & ADD_CACHE_IGNORE_REMOVAL))
|
||||||
|
continue;
|
||||||
|
/*
|
||||||
|
* Otherwise, it is "git add path" is asking
|
||||||
|
* to explicitly add it; we fall through. A
|
||||||
|
* missing work tree file is an error and is
|
||||||
|
* caught by add_file_to_index() in such a
|
||||||
|
* case.
|
||||||
|
*/
|
||||||
case DIFF_STATUS_MODIFIED:
|
case DIFF_STATUS_MODIFIED:
|
||||||
case DIFF_STATUS_TYPE_CHANGED:
|
case DIFF_STATUS_TYPE_CHANGED:
|
||||||
if (add_file_to_index(&the_index, path, data->flags)) {
|
if (add_file_to_index(&the_index, path, data->flags)) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ and issues a git add -u with path limiting on "dir" to add
|
||||||
only the updates to dir/sub.
|
only the updates to dir/sub.
|
||||||
|
|
||||||
Also tested are "git add -u" without limiting, and "git add -u"
|
Also tested are "git add -u" without limiting, and "git add -u"
|
||||||
without contents changes.'
|
without contents changes, and other conditions'
|
||||||
|
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
|
@ -128,4 +128,52 @@ test_expect_success 'add -n -u should not add but just report' '
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'add -u resolves unmerged paths' '
|
||||||
|
git reset --hard &&
|
||||||
|
one=$(echo 1 | git hash-object -w --stdin) &&
|
||||||
|
two=$(echo 2 | git hash-object -w --stdin) &&
|
||||||
|
three=$(echo 3 | git hash-object -w --stdin) &&
|
||||||
|
{
|
||||||
|
for path in path1 path2
|
||||||
|
do
|
||||||
|
echo "100644 $one 1 $path"
|
||||||
|
echo "100644 $two 2 $path"
|
||||||
|
echo "100644 $three 3 $path"
|
||||||
|
done
|
||||||
|
echo "100644 $one 1 path3"
|
||||||
|
echo "100644 $one 1 path4"
|
||||||
|
echo "100644 $one 3 path5"
|
||||||
|
echo "100644 $one 3 path6"
|
||||||
|
} |
|
||||||
|
git update-index --index-info &&
|
||||||
|
echo 3 >path1 &&
|
||||||
|
echo 2 >path3 &&
|
||||||
|
echo 2 >path5 &&
|
||||||
|
git add -u &&
|
||||||
|
git ls-files -s "path?" >actual &&
|
||||||
|
{
|
||||||
|
echo "100644 $three 0 path1"
|
||||||
|
echo "100644 $one 1 path3"
|
||||||
|
echo "100644 $one 1 path4"
|
||||||
|
echo "100644 $one 3 path5"
|
||||||
|
echo "100644 $one 3 path6"
|
||||||
|
} >expect &&
|
||||||
|
test_cmp expect actual &&
|
||||||
|
|
||||||
|
# Bonus tests. Explicit resolving
|
||||||
|
git add path3 path5 &&
|
||||||
|
test_must_fail git add path4 &&
|
||||||
|
test_must_fail git add path6 &&
|
||||||
|
git rm path4 &&
|
||||||
|
git rm path6 &&
|
||||||
|
|
||||||
|
git ls-files -s "path?" >actual &&
|
||||||
|
{
|
||||||
|
echo "100644 $three 0 path1"
|
||||||
|
echo "100644 $two 0 path3"
|
||||||
|
echo "100644 $two 0 path5"
|
||||||
|
} >expect
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Loading…
Reference in New Issue