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

[BUG REPORT] `git rebase --exec` shouldn't run the exec command when there is nothing to rebase

From
NBNikita Bobko <nikitabobko@gmail.com>
Date
Nov 26, 2021, 12:44 UTC
Message-ID
<CAMJzOtyw78-8gt3oGscN7KUzpzRRWtAQuGfcJ+R_Fjoom9Lexw@mail.gmail.com>

Steps: git rebase HEAD --exec "echo foo"

EXPECTED: since 0 commits are going to be rebased then I expect "foo"
NOT to be printed
ACTUAL:   "foo" is printed

A real-world example where such behavior is really unexpected - I have a script that signs a series of commits like this: ```bash head="$(git rev-parse HEAD)"

# Generate some commits (in my case it's cherry-picking commits from public GitHub subtree repo to internal monorepo)

file="$(mktemp)" git rebase $head --exec "git log -1 --pretty='%B' > $file" \ --exec "echo 'closes 'https://github.com/JetBrains/intellij-community/pull/$1' >> $file" \ --exec "git commit --amend -F $file" ``` But if none of the commits were generated then `git rebase --exec` will amend the HEAD which is not expected. It means that I have to process the case when 0 zero commits are generated separately.

If you agree that it's a bug then, most likely, it won't be possible to fix it because it would break compatibility. Well, yes then this bug report is JFYI.

[System Info] git version: git version 2.33.0 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 5.4.98-1-lts #1 SMP Sat, 13 Feb 2021 19:22:14 +0000 x86_64 compiler info: gnuc: 11.1 libc info: glibc: 2.33 $SHELL (typically, interactive shell): /bin/zsh

[Enabled Hooks]
Next: Ævar Arnfjörð Bjarmason
Message 1 of 6 in “[BUG REPORT] `git rebase --exec` shouldn't run the exec command when there is nothing to rebase”
  1. Nikita BobkoNov 26, 2021
  2. Ævar Arnfjörð BjarmasonNov 29, 2021
  3. Elijah NewrenNov 30, 2021
  4. Taylor BlauNov 30, 2021
  5. Elijah NewrenNov 30, 2021
  6. Phillip WoodNov 30, 2021

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.