Commit Briefs
replace date, strftime %G-%m-%d with %F
Use the more predictable %F, aka %Y-%m-%d, instead of %G-%m-%d. %G follows the definition of ISO-8601 week-based year, which is weird. In particular, 2024 is one of such years with weird behaviour: $ date -jf %Y-%m-%d +"%F %G-%m-%d" 2024-12-30 2024-12-30 2025-12-30 Diff from Lucas Gabriel Vuotto (thanks!); stsp agrees
make 'got status' display interrupted rebase, histedit, and merge operations
When an operation is interrupted add a trailing message to status output which displays the operation and branches involved. This information will be useful when diagnosing problem reports and it helps new users with contextualizing multi-operation work tree state. ok op@
make 'got rebase' find a merge base with topological sorting if needed
Fixes a problematic case of spurious conflicts encountered by naddy@ on landry's firefox package git repository. The current implementation of toposort is expensive, so this might make rebase appear to run slowly on large repositories. However, this is better than letting users deal with spurious conflicts. ok op@
add an xfail test for a case where rebase fails to forward a branch
Because 'got rebase' only does a first-parent traversal it will try to rebase commits which appear in the history of a branch, even when the branch to be rebased is already based on that history. This results in spurious merge conflicts as existing changes get re-applied. The desired behaviour would be that 'got rebase' forwards the branch, as it does when the 'got merge -M' command used by this test case is replaced by a simple 'got merge' which avoids creating a merge commit. Problem reported by naddy in the "Landry's firefox repository" thread: https://marc.gameoftrees.org/mail/1706721001.20565_0.html
replace "(cd path && git cmd)" with "git -C path cmd"
This matches the existing use of "got -r path cmd" and "git_commit path args".
when aborting rebase/histedit/merge, unlink files added by merged changes
Otherwise we leave unversioned files behind in the work tree which may interfere with new attempts to rebase or merge the changes again. Problem found by + ok naddy@
fix rebase/histedit -a leaving some files on the temporary branch
The commands 'got rebase -a' and 'got histedit -a' were checking out files from the wrong commit. Make them check files out from the commit we are switching the work tree to, as intended. Avoids spurious merge conflicts when the work tree is later used for another rebase operation. It also makes 'got update' right after 'rebase -a' a no-op, as it should be. Problem found by naddy@ while rebasing jca's llvm15 branch ok op, jamsek earlier version
regress: replace "sed -i" with ed(1) for portable in-place editing
"sed -i" is fundamentally unportable. GNU and OpenBSD sed(1) treat the extension for the backup file as an optional argument and use "sed -i" for no backup file. FreeBSD sed(1) treats the extension as an obligatory argument and uses "sed -i ''" for no backup file. There is no single syntax that works for both. ok stsp op
portable: regress: drop setting LC_TIME
common.sh sets LC_ALL=C which makes this change unnecessary now. Patch from Christian "naddy" Weisgerber.
portable: regress: drop GNU date on *BSDs
Check if date(1) supports -r and fallback to gdate if that fails, via a shell-wrapper. From Christian "naddy" Weisgerber.
make 'got rebase' work when the to-be-rebased branch has no parent commit
found by and ok op@, who also provided the test case
respect umask when creating or changing files and directories
This behaviour is already documented in got-worktree(5) but wasn't actually implemented. ok stsp@
don't undef GOT_AUTHOR in regress
unset only in the subshell so further cose is unaffected. ok stsp@
do not require local author info during 'got rebase'
My commit to reset committer info during rebase was too strict in some use cases. Even when simply forwarding a branch the rebase operation could now fail if GOT_AUTHOR is not set. To fix this, fall back on existing commiter information if no author is configured. And try to obtain author info from Git config in case GOT_AUTHOR is not set. Problems reported by Mikhail.
use test(1) -eq and -ne to compare integers, and reduce quoting
This brings the rest of the regression test scripts in line with patch.sh.
switch branches during noop rebases
Always update to the specified branch even if the branch is already rebased (no commits needed to be rebased, and the branch does not need a fast forward). With the old behavior of erroring and staying on the current branch, I sometimes found myself ignoring the error message, treating it as information and assuming the branch update, and later on committing on top of origin/main instead of the main branch. feedback and ok stsp