Commit Briefs

Mark Jamsek

got: further fetch tweaks to prevent unintended fetches

Implement stsp's suggestion to only fetch remote's HEAD if the symref refs/remote/*/HEAD exists, and its target no longer matches the remote HEAD. This ensures users tracking a project won't miss a change in HEAD, while also fixing the issue reported by naddy where HEAD was fetched by default even though a specific, potentially less active, branch is cloned, resulting in a repository with more commits than necessary. In addition, unless 'got fetch -b <branch>' is used, the remote HEAD branch will be fetched if branches are not set in got.conf and there is no work tree to ascertain a branch, or said branches are not found on the server. ok stsp@



Stefan Sperling

backout got: always fetch remote HEAD except when -b is used

As pointed out by naddy, this behaviour is not ideal when users want to limit their repository to a particular branch which will diverge from HEAD over time, such as -stable branches. See https://marc.gameoftrees.org/mail/1676388048.8632_0.html


Mark Jamsek

got: always fetch remote HEAD except when -b is used

Rather than only fetch HEAD when there are no branches set in got.conf and there is no branch to be inferred from a work tree, or said branches don't exist on the server, always fetch HEAD unless 'got fetch -b branch' is used. ok stsp@


Mark Jamsek

got: drop commit -A $GOT_AUTHOR restriction

As discussed with op and stsp on irc, this prevents the valid case of changing a commit's author to yourself during a histedit operation, and potentially blocks other valid use cases too. ok stsp@ and op@


Omar Polo

got/tog/gotadmin: pledge earlier

In the case of tog move setlocale(3) before pledge(2), as suggested by stsp. ok stsp@


Mark Jamsek

special case 'got fetch -b <branch>' to only fetch <branch>

As discussed on irc, this drops the implicit remote HEAD fetch when -b is used. got.1 has been updated to make the new fetch behaviour clear. ok stsp@


Stefan Sperling

make new log message modication check more robust; fixes regress fallout

ok jamsek


Mark Jamsek

garbage-collect redundant read_logmsg() parameter

As identified and suggested by stsp, with the previous commit, 'strip_comments' is now always set thus no longer needed. ok stsp@


Mark Jamsek

got: use timestamp and emptiness to validate log message

As suggested by naddy: consider commit log messages valid provided the temp file time stamp has changed and the file is not empty. This heuristic provides the desired behaviour (i.e., reusing cherrypicked/backed-out log messages) that's currently provided but is simpler to grok. Improved by and ok stsp@


Stefan Sperling

make edits made to comments count as a log message modification

This supports use of cherrypick/backout without requiring the user to modify the log message of the original commit. ok jamsek, op


Stefan Sperling

only fetch the work tree's branch by default if it is inside "refs/heads/"

ok jamsek


Stefan Sperling

fix interaction of 'got fetch -b', got.conf, and work tree

Without branches in got.conf for a remote, and without -b/-R options, the fallback to HEAD would only work when not invoked in a work tree. With this fix 'got fetch' should behave as described in the man page. The -b option now overrides both got.conf and the fallback to the work tree's branch. And fallback to HEAD works as expected when invoked in a repository. Also, do not strictly require remote repositories to provide a branch from the refs/heads/ namespace. In such cases users should be able to use -R to select something to fetch. ok jamsek


Stefan Sperling

improve 'got fetch' behaviour when work tree's branch is not on server

Only fetch the work tree's branch if the -b option is not specified. This keeps -b functional as an override when invoked in a work tree. Our previous changes did not consider that got.conf is also a source of lists of branches to fetch, and that -b is supposed to work as an override of any default behaviour. We were implicitly appending the work tree's branch as if it was mentioned as an override on the command line, which was wrong and based on a misunderstanding of the intended behaviour. Without -b on the command line we obtain a list of branches to fetch from got.conf and use this list if it is not empty. The repository's HEAD will be fetched only if neither the -b option, nor got.conf, nor a work tree tell us what to fetch. Make the man page more clear by moving the explanation of the default behaviour into the main section of 'got fetch', leaving the -a and -b option descriptions free of such details. ok jamsek


Mark Jamsek

fix mistaken instances returning NULL instead of err

While here, for consistency, check dup() return value for -1 rather than < 0. ok stsp@


Mark Jamsek

got: make fetch default to the work tree's current branch

As per stsp's todo item, if invoked in a work tree, make 'got fetch' default to fetching the work tree's current branch instead of the branch pointed to by the remote repository's HEAD. ok stsp@ and op@


Mark Jamsek

zap unused parameter in got_worktree_rebase_complete()

ok stsp@


Mark Jamsek

return err instead of NULL in got.c:print_backup_ref()

ok stsp@


Mark Jamsek

free cwd in cmd_backout() and cmd_cherrypick()

ok stsp@


Stefan Sperling

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


Mark Jamsek

show worktree UUID in backout/cherrypick -l output

When run from the repository, display the UUID to help the user know which logmsg refs belong to which work tree. Also, use "backout" or "cherrypick" in the log message header to distinguish output from 'got log'. Suggested by stsp on irc. ok stsp@


Mark Jamsek

add missed option conflict check for histedit -e and -f

Reviewed as part of previous commit adding histedit -d. ok stsp@


Mark Jamsek

got: add 'got histedit -d' flag to drop all commits

Like -f, except drop all commits. Discussed with op and stsp on irc. ok stsp@


Mark Jamsek

got: don't leave tmp "got-logmsg-*" files in the work tree

Reported by stsp on irc, and reviewed as part of the following regress commit covering the commit aspect of logmsg refs. Delete temp merge_log files if created during commits involving backed-out/cherrypicked changes. ok stsp@