git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: dstolee@microsoft.com, Elijah Newren <newren@gmail.com>
Subject: [PATCH v2 0/2] Sparse checkout status
Date: Thu, 18 Jun 2020 20:49:56 +0000	[thread overview]
Message-ID: <pull.808.v2.git.git.1592513398.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.808.git.git.1592350413.gitgitgadget@gmail.com>

Some of the feedback of folks trying out sparse-checkouts at $dayjob is that
sparse checkouts can sometimes be disorienting; users can forget that they
had a sparse-checkout and then wonder where files went. This series adds
some output to 'git status' and modifies git-prompt slightly as an attempt
to help.

Note that as per discussion on v1, we may want to later add a git
sparse-checkout subcommand named something like 'stats' or 'info' or
'status' that provides more detailed information for users to dig deeper.
That would be an additional improvement for helping users find out more
information once they realize or remember they are in a sparse checkout,
this is just aimed at giving them a simple reminder.

Changes since v1:

 * Replaced the -1 magic constant with SPARSE_CHECKOUT_DISABLED
 * Fixed a possible division by 0 (when there are no entries in the index
   AND sparse checkout is enabled; not sure when that'd ever happen but
   still better to guard against...)
 * Slight wording tweaks for the git-prompt commit message
 * Removed the RFC label

Elijah Newren (2):
  wt-status: show sparse checkout status as well
  git-prompt: include sparsity state as well

 contrib/completion/git-prompt.sh |  7 +++++-
 wt-status.c                      | 41 ++++++++++++++++++++++++++++++++
 wt-status.h                      |  2 ++
 3 files changed, 49 insertions(+), 1 deletion(-)


base-commit: b3d7a52fac39193503a0b6728771d1bf6a161464
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-808%2Fnewren%2Fsparse-checkout-status-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-808/newren/sparse-checkout-status-v2
Pull-Request: https://github.com/git/git/pull/808

Range-diff vs v1:

 1:  462cee857ef ! 1:  e266bc39d99 [RFC] wt-status: show sparse checkout status as well
     @@ Metadata
      Author: Elijah Newren <newren@gmail.com>
      
       ## Commit message ##
     -    [RFC] wt-status: show sparse checkout status as well
     +    wt-status: show sparse checkout status as well
      
          Some of the early feedback of folks trying out sparse-checkouts at
          $dayjob is that sparse checkouts can sometimes be disorienting; users
     @@ wt-status.c: static void show_bisect_in_progress(struct wt_status *s,
      +static void show_sparse_checkout_in_use(struct wt_status *s,
      +					const char *color)
      +{
     -+	if (s->state.sparse_checkout_percentage != -1)
     -+		status_printf_ln(s, color,
     -+				 _("You are in a sparse checkout with %d%% of tracked files present."),
     -+				 s->state.sparse_checkout_percentage);
     ++	if (s->state.sparse_checkout_percentage == SPARSE_CHECKOUT_DISABLED)
     ++		return;
     ++
     ++	status_printf_ln(s, color,
     ++			 _("You are in a sparse checkout with %d%% of tracked files present."),
     ++			 s->state.sparse_checkout_percentage);
      +	wt_longstatus_print_trailer(s);
      +}
      +
     @@ wt-status.c: int wt_status_check_bisect(const struct worktree *wt,
      +	int skip_worktree = 0;
      +	int i;
      +
     -+	if (!core_apply_sparse_checkout) {
     -+		state->sparse_checkout_percentage = -1;
     ++	if (!core_apply_sparse_checkout || r->index->cache_nr == 0) {
     ++		/*
     ++		 * Don't compute percentage of checked out files if we
     ++		 * aren't in a sparse checkout or would get division by 0.
     ++		 */
     ++		state->sparse_checkout_percentage = SPARSE_CHECKOUT_DISABLED;
      +		return;
      +	}
      +
     @@ wt-status.c: static void wt_longstatus_print_state(struct wt_status *s)
       	if (state->bisect_in_progress)
       		show_bisect_in_progress(s, state_color);
      +
     -+	if (state->sparse_checkout_percentage != -1)
     ++	if (state->sparse_checkout_percentage != SPARSE_CHECKOUT_DISABLED)
      +		show_sparse_checkout_in_use(s, state_color);
       }
       
       static void wt_longstatus_print(struct wt_status *s)
      
       ## wt-status.h ##
     +@@ wt-status.h: enum wt_status_format {
     + 
     + #define HEAD_DETACHED_AT _("HEAD detached at ")
     + #define HEAD_DETACHED_FROM _("HEAD detached from ")
     ++#define SPARSE_CHECKOUT_DISABLED -1
     + 
     + struct wt_status_state {
     + 	int merge_in_progress;
      @@ wt-status.h: struct wt_status_state {
       	int bisect_in_progress;
       	int revert_in_progress;
       	int detached_at;
     -+	int sparse_checkout_percentage; /* -1 == not in sparse checkout */
     ++	int sparse_checkout_percentage; /* SPARSE_CHECKOUT_DISABLED if not sparse */
       	char *branch;
       	char *onto;
       	char *detached_from;
 2:  64613ad7ad6 ! 2:  17254b30a5b [RFC] git-prompt: include sparsity state as well
     @@ Metadata
      Author: Elijah Newren <newren@gmail.com>
      
       ## Commit message ##
     -    [RFC] git-prompt: include sparsity state as well
     +    git-prompt: include sparsity state as well
      
     -    The current git prompt includes a lot of possible state information, from
     -    various flavors of rebases to cherry-picks, or merges, or bisects.  Add
     +    The current git prompt includes a lot of possible state information from
     +    cherry-picks, merges, bisects, and various flavors of rebases.  Add
          sparsity as another state flavor (though one which can be present
          simultaneously with any of rebase/cherry-pick/merge/bisect).  This extra
          state is shown with an extra
              |SPARSE
     -    substring before the other states.  (Sparsity is probably not going to
     -    change much within a repository, while temporary operations will.  So we
     -    want the temporary operation related state changes to be listed last, to
     -    make them appear closer to where the user types and make them more
     -    likely to be noticed.)  Thus, for example, the prompt might look like:
     +    substring before the other states, providing a prompt that looks like:
              (branchname|SPARSE|REBASE 6/10)
      
     +    The reason for showing the "|SPARSE" substring before other states is to
     +    emphasize those other states.  Sparsity is probably not going to change
     +    much within a repository, while temporary operations will.  So we want
     +    the state changes related to temporary operations to be listed last, to
     +    make them appear closer to where the user types and make them more
     +    likely to be noticed.
     +
          Signed-off-by: Elijah Newren <newren@gmail.com>
      
       ## contrib/completion/git-prompt.sh ##

-- 
gitgitgadget

  parent reply	other threads:[~2020-06-18 20:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-16 23:33 [PATCH 0/2] Sparse checkout status Elijah Newren via GitGitGadget
2020-06-16 23:33 ` [PATCH 1/2] [RFC] wt-status: show sparse checkout status as well Elijah Newren via GitGitGadget
2020-06-17 14:50   ` Derrick Stolee
2020-06-17 15:46     ` Elijah Newren
2020-06-16 23:33 ` [PATCH 2/2] [RFC] git-prompt: include sparsity state " Elijah Newren via GitGitGadget
2020-06-18 20:49 ` Elijah Newren via GitGitGadget [this message]
2020-06-18 20:49   ` [PATCH v2 1/2] wt-status: show sparse checkout status " Elijah Newren via GitGitGadget
2020-06-18 20:49   ` [PATCH v2 2/2] git-prompt: include sparsity state " Elijah Newren via GitGitGadget
2020-06-19 16:15     ` SZEDER Gábor
2020-06-19 16:33       ` Junio C Hamano
2020-06-19 16:35         ` Junio C Hamano
2020-06-18 21:45   ` [PATCH v2 0/2] Sparse checkout status Junio C Hamano
2020-06-18 23:18     ` Elijah Newren
2020-06-21  1:34       ` Elijah Newren
2020-06-21  5:21   ` [PATCH v3 0/3] " Elijah Newren via GitGitGadget
2020-06-21  5:21     ` [PATCH v3 1/3] wt-status: show sparse checkout status as well Elijah Newren via GitGitGadget
2020-06-21  5:21     ` [PATCH v3 2/3] git-prompt: document how in-progress operations affect the prompt Elijah Newren via GitGitGadget
2020-06-21  5:21     ` [PATCH v3 3/3] git-prompt: include sparsity state as well Elijah Newren via GitGitGadget
2020-06-22 16:35       ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2020-06-19  2:28 [PATCH v2 0/2] Sparse checkout status Russell Crume

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.808.v2.git.git.1592513398.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=dstolee@microsoft.com \
    --cc=git@vger.kernel.org \
    --cc=newren@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).