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

Re: [PATCH v2] git-branch: display sha1 on branch deletion

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Dec 15, 2008, 17:23 UTC
Message-ID
<urlVZPqgW2MvLyyMWmI_xoDCxnKMd-kyAs1vihhFHBiFmQ3aPtF7Pw@cipher.nrlssc.navy.mil>
In-Reply-To
<20081213063104.GA8480@coredump.intra.peff.net>
Jeff King wrote:
Show 14 quoted lines
> On Fri, Dec 12, 2008 at 05:20:07PM -0600, Brandon Casey wrote:
> 
>> Make it easier to recover from a mistaken branch deletion by displaying the
>> sha1 of the branch's tip commit.
> 
> This version looks fine to me, but one nit:
> 
>> -     test "$(git branch -d my7 2>&1)" = "Deleted branch my7."'
>> +     sha1=$(git rev-parse my7 | cut -c 1-7) &&
>> +     test "$(git branch -d my7 2>&1)" = "Deleted branch my7 ($sha1)."'
> 
> There is a very very small chance that this sha1 might require more
> than 7 characters to be unique (small because we have such a tiny number
> of objects in the trash repo).

Yeah I was counting on the smallness of that chance to let me be lazy and not think about how to get the proper abbreviated sha1.

Show 7 quoted lines
> Maybe:
> 
>   sha1=$(git log --pretty=format:%h -1 my7)
> 
> is better (though I have to admit, if I were writing the test originally
> I would have tested the exit value of "git branch" instead of the
> message).
My feelings won't be hurt if you want to change it.
-brandon
Previous: Jeff King
Message 6 of 6 in “git-branch: display sha1 on branch deletion”
  1. git-branch: display sha1 on branch deletionBrandon Casey, Dec 12, 2008
  2. Jeff KingDec 12, 2008
  3. Brandon CaseyDec 12, 2008
  4. git-branch: display sha1 on branch deletionBrandon Casey, Dec 12, 2008
  5. Jeff KingDec 13, 2008
  6. Brandon CaseyDec 15, 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.