preview of "What's cooking" (topics)
My git day this week hasn't started yet, but for people to base their improvements on, here is a quick status before I go to bed.
- Detached HEAD along with two patches to teach git-status and git-branch about not being on any branch are in 'pu'; I removed -d option from git-checkout from the previous round.
- Jürgen's git-status improvements are mostly in 'next' but one of them is queued in 'pu', waiting for comments.
- I've queued my counterproposal to Shawn's lockfile fix in 'pu', waiting for comments.
On the 'master' front, I've merged Andy's xwrite() loop. I think this is applicable to many other places after generalizing it a bit more and perhaps merging it with safe_write in pkt-line.c.
builtin-apply.c, builtin-unpack-objects.c, copy.c, csum-file.c, index-pack.c, merge-recursive.c and pkt-line.c have implementations of something very similar, with different policy on error handling.
Also index-pack.c and upload-pack.c (in the status reporting code path) also has unprotected xwrite() that can result in short write.
Have fun.
Quoted 2 lines · Junio C Hamano
- Jürgen's git-status improvements are mostly in 'next' but one of them is queued in 'pu', waiting for comments.
Here is a more detailed breakdown of the reasoning behind the remaining change in (slightly massaged) git-log format. Especially the usage of 'cached' and 'unstage' might not be that helpful.
==========
Add "cached" to cached content header in status output
Since we direct the user to use git-rm --cached this might be a good way to clarify it without loosing many words.
wt-status.c +1 -1
@@ -56,7 +56,7 @@ void wt_status_prepare(struct wt_status *s)static void wt_status_print_cached_header (const char *reference) {const char *c =color (WT_STATUS_HEADER ); -color_printf_ln (c,"# Changes to be committed:" ); +color_printf_ln (c,"# Cached changes to be committed:" );if (reference) {color_printf_ln (c,"# (use \"git reset %s <file>...\" and \"git rm --cached <file>...\" to unstage)" , reference); }else {
==========
Add unstaging hint to status output
If reference commit name is provided advertise git-reset otherwise instruct the user to use git-rm --cached. The latter case is needed to handle the initial commit.
Note that git-rm --cached is currently needed even if we have a reference commit, since git-reset cannot remove freshly added files from the index (yet).
wt-status.c +5 -0
@@ -57,6 +57,11 @@ static void wt_status_print_cached_header(const char *reference) {const char *c =color (WT_STATUS_HEADER );color_printf_ln (c,"# Changes to be committed:" ); +if (reference) { +color_printf_ln (c,"# (use \"git reset %s <file>...\" and \"git rm --cached <file>...\" to unstage)" , reference); + }else { +color_printf_ln (c,"# (use \"git rm --cached <file>...\" to unstage)" ); + }color_printf_ln (c,"#" ); }
==========
Simplify cached content header in status output
Replace awkward "Added but not yet committed (will commit)" by a simple "Changes to be committed".
wt-status.c +1 -2
@@ -56,8 +56,7 @@ void wt_status_prepare(struct wt_status *s)static void wt_status_print_cached_header (const char *reference) {const char *c =color (WT_STATUS_HEADER ); -color_printf_ln (c,"# Added but not yet committed:" ); -color_printf_ln (c,"# (will commit):" ); +color_printf_ln (c,"# Changes to be committed:" );color_printf_ln (c,"#" ); }
==========
Refactor printing of cached content header of status output
Since this header is printed in two different code paths and the name of the reference commit will be needed for the future unstaging hint, provide a new printing function.
wt-status.c +10 -4
@@ -53,6 +53,14 @@ void wt_status_prepare(struct wt_status *s) s->untracked =0 ; } +static void wt_status_print_cached_header (const char *reference) +{ +const char *c =color (WT_STATUS_HEADER ); +color_printf_ln (c,"# Added but not yet committed:" ); +color_printf_ln (c,"# (will commit):" ); +color_printf_ln (c,"#" ); +} +static void wt_status_print_header (const char *main,const char *sub) {const char *c =color (WT_STATUS_HEADER );
@@ -147,8 +155,7 @@ static void wt_status_print_updated_cb(struct diff_queue_struct *q,if (q->queue[i]->status =='U' )continue ;if (!shown_header) { -wt_status_print_header ("Added but not yet committed" , -"will commit" ); +wt_status_print_cached_header (s->reference); s->commitable =1 ; shown_header =1 ; }
@@ -179,8 +186,7 @@ void wt_status_print_initial(struct wt_status *s)read_cache ();if (active_nr) { s->commitable =1 ; -wt_status_print_header ("Added but not yet committed" , -"will commit" ); +wt_status_print_cached_header (NULL ); }for (i =0 ; i < active_nr; i++) {color_printf (color (WT_STATUS_HEADER ),"#\t" );