git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 1/2] extract setting of wt_status.commitable flag out of wt_status_print_updated()

From
Tay Ray Chuan <rctay89@gmail.com>
Date
Jun 4, 2015, 17:56 UTC
Message-ID
<1433440591-30917-2-git-send-email-rctay89@gmail.com>
In-Reply-To
<1433440591-30917-1-git-send-email-rctay89@gmail.com>

It may not be obvious from its name that wt_status_print_updated() that it also sets wt_status.commitable, which affects commit functionality. Extract this out into a separate function for improved clarity, though at the expense of executing another loop.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
Changed since v1
- move call to _mark_committable() to match original control-flow
  Originally, our placement of the call perhaps befitted aesthetics /
  logical grouping. But perhaps it is a better idea to match the original
  control flow to dispel any suspicion that this patch changed behaviour
  unintendedly.
 wt-status.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/wt-status.c b/wt-status.c
index c56c78f..87550ae 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -626,6 +626,21 @@ void wt_status_collect(struct wt_status *s)
 	wt_status_collect_untracked(s);
 }
 
+void wt_status_mark_commitable(struct wt_status *s)
+{
+	int i;
+
+	for (i = 0; i < s->change.nr; i++) {
+		struct wt_status_change_data *d;
+		d = s->change.items[i].util;
+		if (!d->index_status ||
+		    d->index_status == DIFF_STATUS_UNMERGED)
+			continue;
+		s->commitable = 1;
+		break;
+	}
+}
+
 static void wt_status_print_unmerged(struct wt_status *s)
 {
 	int shown_header = 0;
@@ -664,7 +679,6 @@ static void wt_status_print_updated(struct wt_status *s)
 			continue;
 		if (!shown_header) {
 			wt_status_print_cached_header(s);
-			s->commitable = 1;
 			shown_header = 1;
 		}
 		wt_status_print_change_data(s, WT_STATUS_UPDATED, it);
@@ -1360,6 +1374,7 @@ void wt_status_print(struct wt_status *s)
 
 	wt_status_print_updated(s);
 	wt_status_print_unmerged(s);
+	wt_status_mark_commitable(s);
 	wt_status_print_changed(s);
 	if (s->submodule_summary &&
 	    (!s->ignore_submodule_arg ||
-- 
2.0.0.581.g64f2558
Previous: Tay Ray ChuanNext: Tay Ray Chuan
Message 2 of 9 in “make commit --verbose work with --no-status”
  1. 0/2 make commit --verbose work with --no-statusTay Ray Chuan, Jun 4, 2015
  2. 1/2 extract setting of wt_status.commitable flag out of wt_status_print_updated()Tay Ray Chuan, Jun 4, 2015
  3. 2/2 make commit --verbose work with --no-statusTay Ray Chuan, Jun 4, 2015
  4. Junio C HamanoJun 4, 2015
  5. Junio C HamanoJun 4, 2015
  6. Tay Ray ChuanJun 5, 2015
  7. Junio C HamanoJun 5, 2015
  8. Tay Ray ChuanJun 5, 2015
  9. Junio C HamanoJun 5, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.