Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new feature: import/export marked commit lists #915

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

aaptel
Copy link

@aaptel aaptel commented Apr 13, 2019

When doing large backports or similar work that involves a lot of
cherry picking, it can be useful to maintain lists of commits. While
in the main view, Tig can mark commits via the toggle-bp-mark action,
which is bound to C-b by default. Marked commits title will be
displayed using an alternative style (main-bp-mark).

If a path is specified when running Tig (see -l option). Tig can
read and write marked commits. Tig tries to import that file on
startup if it exists, and writes to that file on exit.

The format of this file is simple, each line must have the following format:

<sha1>[ <optional text>]

Tig tries to keep the content of each line when it imports
it. Additional commits added during the Tig session will use the
commit title as text when exporting.

On exit, Tig sorts the marked commits by commit date (not author date)
and exports the marked lists to the file specified by the -l option.


  • new toggle-bp-mark user request (C-b)
  • new main-bp-mark font style
  • new bplist.{c,h} module to manipulate instances of bplists
  • new run opt -l to specify location to import/export marked list to

Currently tig has one global bplist, but the implementation is generic
enough and works on bplist instances so that in the future we could
have multiple bplists.

A bplist holds a list of lines and a hashtable that maps fully-expanded revs to lines.

  • bplist_init(): initialize a bplist
  • bplist_read(): load a bplist from a file into an initialized bplist
  • bplist_has_rev(): checks whether a bplist contains a commit rev
  • bplist_add_rev(): adds a rev to a bplist if it is not already there
  • bplist_rem_rev(): removes a rev from a bplist if it holds it
  • bplist_toggle_rev(): adds/remove rev from a bplist
  • bplist_write(): dump a bplist to a file

BP is short for BackPort. When you need to do a lot of backporting it
is useful to be able to mark/unmark and load/save lists of commits.

Currently tig has one global bplist, but the implementation is generic
enough and works on bplist instances so that in the future we could
have multiple bplist.

* bplist_init(): initialize a bplist
* bplist_read(): load a bplist from a file into an initialized bplist
* bplist_has_rev(): checks whether a bplist contains a commit rev
* bplist_add_rev(): adds a rev to a bplist if it is not already there
* bplist_rem_rev(): removes a rev from a bplist if it holds it
* bplist_toggle_rev(): adds/remove rev from a bplist
* bplist_write(): dump a bplist to a file

A bplist file is a plain text file where each line is in the form of

    <sha1>[ <text>]

Lines who do not match this format will be added as-is and not be
considered as commit. When writing a bplist, commits are sorted by
commit date.

Non-commit lines get a commit date of 0 and they end up at the top of
the line as a result.
* initialize the bplist in main() before parsing options
* add -l to load a bplist file or specify a file to save to on exit
* handle -lfoo and -l foo
* write bplist on exit if a file was specified
adds main-bp-mark line style option.
@magnayn
Copy link

magnayn commented May 9, 2019

I came here just to say this is exactly the feature I'm looking for!

My dev workflow is somewhat messy, and tends to be
a) pull master
b) interactive rebase, where I
select a number of commits and bubble them to the top
c) push several commits down the head to master

At the moment a is cmdline, c I actually use tig (previously to get the sha1, but now I found I can usefully bind a command), but (b) is a fairly rote 'git rebase -i'.

I think someone else was after a 'mark this commit so I can trigger a diff against it with a different commit' which would also be of interest.

@koutcher
Copy link
Collaborator

koutcher commented Jun 1, 2019

An alternative to this PR could be (with tig 2.5.0):

  • Add bind generic <C-B> @sh -c "git notes --ref=bplist add -m 'Pick Me! Pick Me!' %(commit) || git notes --ref=bplist remove %(commit)" to .tigrc
  • Start tig --notes=bplist or tig --notes=*
  • Toggle mark with C-b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants