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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ TIG_OBJS = \
src/grep.o \
src/ui.o \
src/apps.o \
src/bplist.o \
$(GRAPH_OBJS) \
$(COMPAT_OBJS)

Expand Down
28 changes: 28 additions & 0 deletions doc/manual.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,33 @@ be appended:
[main] 77d9e40fbcea3238015aea403e06f61542df9a31 - commit 1 of 779 (0%) 5s
-----------------------------------------------------------------------------

[[bp-mark-list]]
Commit Marks
------------

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.

[[env-variables]]
Environment Variables
---------------------
Expand Down Expand Up @@ -465,6 +492,7 @@ Misc
|: |Open prompt. This allows you to specify what command to run and also to
jump to a specific line, e.g. `:23`
|e |Open file in editor.
|<C-b> |Toggle the BP mark on current commit.
|=============================================================================

[[prompt]]
Expand Down
4 changes: 4 additions & 0 deletions doc/tig.1.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ grep::
-C<path>::
Run as if Tig was started in <path> instead of the current working directory.

-l<path>::
If <path> exists, load marked commits and dump marked commits to it on exit.
Otherwise, create and dump marked commits to it on exit.

PAGER MODE
----------

Expand Down
2 changes: 2 additions & 0 deletions doc/tigrc.5.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,7 @@ View manipulation
|view-close |Close the current view
|view-close-no-quit |Close the current view without quitting
|quit |Close all views and quit
|toggle-bp-mark |Toggle BP mark
|=============================================================================

View-specific actions
Expand Down Expand Up @@ -1038,6 +1039,7 @@ setting the *default* color option.
|main-local-tag |Label of a local tag.
|main-ref |Label of any other reference.
|main-replace |Label of replaced reference.
|main-bp-mark |Title of marked commit (BP mark)
|=============================================================================

.Status view
Expand Down
35 changes: 35 additions & 0 deletions include/tig/bplist.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* Copyright (c) 2019 Aurelien Aptel <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

#ifndef TIG_BPLIST_H
#define TIG_BPLIST_H

extern struct bplist global_bplist;

void bplist_init(struct bplist *bpl, size_t capacity, const char *fn);

const char * bplist_get_fn(struct bplist *bpl);
void bplist_set_fn(struct bplist *bpl, const char *fn);

bool bplist_has_rev(struct bplist *bpl, const char *rev);
void bplist_add_line(struct bplist *bpl, const char *line);
int bplist_add_rev(struct bplist *bpl, const char *rev, const char *sline);
void bplist_rem_rev(struct bplist *bpl, const char *rev);
bool bplist_toggle_rev(struct bplist *bpl, const char *rev);

int bplist_read(struct bplist *bpl, const char *fn);
int bplist_write(struct bplist *bpl, const char *fn);

void init_bplist(void);

#endif
1 change: 1 addition & 0 deletions include/tig/line.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ struct ref;
_(MAIN_TRACKED, ""), \
_(MAIN_REF, ""), \
_(MAIN_HEAD, ""), \
_(MAIN_BP_MARK, ""), \
_(STAT_NONE, ""), \
_(STAT_STAGED, ""), \
_(STAT_UNSTAGED, ""), \
Expand Down
1 change: 1 addition & 0 deletions include/tig/request.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
REQ_(PROMPT, "Open the prompt"), \
REQ_(OPTIONS, "Open the options menu"), \
REQ_(SCREEN_REDRAW, "Redraw the screen"), \
REQ_(TOGGLE_BP_MARK, "Toggle BP mark"), \
REQ_(STOP_LOADING, "Stop all loading views"), \
REQ_(SHOW_VERSION, "Show version information"), \
REQ_(NONE, "Do nothing")
Expand Down
Loading