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

Re: command prompt script for current branch

From
Jakub Narebski <jnareb@gmail.com>
Date
Feb 6, 2008, 22:56 UTC
Message-ID
<200802062356.41548.jnareb@gmail.com>
In-Reply-To
<9b3e2dc20802061413v5dbe349axe43a4af263e39878@mail.gmail.com>
On Wed, 6 Feb 2008, Stephen Sinclair wrote:

Please provide attribution (who write what) when quoting, like below:

> Jakub Narebski wrote:
>> "Stephen Sinclair" <radarsat1@gmail.com> writes:
Show 18 quoted lines
>>> Attached is a script I quickly wrote up yesterday.  Sometimes I've
>>> found I started working only to realize I was on the wrong branch.
>>> (Now that I'm accustomed to working with git, I make many small
>>> branches, so it happens.)
>>
>> First, it is much better to put such script inline, in the body of
>> your email.  This makes commenting about script body much easier.
>> And if you have to attach it, for example because your mailer mangles
>> whitespace (which is not the case here), make sure that attachement
>> uses "text/plain", and if possible "inline" disposition, to better
>> _view_ the code without need to save it to temporary file.
>>
>> I would take an exeption and comment on your code, even though you
>> make it hard to do so.
> 
> Thank you.  Since there's already a solution for this in contrib,
> (didn't see it, sorry), I'll just take your recommendations on coding
> style for any future stuff I do.

First, the code in contrib doesn't do all your code did. It doesn't show if workarea is "dirty" (although I'm not sure if this is very useful), nor does it show number of commits since or to mainline (origin) version, although with working on (with) feature/topic branches which does not have corresponding remote tracking branch it seems not useful.

On the other hand code in _git_ps1 (taken from one of the "git prompt" posts floating on git mailing list, and available in archives, together with /usr/share/stgit/contrib/stgbashprompt.sh from StGit, Quilt-like patch management layer on top of Git) shows also name of repository and path in repository, and also if the branch is managed by StGit.

Second, I think you have learned something. Both on rules regarding discussion, netiquette and sending contributions on this mailing list, and about how to write scripts for/around git. (At least I hope so).

-- 
Jakub Narebski
Poland
Previous: Stephen Sinclair
Message 16 of 16 in “command prompt script for current branch”
  1. Stephen SinclairFeb 6, 2008
  2. Junio C HamanoFeb 6, 2008
  3. Improve bash prompt to detect merge / rebase in progressRobin Rosenberg, Feb 6, 2008
  4. Robin RosenbergFeb 6, 2008
  5. Junio C HamanoFeb 6, 2008
  6. Robin RosenbergFeb 7, 2008
  7. Shawn O. PearceFeb 7, 2008
  8. Steffen ProhaskaFeb 8, 2008
  9. Johannes SchindelinFeb 8, 2008
  10. Steffen ProhaskaFeb 8, 2008
  11. Make git-completion.bash a first-class citizenJohannes Schindelin, Feb 8, 2008
  12. Jakub NarebskiFeb 6, 2008
  13. Mike HommeyFeb 6, 2008
  14. Jakub NarebskiFeb 6, 2008
  15. Stephen SinclairFeb 6, 2008
  16. Jakub NarebskiFeb 6, 2008

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.