[PATCH] Properly handle typechange in git add -u.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



	* builtin-add.c (update_callback): Add a case for
	DIFF_STATUS_TYPE_CHANGED and a fix a typo in the error message.
	* t/t2200-add-update.sh: Add a new test.

Signed-off-by: Benoit Sigoure <tsuna@xxxxxxxxxxxxx>
---

Credits: Junio made the fix on IRC, I merely fixed the typo and added a test
case (hopefully in the right place).

 builtin-add.c         |    3 ++-
 t/t2200-add-update.sh |   11 ++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/builtin-add.c b/builtin-add.c
index 105a9f0..9d6d3d2 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -95,9 +95,10 @@ static void update_callback(struct diff_queue_struct *q,
 		const char *path = p->one->path;
 		switch (p->status) {
 		default:
-			die("unexpacted diff status %c", p->status);
+			die("unexpected diff status %c", p->status);
 		case DIFF_STATUS_UNMERGED:
 		case DIFF_STATUS_MODIFIED:
+                case DIFF_STATUS_TYPE_CHANGED:
 			add_file_to_cache(path, verbose);
 			break;
 		case DIFF_STATUS_DELETED:
diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index 61d08bb..eb1ced3 100755
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
@@ -16,11 +16,12 @@ only the updates to dir/sub.'
 test_expect_success setup '
 	echo initial >check &&
 	echo initial >top &&
+	echo initial >foo &&
 	mkdir dir1 dir2 &&
 	echo initial >dir1/sub1 &&
 	echo initial >dir1/sub2 &&
 	echo initial >dir2/sub3 &&
-	git add check dir1 dir2 top &&
+	git add check dir1 dir2 top foo &&
 	test_tick
 	git-commit -m initial &&
 
@@ -76,4 +77,12 @@ test_expect_success 'change gets noticed' '
 
 '
 
+test_expect_success 'replace a file with a symlink' '
+
+	rm foo &&
+	ln -s top foo &&
+	git add -u -- foo
+
+'
+
 test_done
-- 
1.5.3.1.7.gdff1c-dirty

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux