git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] add -u: do not fail to resolve a path as deleted
@ 2009-01-28 22:28 Junio C Hamano
  2009-01-28 23:32 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2009-01-28 22:28 UTC (permalink / raw)
  To: git

After you resolve a conflicted merge to remove the path, "git add -u"
failed to record the removal.  Instead it errored out by saying that the
removed path is not found in the work tree, but that is what the user
wanted to do and failing it is illogical.

This fixes it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 read-cache.c          |    5 +++++
 t/t2200-add-update.sh |   20 +++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index b1475ff..ddc0586 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1574,6 +1574,11 @@ static void update_callback(struct diff_queue_struct *q,
 		default:
 			die("unexpected diff status %c", p->status);
 		case DIFF_STATUS_UNMERGED:
+			/*
+			 * diff-files gives U followed by the work tree state
+			 * such as M or D, so we can ignore this.
+			 */
+			continue;
 		case DIFF_STATUS_MODIFIED:
 		case DIFF_STATUS_TYPE_CHANGED:
 			if (add_file_to_index(&the_index, path, data->flags)) {
diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index cd9231c..e917a01 100755
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
@@ -12,7 +12,7 @@ and issues a git add -u with path limiting on "dir" to add
 only the updates to dir/sub.
 
 Also tested are "git add -u" without limiting, and "git add -u"
-without contents changes.'
+without contents changes, and other conditions'
 
 . ./test-lib.sh
 
@@ -128,4 +128,22 @@ 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 |
+	git update-index --index-info &&
+	echo 4 >path1 &&
+	git add -u &&
+	test 1 = "$(git ls-files path1 path2 | wc -l)"
+'
+
 test_done
+
-- 
1.6.1.1.278.g6a817

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] add -u: do not fail to resolve a path as deleted
  2009-01-28 22:28 [PATCH] add -u: do not fail to resolve a path as deleted Junio C Hamano
@ 2009-01-28 23:32 ` Junio C Hamano
  2009-01-29  0:13   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2009-01-28 23:32 UTC (permalink / raw)
  To: git

Junio C Hamano <gitster@pobox.com> writes:

> After you resolve a conflicted merge to remove the path, "git add -u"
> failed to record the removal.  Instead it errored out by saying that the
> removed path is not found in the work tree, but that is what the user
> wanted to do and failing it is illogical.
>
> This fixes it.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  read-cache.c          |    5 +++++
>  t/t2200-add-update.sh |   20 +++++++++++++++++++-
>  2 files changed, 24 insertions(+), 1 deletions(-)
>
> diff --git a/read-cache.c b/read-cache.c
> index b1475ff..ddc0586 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -1574,6 +1574,11 @@ static void update_callback(struct diff_queue_struct *q,
>  		default:
>  			die("unexpected diff status %c", p->status);
>  		case DIFF_STATUS_UNMERGED:
> +			/*
> +			 * diff-files gives U followed by the work tree state
> +			 * such as M or D, so we can ignore this.
> +			 */
> +			continue;

This is wrong; breaks t3702.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] add -u: do not fail to resolve a path as deleted
  2009-01-28 23:32 ` Junio C Hamano
@ 2009-01-29  0:13   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2009-01-29  0:13 UTC (permalink / raw)
  To: git

Junio C Hamano <gitster@pobox.com> writes:

> This is wrong; breaks t3702.

Ugh; that is a bogus test.  Please disregard.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-01-29  0:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-28 22:28 [PATCH] add -u: do not fail to resolve a path as deleted Junio C Hamano
2009-01-28 23:32 ` Junio C Hamano
2009-01-29  0:13   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).