git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Justin Donnelly via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Justin Donnelly" <justinrdonnelly@gmail.com>
Subject: [PATCH v2 0/4] In PS1 prompt, make upstream state indicators consistent with other state indicators
Date: Sun, 27 Feb 2022 19:57:08 +0000	[thread overview]
Message-ID: <pull.1162.v2.git.1645991832.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1162.git.1645789446.gitgitgadget@gmail.com>

These patches are about the characters and words that can be configured to
display in the PS1 prompt after the branch name. I've been unable to find a
consistent terminology. I refer to them as follows: [short | long] [type]
state indicator where short is for characters (e.g. ?), long is for words
(e.g. |SPARSE), and type is the type of indicator (e.g. sparse or upstream).
I'd be happy to change the commit messages to a different terminology if
that's preferred.

There are a few inconsistencies with the PS1 prompt upstream state indicator
(GIT_PS1_SHOWUPSTREAM).

 * With GIT_PS1_SHOWUPSTREAM="auto", if there are no other short state
   indicators (e.g. + for staged changes, $ for stashed changes, etc.), the
   upstream state indicator appears adjacent to the branch name (e.g.
   (main=)) instead of being separated by SP or GIT_PS1_STATESEPARATOR (e.g.
   (main =)).
 * If there are long state indicators (e.g. |SPARSE), a short upstream state
   indicator (i.e. GIT_PS1_SHOWUPSTREAM="auto") is to the right of the long
   state indicator (e.g. (main +|SPARSE=)) instead of with the other short
   state indicators (e.g. (main +=|SPARSE)).
 * The long upstream state indicator (e.g. GIT_PS1_SHOWUPSTREAM="verbose")
   is separated from other (short or long) state indicators by a hard-coded
   SP. Other long state indicators are separated by a hard-coded pipe (|).

These patches are to make the upstream state indicators more consistent with
other state indicators.

----------------------------------------------------------------------------

Changes since v1:

 * Added __git_ps1 examples and before/after tables to commit messages where
   applicable. This should make it clearer what the behavior is for other
   (not upstream) state indicators, and how the patches make the upstream
   state indicator more consistent.
 * Removed some extraneous information about long state indicators from
   patch 2 commit message. This wasn't really helpful, and was a
   distraction.

----------------------------------------------------------------------------

Justin Donnelly (4):
  git-prompt: rename `upstream` to `upstream_type`
  git-prompt: make upstream state indicator location consistent
  git-prompt: make long upstream state indicator consistent
  git-prompt: put upstream comments together

 contrib/completion/git-prompt.sh | 59 ++++++++++++++++----------------
 1 file changed, 30 insertions(+), 29 deletions(-)


base-commit: 4c53a8c20f8984adb226293a3ffd7b88c3f4ac1a
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1162%2Fjustinrdonnelly%2Fgit-prompt-upstream-consistency-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1162/justinrdonnelly/git-prompt-upstream-consistency-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1162

Range-diff vs v1:

 1:  1db836bb309 = 1:  1db836bb309 git-prompt: rename `upstream` to `upstream_type`
 2:  b503cac5ae3 ! 2:  4bf120b1bf8 git-prompt: make upstream state indicator location consistent
     @@ Commit message
          git-prompt: make upstream state indicator location consistent
      
          Make upstream state indicator location more consistent with similar
     -    state indicators (e.g. sparse). Group the short state indicator (`=`,
     -    `<`, `>`, or `<>`) with other short state indicators immediately after
     -    the branch name. Group the long state indicator (e.g. `u+2-1
     -    origin/main`) with other long state indicators after the short state
     -    indicators. Previously short and long upstream state indicators appeared
     -    after all other state indicators.
     +    state indicators (e.g. sparse). Group the short upstream state indicator
     +    (`=`, `<`, `>`, or `<>`) with other short state indicators immediately
     +    after the branch name. Previously short and long upstream state
     +    indicators appeared after all other state indicators.
      
          Use a separator (`SP` or `GIT_PS1_STATESEPARATOR`) between branch name
          and short upstream state indicator. Previously the short upstream state
          indicator would sometimes appear directly adjacent to the branch name
     -    (e.g. `(main=)`) instead of being separated (e.g. `(main =)`).
     +    instead of being separated.
     +
     +    For comparison, `__git_ps1` examples without upstream state indicator:
     +    (main)
     +    (main %)
     +    (main *%)
     +    (main|SPARSE)
     +    (main %|SPARSE)
     +    (main *%|SPARSE)
     +    (main|SPARSE|REBASE 1/2)
     +    (main %|SPARSE|REBASE 1/2)
     +
     +    Note that if there are short state indicators, they appear together
     +    after the branch name and separated from it by `SP` or
     +    `GIT_PS1_STATESEPARATOR`.
     +
     +    Before/after examples with short upstream state indicator:
     +    | Before           | After            |
     +    | ---------------- | ---------------- |
     +    | (main=)          | (main =)         |
     +    | (main|SPARSE=)   | (main =|SPARSE)  |
     +    | (main %|SPARSE=) | (main %=|SPARSE) |
      
          Signed-off-by: Justin Donnelly <justinrdonnelly@gmail.com>
      
 3:  83766e33614 ! 3:  0af083413b8 git-prompt: make long upstream state indicator consistent
     @@ Metadata
       ## Commit message ##
          git-prompt: make long upstream state indicator consistent
      
     -    Use a pipe as a delimiter between short state indicators and long
     -    upstream state indicator (e.g. `(main *|u+2-1 origin/main)` instead of
     -    `(main * u+2-1 origin/main)`) . This is consistent with long state
     -    indicators for sparse and in-progress operations (e.g. merge).
     +    Use a pipe as a separator before long upstream state indicator. This is
     +    consistent with long state indicators for sparse and in-progress
     +    operations (e.g. merge).
     +
     +    For comparison, `__git_ps1` examples without upstream state indicator:
     +    (main)
     +    (main %)
     +    (main *%)
     +    (main|SPARSE)
     +    (main %|SPARSE)
     +    (main *%|SPARSE)
     +    (main|SPARSE|REBASE 1/2)
     +    (main %|SPARSE|REBASE 1/2)
     +
     +    Note that if there are long state indicators, they appear after short
     +    state indicators if there are any, or after the branch name if there are
     +    no short state indicators. Each long state indicator begins with a pipe
     +    (`|`) as a separator.
     +
     +    Before/after examples with long upstream state indicator:
     +    | Before                          | After                           |
     +    | ------------------------------- | ------------------------------- |
     +    | (main u=)                       | (main|u=)                       |
     +    | (main u= origin/main)           | (main|u= origin/main)           |
     +    | (main u+1)                      | (main|u+1)                      |
     +    | (main u+1 origin/main)          | (main|u+1 origin/main)          |
     +    | (main % u=)                     | (main %|u=)                     |
     +    | (main % u= origin/main)         | (main %|u= origin/main)         |
     +    | (main % u+1)                    | (main %|u+1)                    |
     +    | (main % u+1 origin/main)        | (main %|u+1 origin/main)        |
     +    | (main|SPARSE u=)                | (main|SPARSE|u=)                |
     +    | (main|SPARSE u= origin/main)    | (main|SPARSE|u= origin/main)    |
     +    | (main|SPARSE u+1)               | (main|SPARSE|u+1)               |
     +    | (main|SPARSE u+1 origin/main)   | (main|SPARSE|u+1 origin/main)   |
     +    | (main %|SPARSE u=)              | (main %|SPARSE|u=)              |
     +    | (main %|SPARSE u= origin/main)  | (main %|SPARSE|u= origin/main)  |
     +    | (main %|SPARSE u+1)             | (main %|SPARSE|u+1)             |
     +    | (main %|SPARSE u+1 origin/main) | (main %|SPARSE|u+1 origin/main) |
      
          Signed-off-by: Justin Donnelly <justinrdonnelly@gmail.com>
      
 4:  58ff3d8affe = 4:  06e51dc5093 git-prompt: put upstream comments together

-- 
gitgitgadget

  parent reply	other threads:[~2022-02-27 19:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-25 11:44 [PATCH 0/4] In PS1 prompt, make upstream state indicators consistent with other state indicators Justin Donnelly via GitGitGadget
2022-02-25 11:44 ` [PATCH 1/4] git-prompt: rename `upstream` to `upstream_type` Justin Donnelly via GitGitGadget
2022-02-25 11:44 ` [PATCH 2/4] git-prompt: make upstream state indicator location consistent Justin Donnelly via GitGitGadget
2022-02-25 11:44 ` [PATCH 3/4] git-prompt: make long upstream state indicator consistent Justin Donnelly via GitGitGadget
2022-02-25 11:44 ` [PATCH 4/4] git-prompt: put upstream comments together Justin Donnelly via GitGitGadget
2022-02-25 12:22 ` [PATCH 0/4] In PS1 prompt, make upstream state indicators consistent with other state indicators Ævar Arnfjörð Bjarmason
2022-02-27  0:32   ` Justin Donnelly
2022-02-27 10:19     ` Ævar Arnfjörð Bjarmason
2022-02-27 19:57 ` Justin Donnelly via GitGitGadget [this message]
2022-02-27 19:57   ` [PATCH v2 1/4] git-prompt: rename `upstream` to `upstream_type` Justin Donnelly via GitGitGadget
2022-02-27 19:57   ` [PATCH v2 2/4] git-prompt: make upstream state indicator location consistent Justin Donnelly via GitGitGadget
2022-02-27 19:57   ` [PATCH v2 3/4] git-prompt: make long upstream state indicator consistent Justin Donnelly via GitGitGadget
2022-02-27 19:57   ` [PATCH v2 4/4] git-prompt: put upstream comments together Justin Donnelly via GitGitGadget
2022-03-22 12:25   ` [PATCH v2 0/4] In PS1 prompt, make upstream state indicators consistent with other state indicators Ævar Arnfjörð Bjarmason
2022-03-23 20:06     ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=pull.1162.v2.git.1645991832.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=justinrdonnelly@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).