Re: [PATCH 0/5] Revamping "git status"

Subsystems: the rest

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH 0/5] Revamping "git status"

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:47:09

Thomas Rast [off-list ref] writes:
Meh, this stops before the git-status because merge signals a
conflict.  However, the following really crashes.  Promise.
Thanks.

 wt-status.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index f73bf47..6370fe2 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -236,7 +236,7 @@ static int unmerged_mask(const char *path)
 
 	mask = 0;
 	pos = -pos-1;
-	while (pos <= active_nr) {
+	while (pos < active_nr) {
 		ce = active_cache[pos++];
 		if (strcmp(ce->name, path))
 			break;

Re: [PATCH 0/5] Revamping "git status"

From: Thomas Rast <hidden>
Date: 2016-06-15 22:47:09

Junio C Hamano wrote:
-	while (pos <= active_nr) {
+	while (pos < active_nr) {
Thanks, that fixes it.

It gives a weird output now, however:

  # On branch side
  # Unmerged paths:
  #   (use "git reset HEAD <file>..." to unstage)
  #   (use "git add <file>..." to mark resolution)
  #
  #	deleted by us       : foo
  #
  # Changed but not updated:
  #   (use "git add <file>..." to update what will be committed)
  #   (use "git checkout -- <file>..." to discard changes in working directory)
  #
  #
  no changes added to commit (use "git add" and/or "git commit -a")

So it detects there are worktree changes, but then decides not to show
them because it's an unmerged entry.  I think the following should go
in 3/5, but note that I haven't looked at the rest of the code to
check if it breaks anything:

-- 8< --
diff --git i/wt-status.c w/wt-status.c
index 6370fe2..5a68297 100644
--- i/wt-status.c
+++ w/wt-status.c
@@ -400,7 +400,8 @@ static int wt_status_check_worktree_changes(struct wt_status *s)
 	for (i = 0; i < s->change.nr; i++) {
 		struct wt_status_change_data *d;
 		d = s->change.items[i].util;
-		if (!d->worktree_status)
+		if (!d->worktree_status
+		    || d->index_status == DIFF_STATUS_UNMERGED)
 			continue;
 		changes = 1;
 		if (d->worktree_status == DIFF_STATUS_DELETED)
-- >8 --
And with that fixed, the test I posted earlier should be changed to
the following so that it checks the output (the old version detects
failure even for a working git-status, because that exits 1):

-- 8< --
diff --git a/t/t7060-wtstatus.sh b/t/t7060-wtstatus.sh
index 5ad2cd1..76b20b2 100755
--- a/t/t7060-wtstatus.sh
+++ b/t/t7060-wtstatus.sh
@@ -28,4 +28,29 @@ test_expect_success 'Report new path with conflict' '
 	test_cmp expect actual
 '
 
+cat > expect <<EOF
+# On branch side
+# Unmerged paths:
+#   (use "git reset HEAD <file>..." to unstage)
+#   (use "git add <file>..." to mark resolution)
+#
+#	deleted by us       : foo
+#
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
+
+test_expect_success 'M/D conflict does not segfault' '
+	mkdir mdconflict &&
+	cd mdconflict &&
+	git init &&
+	test_commit initial foo '' &&
+	test_commit modify foo foo &&
+	git checkout -b side HEAD^ &&
+	git rm foo &&
+	git commit -m delete &&
+	test_must_fail git merge master &&
+	test_must_fail git status > ../actual &&
+	test_cmp ../expect ../actual
+'
+
 test_done
-- >8 --
-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help