Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git rebase stopped working in git for windows

Tags:

I'm observing very strange crashes in git rebase. Operations that I'm performing haven't change, but their result has changed since some time ago.

Instead of rebased branch I get help message from git rebase, describing command line options, and file bash.exe.stackdump with some hex numbers.

The same behavior is observed during execution of git pull --rebase. Rebasing pulled commits is my default setting therefore this misbehavior is very annoying.

Example:

$ git rebase master feature/tune-logging
usage: git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] [<upstream>] [<branch>]
   or: git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] --root [<branch>]
   or: git rebase --continue | --abort | --skip | --edit-todo

Available options are
    -v, --verbose         display a diffstat of what changed upstream
    -q, --quiet           be quiet. implies --no-stat
    --autostash           automatically stash/stash pop before and after
    --fork-point          ....

    [ skip ... ] 

Actions:
    --continue            continue
    --abort               abort and check out the original branch
    --skip                skip current patch and continue
    --edit-todo           edit the todo list during an interactive rebase
    --quit                abort but keep HEAD where it is
    --show-current-patch  show the patch file being applied or merged

I use Windows 7 x64, with recent updates. git version 2.18.0.windows.1

I also use SmartGit, running the same git executable.

Here is the output, obtained with GIT_TRACE=2

$ GIT_TRACE=2 git rebase master feature/tune-logging                                                                             
11:13:05.925709 exec-cmd.c:236          trace: resolved executable dir: C:/Program Files/Git/mingw64/bin                         
11:13:05.927709 git.c:654               trace: exec: git-rebase master feature/tune-logging                                      
11:13:05.927709 run-command.c:637       trace: run_command: git-rebase master feature/tune-logging                               
11:13:06.348751 exec-cmd.c:236          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core            
11:13:09.354050 exec-cmd.c:236          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core            
11:13:09.356050 git.c:415               trace: built-in: git rev-parse --git-dir                                                 
11:13:09.778092 exec-cmd.c:236          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core            
11:13:09.779092 git.c:415               trace: built-in: git rev-parse --git-path objects                                        
11:13:10.122126 exec-cmd.c:236          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core            
11:13:10.123126 git.c:415               trace: built-in: git rev-parse --is-bare-repository                                      
11:13:10.452159 exec-cmd.c:236          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core            
11:13:10.453159 git.c:415               trace: built-in: git rev-parse --show-toplevel                                           
11:13:10.827196 exec-cmd.c:236          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core            
11:13:10.829197 git.c:415               trace: built-in: git config --bool rebase.stat                                           
11:13:11.210235 exec-cmd.c:236          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core            
11:13:11.212235 git.c:415               trace: built-in: git config --bool rebase.autostash                                      
11:13:11.548269 exec-cmd.c:236          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core            
11:13:11.550269 git.c:415               trace: built-in: git config --bool rebase.autosquash                                     
11:13:11.869301 exec-cmd.c:236          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core            
11:13:11.871301 git.c:415               trace: built-in: git config --bool commit.gpgsign                                        
11:13:12.330347 exec-cmd.c:236          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core            
11:13:12.754389 exec-cmd.c:236          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core            
11:13:12.755389 git.c:415               trace: built-in: git rev-parse --parseopt --stuck-long -- -h                             
usage: git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] [<upstream>] [<branch>]                                       
   or: git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] --root [<branch>]                                             
   or: git rebase --continue | --abort | --skip | --edit-todo                                                                    

Available options are                                                                                                            
    -v, --verbose         display a diffstat of what changed upstream                                                            
    -q, --quiet           be quiet. implies --no-stat                                                                            
    --autostash           automatically stash/stash pop before and after                                                         

  [skip ]

Branches master and feature/tune-logging do exist.

UPDATE.

Tried rolling-back git to some previous version.

  1. Randomly chosen git version 2.12.2 worked fine, but caused complains of the SmartGit about too old git and suggestion to use version at least 2.16

  2. Upgraded git to 2.16.2 - same crashes.

UPDATE 2.

I describe my experiments.

Create a new branch on some old commit from the master, add dummy file, commit, delete dummy file, commit, rebase:

--c1--c2--c3--master
   \
    d1-add dummy file--d2-remove dummy file--

UPDATE 3

Tried git versions 2.15 and 2.14. Version 2.15 gives the same crashes, version 2.14 works.

Will stop on it for now, until the reason of crashes will be resolved. I'll try to provide additional information on order to find it.

UPDATE 4

I usually work with the SmartGit, which is a GUI front-end to git, but all the results above were obtained using command line.

like image 885
wl2776 Avatar asked Aug 13 '18 08:08

wl2776


2 Answers

Updated git to 2.19, the issue has gone.

While installing new git version, setup wizard has shown two checkboxes, asking to turn on new experimental built-in features: rebase and stash.

I've left them unchecked.

use external rebase and stash

Updated to git 2.19.1.windows.1, now turned those checkboxes on. Everything still works.

like image 194
wl2776 Avatar answered Oct 12 '22 08:10

wl2776


The built-in git rebase is now more complete with Git 2.21 (Feb. 2019), since instead of going through "git-rebase--am" scriptlet to use the "am" backend, the built-in version of "git rebase" learned to drive the "am" backend directly.

See commit 2185362, commit 414f336, commit 5b2237a, commit c523370 (18 Jan 2019) by Johannes Schindelin (dscho).
(Merged by Junio C Hamano -- gitster -- in commit e52c6bb, 07 Feb 2019)

built-in rebase: call git am directly

Signed-off-by: Johannes Schindelin

While the scripted git rebase still has to rely on the git-rebase--am.sh script to implement the glue between the rebase and the am commands, we can go a more direct route in the built-in rebase and avoid using a shell script altogether.

This patch represents a straight-forward port of git-rebase--am.sh to C, along with the glue code to call it directly from within builtin/rebase.c.

This reduces the chances of Git for Windows running into trouble due to problems with the POSIX emulation layer (known as "MSYS2 runtime", itself a derivative of the Cygwin runtime): when no shell script is called, the POSIX emulation layer is avoided altogether.

(Actually, with Git 2.22, Q2 2019, the built-in rebase is complete and stable, and the old script rebase is no more)


With Git 2.25 (Q1 2020), "git rebase --signoff" stopped working when the command was written in C, which has been corrected.

See commit 4fe7e43 (20 Dec 2019) by Elijah Newren (newren).
(Merged by Junio C Hamano -- gitster -- in commit e0e1ac5, 02 Jan 2020)

rebase: fix saving of --signoff state for am-based rebases

Signed-off-by: Elijah Newren

This was an error introduced in the conversion from shell in commit 21853626eac5 ("built-in rebase: call git am directly", 2019-01-18, Git v2.21.0-rc0 -- merge, seen above), which was noticed by a random browsing of the code.


As noted in With Git 2.26 (Q1 2020), "git rebase" now uses the "--apply" option to use the "apply" backend (e.g. the moral equivalent of "format-patch piped to am").

The rebase.backend configuration variable can be set to customize.

See commit 10cdb9f, commit 2ac0d62, commit 8295ed6, commit 76340c8, commit 980b482, commit c2417d3, commit 6d04ce7, commit 52eb738, commit 8af14f0, commit be50c93, commit befb89c, commit 9a70f3d, commit 93122c9, commit 55d2b6d, commit 8a997ed, commit 7db00f0, commit e98c426, commit d48e5e2 (15 Feb 2020), and commit a9ae8fd, commit 22a69fd (16 Jan 2020) by Elijah Newren (newren).
(Merged by Junio C Hamano -- gitster -- in commit 8c22bd9, 02 Mar 2020)

rebase: rename the two primary rebase backends

Signed-off-by: Elijah Newren

Rename the 'am' backend to 'apply' because:

  • Few users are familiar with git-am as a reference point.
  • Related to the above, the name 'am' makes sentences in the documentation harder for users to read and comprehend (they may read it as the verb from "I am"); avoiding this difficult places a large burden on anyone writing documentation about this backend to be very careful with quoting and sentence structure and often forces annoying redundancy to try to avoid such problems.
  • Users stumble over pronunciation ("am" as in "I am a person not a backend" or "am" as in "the first and thirteenth letters in the alphabet in order are "A-M"); this may drive confusion when one user tries to explain to another what they are doing.
  • While "am" is the tool driving this backend, the tool driving git-am is git-apply, and since we are driving towards lower-level tools for the naming of the merge backend we may as well do so here too.
  • The directory where state is stored has never been called .git/rebase-am, it was always called .git/rebase-apply.
like image 44
VonC Avatar answered Oct 12 '22 07:10

VonC