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