Re: [PATCH] gitk: Allow commit editing
- From
Jeff King <peff@peff.net>
- Date
- Aug 25, 2011, 03:14 UTC
- Message-ID
- <20110825031420.GB3465@sigill.intra.peff.net>
- In-Reply-To
- <1313756753-26498-1-git-send-email-sojka@os.inf.tu-dresden.de>
On Fri, Aug 19, 2011 at 02:25:53PM +0200, Michal Sojka wrote:
Show 5 quoted lines
> + if {[exec git branch -r --contains=$rowmenuid] ne {}} {
> + if {![confirm_popup [mc "The commit you are going to edit appears in at least one\
> + remote branch. It is a bad idea to change a branch that is\
> + possibly used by other people. See git-rebase(1) for details.\n\n\
> + Do you want to continue?"]]} return }We frown on using porcelain like "git branch" here, because it was not meant to be scriptable (i.e., its behavior may change in future releases).
As I mentioned elsewhere, I think you really want to see whether the commit is referenced by any other ref, not just branches; if it is, then the rebase is potentially problematic. You can do that with something like:
us=`git symbolic-ref HEAD`
git for-each-ref --format='%(refname)' |
while read ref; do
test "$ref" = $us" && continue
echo "^$ref"
done |
git rev-list HEAD --stdinThat will give a list of commits found only on HEAD and nowhere else (i.e., those which are safe to rebase). If your commit is among them, then it's safe.
Speaking of which, notice that I used HEAD here. What happens with your patch if I do:
$ git checkout foo $ gitk bar
and select a commit to edit that is not in "foo"?
-Peff