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