Skip to content

Instantly share code, notes, and snippets.

@grahamperrin
Created August 2, 2023 01:09
Show Gist options
  • Save grahamperrin/fd2c5f9d2f01a1a9215a39a767b2c2f3 to your computer and use it in GitHub Desktop.
Save grahamperrin/fd2c5f9d2f01a1a9215a39a767b2c2f3 to your computer and use it in GitHub Desktop.
Git: when 'git rebase' is not exactly a good hint …

Notes to self.

I have no idea what might have led to conflicts involving files such as /usr/src/UPDATING

% git -C /usr/src stash
% gh repo sync grahamperrin/freebsd-src && git -C /usr/src pull --ff-only && git -C /usr/src pull --ff-only freebsd main
✓ Synced the "grahamperrin:main" branch from "freebsd:main"
Already up to date.
From https://git.freebsd.org/src
 * branch                      main       -> FETCH_HEAD
hint: Diverging branches can't be fast-forwarded, you need to either:
hint: 
hint:   git merge --no-ff
hint: 
hint: or:
hint: 
hint:   git rebase
hint: 
hint: Disable this message with "git config advice.diverging false"
fatal: Not possible to fast-forward, aborting.
% git -C /usr/src rebase freebsd main
fatal: invalid upstream 'freebsd'
% git -C /usr/src pull freebsd main
From https://git.freebsd.org/src
 * branch                      main       -> FETCH_HEAD
hint: You have divergent branches and need to specify how to reconcile them.
hint: You can do so by running one of the following commands sometime before
hint: your next pull:
hint: 
hint:   git config pull.rebase false  # merge
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint: 
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
fatal: Need to specify how to reconcile divergent branches.
% git -C /usr/src pull --rebase freebsd main
From https://git.freebsd.org/src
 * branch                      main       -> FETCH_HEAD
warning: skipped previously applied commit d5bd29ed505f
…
… (more than ten thousand lines)
…
warning: skipped previously applied commit 542497245dca
hint: use --reapply-cherry-picks to include skipped commits
hint: Disable this message with "git config advice.skippedCherryPicks false"
error: Unable to create '/usr/src/.git/index.lock': File exists.

Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.
error: could not detach HEAD
% ls -hln /usr/src/.git/index.lock
-rw-r--r--  1 1002 0    0B  1 Aug 16:00 /usr/src/.git/index.lock
% rm /usr/src/.git/index.lock
% git -C /usr/src pull --rebase freebsd main
From https://git.freebsd.org/src
 * branch                      main       -> FETCH_HEAD
warning: skipped previously applied commit d5bd29ed505f
…
… (more than ten thousand lines)
…
warning: skipped previously applied commit 542497245dca
hint: use --reapply-cherry-picks to include skipped commits
hint: Disable this message with "git config advice.skippedCherryPicks false"
Auto-merging UPDATING
CONFLICT (content): Merge conflict in UPDATING
Auto-merging contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h
Auto-merging libexec/rc/rc.conf
CONFLICT (content): Merge conflict in libexec/rc/rc.conf
Auto-merging release/Makefile
Auto-merging release/release.conf.sample
CONFLICT (content): Merge conflict in release/release.conf.sample
Auto-merging share/mk/src.opts.mk
CONFLICT (content): Merge conflict in share/mk/src.opts.mk
Auto-merging sys/amd64/conf/GENERIC
CONFLICT (modify/delete): sys/amd64/conf/GENERIC-NODEBUG deleted in bfd15705156b (Create the stable/13 branch) and modified in HEAD.  Version HEAD of sys/amd64/conf/GENERIC-NODEBUG left in tree.
Auto-merging sys/amd64/conf/MINIMAL
CONFLICT (modify/delete): sys/arm/conf/GENERIC-NODEBUG deleted in bfd15705156b (Create the stable/13 branch) and modified in HEAD.  Version HEAD of sys/arm/conf/GENERIC-NODEBUG left in tree.
Auto-merging sys/arm/conf/std.armv6
CONFLICT (content): Merge conflict in sys/arm/conf/std.armv6
Auto-merging sys/arm/conf/std.armv7
CONFLICT (content): Merge conflict in sys/arm/conf/std.armv7
Auto-merging sys/arm64/conf/GENERIC
CONFLICT (content): Merge conflict in sys/arm64/conf/GENERIC
CONFLICT (modify/delete): sys/arm64/conf/GENERIC-MMCCAM-NODEBUG deleted in bfd15705156b (Create the stable/13 branch) and modified in HEAD.  Version HEAD of sys/arm64/conf/GENERIC-MMCCAM-NODEBUG left in tree.
CONFLICT (modify/delete): sys/arm64/conf/GENERIC-NODEBUG deleted in bfd15705156b (Create the stable/13 branch) and modified in HEAD.  Version HEAD of sys/arm64/conf/GENERIC-NODEBUG left in tree.
Auto-merging sys/conf/newvers.sh
CONFLICT (content): Merge conflict in sys/conf/newvers.sh
Auto-merging sys/i386/conf/GENERIC
CONFLICT (modify/delete): sys/i386/conf/GENERIC-NODEBUG deleted in bfd15705156b (Create the stable/13 branch) and modified in HEAD.  Version HEAD of sys/i386/conf/GENERIC-NODEBUG left in tree.
Auto-merging sys/i386/conf/MINIMAL
Auto-merging sys/powerpc/conf/GENERIC
CONFLICT (content): Merge conflict in sys/powerpc/conf/GENERIC
CONFLICT (modify/delete): sys/powerpc/conf/GENERIC-NODEBUG deleted in bfd15705156b (Create the stable/13 branch) and modified in HEAD.  Version HEAD of sys/powerpc/conf/GENERIC-NODEBUG left in tree.
Auto-merging sys/powerpc/conf/GENERIC64
CONFLICT (content): Merge conflict in sys/powerpc/conf/GENERIC64
CONFLICT (modify/delete): sys/powerpc/conf/GENERIC64-NODEBUG deleted in bfd15705156b (Create the stable/13 branch) and modified in HEAD.  Version HEAD of sys/powerpc/conf/GENERIC64-NODEBUG left in tree.
Auto-merging sys/powerpc/conf/GENERIC64LE
CONFLICT (content): Merge conflict in sys/powerpc/conf/GENERIC64LE
Auto-merging sys/riscv/conf/GENERIC
CONFLICT (content): Merge conflict in sys/riscv/conf/GENERIC
CONFLICT (modify/delete): sys/riscv/conf/GENERIC-NODEBUG deleted in bfd15705156b (Create the stable/13 branch) and modified in HEAD.  Version HEAD of sys/riscv/conf/GENERIC-NODEBUG left in tree.
error: could not apply bfd15705156b... Create the stable/13 branch
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply bfd15705156b... Create the stable/13 branch
% git -C /usr/src pull --rebase abort
error: Pulling is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
% git -C /usr/src reset --hard HEAD
HEAD is now at 83453b46e8c2 mmc_xpt: Update function name in debug trace
% git -C /usr/src pull --rebase abort
fatal: 'abort' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
% git -C /usr/src rebase abort
fatal: It seems that there is already a rebase-merge directory, and
I wonder if you are in the middle of another rebase.  If that is the
case, please try
        git rebase (--continue | --abort | --skip)
If that is not the case, please
        rm -fr ".git/rebase-merge"
and run me again.  I am stopping in case you still have something
valuable there.

% rm -fr /usr/src/.git/rebase-merge
% git -C /usr/src rebase abort
fatal: invalid upstream 'abort'
% git -C /usr/src rebase --abort
fatal: No rebase in progress?
% git -C /usr/src pull --ff-only freebsd main
From https://git.freebsd.org/src
 * branch                      main       -> FETCH_HEAD
Already up to date.
% gh repo sync grahamperrin/freebsd-src && git -C /usr/src pull --ff-only && git -C /usr/src pull --ff-only freebsd main
✓ Synced the "grahamperrin:main" branch from "freebsd:main"
You are not currently on a branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

% git -C /usr/src branch
* (HEAD detached from 8885768c5ffe)
  main
  pkg-stage
  prefer-ee
  releng/13.2
  stable/12
  stable/13
% git -C /usr/src switch main
Previous HEAD position was 83453b46e8c2 mmc_xpt: Update function name in debug trace
Switched to branch 'main'
Your branch is behind 'origin/main' by 95 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
% git -C /usr/src pull --ff-only freebsd main
From https://git.freebsd.org/src
 * branch                      main       -> FETCH_HEAD
Updating 2a4d73f3cfbd..83453b46e8c2
Fast-forward
 Makefile                                                          |   3 +
 Makefile.inc1                                                     |  10 +-
 Makefile.libcompat                                                |   1 +
 cddl/compat/opensolaris/include/libproc.h                         |   3 -
 cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c           | 281 +++--------------------------------------------
 cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.h           |   6 +
 cddl/lib/libdtrace/libproc_compat.h                               |   2 -
 contrib/libarchive/NEWS                                           |   2 +
 contrib/libarchive/cat/cmdline.c                                  |  12 +-
 contrib/libarchive/cpio/cpio.c                                    |   7 +-
 contrib/libarchive/libarchive/archive.h                           |   4 +-
 contrib/libarchive/libarchive/archive_entry.h                     |   2 +-
 contrib/libarchive/libarchive/archive_read_disk_posix.c           |   2 +-
 contrib/libarchive/libarchive/archive_read_support_filter_bzip2.c |   4 +-
 contrib/libarchive/libarchive/archive_read_support_filter_lz4.c   |   2 +-
 contrib/libarchive/libarchive/archive_read_support_format_7zip.c  |   8 +-
 contrib/libarchive/libarchive/archive_read_support_format_lha.c   |   7 +-
 contrib/libarchive/libarchive/archive_read_support_format_rar.c   |   4 +-
 contrib/libarchive/libarchive/archive_read_support_format_rar5.c  |   2 +-
 contrib/libarchive/libarchive/archive_read_support_format_zip.c   |   4 +-
 contrib/libarchive/libarchive/archive_write_add_filter_bzip2.c    |   6 +-
 contrib/libarchive/libarchive/archive_write_add_filter_lz4.c      |   8 +-
 contrib/libarchive/libarchive/archive_write_add_filter_zstd.c     |   4 +-
 contrib/libarchive/libarchive/archive_write_disk_posix.c          |   7 +-
 contrib/libarchive/libarchive/archive_write_set_format_7zip.c     |   8 +-
 contrib/libarchive/tar/write.c                                    |   2 +
 contrib/libarchive/unzip/CMakeLists.txt                           |  37 -------
 contrib/libarchive/unzip/bsdunzip.1                               |   8 +-
 contrib/libarchive/unzip/bsdunzip.c                               | 108 +++++++++++++++---
 contrib/libarchive/unzip/bsdunzip.h                               |  63 +++++++++++
 contrib/libarchive/unzip/bsdunzip_platform.h                      |   8 --
 contrib/libarchive/unzip/cmdline.c                                | 250 ++++++++++++++++++++++++++++++++++++++++++
 contrib/libarchive/unzip/la_getline.c                             |  99 +++++++++++++++++
 contrib/libarchive/unzip/la_queue.h                               | 840 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 contrib/libarchive/unzip/test/CMakeLists.txt                      |  80 --------------
 contrib/libarchive/unzip/test/test.h                              |   2 +-
 contrib/libarchive/unzip/test/test_version.c                      |  34 ++++++
 lib/libc/net/inet.3                                               |  11 --
 lib/libc/sys/Makefile.inc                                         |   1 +
 lib/libexecinfo/tests/Makefile                                    |   3 +
 lib/libexecinfo/tests/sigtramp_test.c                             |  75 +++++++++++++
 lib/libproc/libproc.h                                             |   2 +-
 lib/libproc/proc_util.c                                           |  12 +-
 release/Makefile                                                  |   4 +-
 sbin/dhclient/tests/Makefile                                      |   3 +
 sbin/fsck_ffs/main.c                                              |  19 ++--
 sbin/fsck_ffs/suj.c                                               |  25 ++++-
 share/man/man4/filemon.4                                          |  15 ++-
 share/man/man5/src.conf.5                                         |  38 +++----
 share/man/man7/build.7                                            |  32 +++++-
 share/mk/Makefile                                                 |   1 +
 share/mk/bsd.files.mk                                             |   2 +-
 share/mk/bsd.lib.mk                                               |   7 +-
 share/mk/sys.machine.mk                                           |   2 +-
 sys/amd64/amd64/pmap.c                                            |  50 ++++++---
 sys/amd64/include/msan.h                                          |  11 +-
 sys/amd64/linux/linux_sysvec.c                                    |   2 +-
 sys/amd64/linux32/linux32_sysvec.c                                |   2 +-
 sys/arm/arm/unwind.c                                              |  14 +++
 sys/arm/include/pcpu.h                                            |   2 -
 sys/arm64/arm64/identcpu.c                                        | 255 +++++++++++++++++++++++++++++++++++++++++--
 sys/arm64/include/armreg.h                                        | 289 ++++++++++++++++++++++++++++++++++++++++--------
 sys/arm64/include/pcpu.h                                          |   2 -
 sys/cam/ata/ata_xpt.c                                             |  89 ---------------
 sys/cam/cam_periph.c                                              |   2 +
 sys/cam/cam_xpt.c                                                 | 113 +++----------------
 sys/cam/cam_xpt_internal.h                                        |   3 -
 sys/cam/mmc/mmc_xpt.c                                             |  36 +++---
 sys/cam/nvme/nvme_all.c                                           |   9 +-
 sys/cam/nvme/nvme_all.h                                           |   2 +
 sys/cam/nvme/nvme_xpt.c                                           |  43 +++-----
 sys/cam/scsi/scsi_all.c                                           |   2 +-
 sys/cam/scsi/scsi_pass.c                                          |  48 +++++---
 sys/cam/scsi/scsi_xpt.c                                           |  75 -------------
 sys/compat/linux/linux_socket.c                                   |   4 +-
 sys/conf/files                                                    |   1 +
 sys/conf/kern.post.mk                                             |   2 +-
 sys/conf/kern.pre.mk                                              |   2 +-
 sys/conf/kmod.mk                                                  |   2 +-
 sys/dev/amdsmn/amdsmn.c                                           |   7 ++
 sys/dev/amdtemp/amdtemp.c                                         |  17 ++-
 sys/dev/e1000/em_txrx.c                                           |  77 ++++++++-----
 sys/dev/e1000/if_em.c                                             |  23 ++--
 sys/dev/gve/gve_tx.c                                              |   6 +-
 sys/dev/intel/spi.c                                               |   4 +-
 sys/dev/md/embedfs.S                                              |   2 +-
 sys/dev/nvme/nvme_pci.c                                           |   1 +
 sys/dev/sk/if_sk.c                                                |   2 +-
 sys/fs/cd9660/cd9660_rrip.c                                       |  18 ++-
 sys/i386/linux/linux.h                                            |   2 +-
 sys/i386/linux/linux_sysvec.c                                     |   1 +
 sys/isa/isa_common.c                                              |   7 +-
 sys/kern/firmw.S                                                  |   2 +-
 sys/kern/subr_memdesc.c                                           | 325 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 sys/kern/subr_msan.c                                              |  21 ++--
 sys/kern/subr_pctrie.c                                            | 278 +++++++++++++++++++++--------------------------
 sys/kern/vfs_cache.c                                              |   2 -
 sys/libkern/gsb_crc32.c                                           |   3 +
 sys/net/iflib.c                                                   |   3 +-
 sys/net/vnet.h                                                    |   2 +-
 sys/netinet/ip_mroute.c                                           |  27 +++--
 sys/netinet/sctp_os_bsd.h                                         |  18 ++-
 sys/netinet/sctp_output.c                                         |   2 +-
 sys/netinet/sctp_pcb.c                                            |   2 +-
 sys/netinet/sctp_var.h                                            |   4 +-
 sys/netinet/sctputil.c                                            |   8 +-
 sys/netinet/sctputil.h                                            |   8 +-
 sys/netinet/tcp_var.h                                             |   5 +
 sys/netinet6/frag6.c                                              |   5 +
 sys/opencrypto/cbc_mac.c                                          |  19 ++--
 sys/riscv/include/pcpu.h                                          |   2 -
 sys/sys/_pctrie.h                                                 |   7 +-
 sys/sys/memdesc.h                                                 |  10 ++
 sys/sys/pcpu.h                                                    |   2 +-
 sys/sys/pctrie.h                                                  |  14 ++-
 sys/tools/amd64_ia32_vdso.sh                                      |   2 +-
 sys/tools/amd64_vdso.sh                                           |   2 +-
 sys/tools/vdso_wrap.S                                             |   2 +-
 sys/ufs/ffs/ffs_alloc.c                                           | 148 ++++++++++++-------------
 sys/ufs/ffs/ffs_extern.h                                          |  19 ++--
 sys/ufs/ffs/ffs_inode.c                                           |  10 +-
 sys/ufs/ffs/ffs_rawread.c                                         |   4 +-
 sys/ufs/ffs/ffs_snapshot.c                                        |  10 +-
 sys/ufs/ffs/ffs_softdep.c                                         |  28 ++---
 sys/ufs/ffs/ffs_subr.c                                            |  30 ++---
 sys/ufs/ffs/ffs_tables.c                                          |   6 +-
 sys/ufs/ffs/ffs_vfsops.c                                          |  25 ++---
 sys/ufs/ffs/ffs_vnops.c                                           |  33 +++---
 sys/ufs/ffs/fs.h                                                  |  78 ++++++-------
 sys/ufs/ffs/softdep.h                                             |   4 +-
 sys/ufs/ufs/dinode.h                                              |  38 +++----
 sys/ufs/ufs/dir.h                                                 |  28 ++---
 sys/ufs/ufs/dirhash.h                                             |   2 +-
 sys/ufs/ufs/extattr.h                                             |   2 +-
 sys/ufs/ufs/inode.h                                               |  20 ++--
 sys/ufs/ufs/quota.h                                               |  46 ++++----
 sys/ufs/ufs/ufs_dirhash.c                                         |   6 +-
 sys/ufs/ufs/ufs_gjournal.c                                        |   6 +-
 sys/ufs/ufs/ufs_lookup.c                                          |  19 ++--
 sys/ufs/ufs/ufs_quota.c                                           |  30 ++---
 sys/ufs/ufs/ufs_vfsops.c                                          |   2 +-
 sys/ufs/ufs/ufs_vnops.c                                           |  14 +--
 sys/ufs/ufs/ufsmount.h                                            |  20 ++--
 sys/vm/_vm_radix.h                                                |   7 +-
 sys/vm/vm_fault.c                                                 |   3 +-
 sys/vm/vm_map.c                                                   |  13 +--
 sys/vm/vm_map.h                                                   |   4 +-
 sys/vm/vm_mmap.c                                                  |   4 +-
 sys/vm/vm_radix.c                                                 | 334 +++++++++++++++++++++++++++-----------------------------
 sys/vm/vm_radix.h                                                 |  14 ++-
 sys/x86/linux/linux_x86.c                                         |  18 ++-
 sys/x86/linux/linux_x86.h                                         |   6 +
 tests/sys/geom/class/gate/Makefile                                |   3 +
 tests/sys/geom/class/mirror/Makefile                              |   3 +
 tests/sys/vm/Makefile                                             |   8 ++
 tests/sys/vm/mmap_map_32bit_helper.c                              |  51 +++++++++
 tests/sys/vm/mmap_map_32bit_test.sh                               |  37 +++++++
 tools/build/Makefile                                              |  21 +++-
 tools/test/stress2/misc/killpg2.sh                                | 197 +++++++++++++++++++++++++++++++++
 tools/test/stress2/misc/killpg3.sh                                | 192 ++++++++++++++++++++++++++++++++
 tools/test/stress2/misc/killpg4.sh                                | 114 +++++++++++++++++++
 tools/tools/nanobsd/rescue/R32                                    |  14 ---
 tools/tools/nanobsd/rescue/build.sh                               |   8 --
 tools/tools/nanobsd/rescue/merge.sh                               |  28 -----
 tools/tools/nanobsd/rescue/rescue_i386.conf                       |  10 --
 usr.bin/gh-bc/Makefile                                            |  16 +--
 usr.bin/xargs/tests/regress.sh                                    |   6 +-
 usr.sbin/bhyve/fwctl.c                                            |  36 ++++--
 usr.sbin/etcupdate/etcupdate.sh                                   |   4 +-
 169 files changed, 4147 insertions(+), 1816 deletions(-)
 delete mode 100644 contrib/libarchive/unzip/CMakeLists.txt
 create mode 100644 contrib/libarchive/unzip/bsdunzip.h
 create mode 100644 contrib/libarchive/unzip/cmdline.c
 create mode 100644 contrib/libarchive/unzip/la_getline.c
 create mode 100644 contrib/libarchive/unzip/la_queue.h
 delete mode 100644 contrib/libarchive/unzip/test/CMakeLists.txt
 create mode 100644 contrib/libarchive/unzip/test/test_version.c
 create mode 100644 lib/libexecinfo/tests/sigtramp_test.c
 create mode 100644 sys/kern/subr_memdesc.c
 create mode 100644 tests/sys/vm/mmap_map_32bit_helper.c
 create mode 100644 tests/sys/vm/mmap_map_32bit_test.sh
 create mode 100755 tools/test/stress2/misc/killpg2.sh
 create mode 100755 tools/test/stress2/misc/killpg3.sh
 create mode 100755 tools/test/stress2/misc/killpg4.sh
 delete mode 100644 tools/tools/nanobsd/rescue/R32
 delete mode 100755 tools/tools/nanobsd/rescue/merge.sh
 delete mode 100644 tools/tools/nanobsd/rescue/rescue_i386.conf
% gh repo sync grahamperrin/freebsd-src && git -C /usr/src pull --ff-only && git -C /usr/src pull --ff-only freebsd main
✓ Synced the "grahamperrin:main" branch from "freebsd:main"
Already up to date.
From https://git.freebsd.org/src
 * branch                      main       -> FETCH_HEAD
Already up to date.
% 
@ITmrHoang
Copy link

metoo, i reseach. It can a config of devops for git. when pull really change hash of log root branh, therefore they disallowance fast-forword change

@ITmrHoang
Copy link

you can use
disable pull rebase by:

git config pull.rebase false

and change ff only to true

git config pull.ff true

you can merge tow branh ff overrive hash of commit branh(feature) merge to branh root (develop) other in pull request. if have change in develop repositry remote it have confict

@soulofkapal
Copy link

Thank you very much With the help of the last commands I can solve my problem with pull, this fixed the whole problem, I couldn’t find the problem on the Internet for an hour, and here I found everything I needed, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment