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

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 --stdin

That 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
Previous: Michal SojkaNext: Michal Sojka
Message 3 of 10 in “Re: [PATCH RFC] gitk: Allow commit editing”
  1. Michal SojkaAug 19, 2011
  2. gitk: Allow commit editingMichal Sojka, Aug 19, 2011
  3. Jeff KingAug 25, 2011
  4. Michal SojkaAug 25, 2011
  5. Jeff KingAug 25, 2011
  6. gitk: Allow commit editingMichal Sojka, Aug 27, 2011
  7. Jeff KingSep 7, 2011
  8. Paul MackerrasSep 8, 2011
  9. Michal SojkaSep 13, 2011
  10. Jeff KingAug 25, 2011

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.