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

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

From
Jeff King <peff@peff.net>
Date
Dec 13, 2008, 06:31 UTC
Message-ID
<20081213063104.GA8480@coredump.intra.peff.net>
In-Reply-To
<UfCPFu_boLV0ycLKLmOno8GTqmtC4RSZZ9O6aRLGYjmSZOdKv6ywhCjApnplTHLxUIzO8KJ5Mww@cipher.nrlssc.navy.mil>
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). 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).

-Peff
Previous: Brandon CaseyNext: Brandon Casey
Message 5 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.